mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	This PR marks the multipath scripts as executable.
This fixes the issue that in 4.19.0.0-RC2, vms can not be stopped in ubuntu hosts.
2024-01-17 12:56:26,061 ERROR [c.c.v.VmWorkJobHandlerProxy] (Work-Job-Executor-4:ctx-e3503563 job-38/job-39 ctx-42706275) (logid:81ede4e9) Invocation exception, caused by: com.cloud.utils.exception.CloudRuntimeException: Unable to stop the virtual machine due to java.lang.NullPointerException
        at com.cloud.utils.script.Script.getExitValue(Script.java:74)
        at com.cloud.hypervisor.kvm.storage.MultipathSCSIAdapterBase.runScript(MultipathSCSIAdapterBase.java:476)
        at com.cloud.hypervisor.kvm.storage.MultipathSCSIAdapterBase.disconnectPhysicalDiskByPath(MultipathSCSIAdapterBase.java:226)
        at com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager.disconnectPhysicalDiskByPath(KVMStoragePoolManager.java:205)
        at com.cloud.hypervisor.kvm.resource.LibvirtComputingResource.cleanupDisk(LibvirtComputingResource.java:3335)
        at com.cloud.hypervisor.kvm.resource.wrapper.LibvirtStopCommandWrapper.execute(LibvirtStopCommandWrapper.java:101)
        at com.cloud.hypervisor.kvm.resource.wrapper.LibvirtStopCommandWrapper.execute(LibvirtStopCommandWrapper.java:49)
        at com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper.execute(LibvirtRequestWrapper.java:78)
        at com.cloud.hypervisor.kvm.resource.LibvirtComputingResource.executeRequest(LibvirtComputingResource.java:1903)
		
	
			
		
			
				
	
	
		
			72 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			72 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env bash
 | |
| # Licensed to the Apache Software Foundation (ASF) under one
 | |
| # or more contributor license agreements.  See the NOTICE file
 | |
| # distributed with this work for additional information
 | |
| # regarding copyright ownership.  The ASF licenses this file
 | |
| # to you under the Apache License, Version 2.0 (the
 | |
| # "License"); you may not use this file except in compliance
 | |
| # with the License.  You may obtain a copy of the License at
 | |
| #
 | |
| #   http://www.apache.org/licenses/LICENSE-2.0
 | |
| #
 | |
| # Unless required by applicable law or agreed to in writing,
 | |
| # software distributed under the License is distributed on an
 | |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 | |
| # KIND, either express or implied.  See the License for the
 | |
| # specific language governing permissions and limitations
 | |
| # under the License.
 | |
| 
 | |
| #########################################################################################
 | |
| #
 | |
| # Given a WWID, cleanup/remove any multipath and devices associated with this WWID.  This
 | |
| # may not always have lasting result because if the storage array still has the volume
 | |
| # visable to the host, it may be rediscovered.  The cleanupStaleMaps.sh script should
 | |
| # catch those cases
 | |
| #
 | |
| #########################################################################################
 | |
| 
 | |
| WWID=${1:?"WWID required"}
 | |
| WWID=$(echo $WWID | tr '[:upper:]' '[:lower:]')
 | |
| 
 | |
| echo "$(date): Removing ${WWID}"
 | |
| 
 | |
| systemctl is-active multipathd || systemctl restart multipathd || {
 | |
|    echo "$(date): Multipathd is NOT running and cannot be started.  This must be corrected before this host can access this storage volume."
 | |
|    logger -t "CS_SCSI_VOL_REMOVE" "${WWID} cannot be disconnected from this host because multipathd is not currently running and cannot be started"
 | |
|    exit 1
 | |
| }
 | |
| 
 | |
| # first get dm- name
 | |
| DM_NAME=$(ls -lrt /dev/mapper/3${WWID} | awk '{ print $NF }' | awk -F'/' '{print $NF}')
 | |
| SLAVE_DEVS=""
 | |
| if [ -z "${DM_NAME}" ]; then
 | |
|    logger -t CS_SCSI_VOL_REMOVE "${WWID} has no active multimap so no removal performed"
 | |
|    logger -t CS_SCSI_VOL_REMOVE "WARN: dm name could not be found for ${WWID}"
 | |
|    dmsetup remove /dev/mapper/*${WWID}
 | |
|    logger -t CS_SCSI_VOL_REMOVE "${WWID} removal via dmsetup remove /dev/mapper/${WWID} finished with return code $?"
 | |
| else
 | |
|    # now look for slave devices and save for deletion
 | |
|    for dev in $(ls /sys/block/${DM_NAME}/slaves/ 2>/dev/null); do
 | |
|       SLAVE_DEVS="${SLAVE_DEVS} ${dev}"
 | |
|    done
 | |
| fi
 | |
| 
 | |
| # delete the path map last
 | |
| multipath -f 3${WWID}
 | |
| 
 | |
| # now delete slave devices
 | |
| # https://bugzilla.redhat.com/show_bug.cgi?id=1949369
 | |
| if [ ! -z "${SLAVE_DEVS}" ]; then
 | |
|   for dev in ${SLAVE_DEVS}; do
 | |
|      multipathd del path /dev/${dev}
 | |
|      echo "1" > /sys/block/${dev}/device/delete
 | |
|      logger -t CS_SCSI_VOL_REMOVE "${WWID} removal of device ${dev} complete"
 | |
|   done
 | |
| fi
 | |
| 
 | |
| logger -t CS_SCSI_VOL_REMOVE "${WWID} successfully purged from multipath along with slave devices"
 | |
| 
 | |
| echo "$(date): ${WWID} removed"
 | |
| 
 | |
| exit 0
 |