mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
BUG-ID: CLOUDSTACK-7653. VM's are not getting deleted from hypervisor after deleting from UI when using zone wide primary storage.
While expunging a volume, CS chooses the endpoint to perform delete operation by selecting any host that has the storage containing the volume mounted on it. Instead, if the volume to be deleted is attached to a VM, the endpoint chosen by CCP should be the host that contains the VM.
This commit is contained in:
parent
6b06970366
commit
f1e3e83bbf
@ -22,5 +22,6 @@ public enum StorageAction {
|
||||
TAKESNAPSHOT,
|
||||
BACKUPSNAPSHOT,
|
||||
DELETESNAPSHOT,
|
||||
MIGRATEVOLUME
|
||||
MIGRATEVOLUME,
|
||||
DELETEVOLUME
|
||||
}
|
||||
|
||||
@ -302,6 +302,17 @@ public class DefaultEndPointSelector implements EndPointSelector {
|
||||
return getEndPointFromHostId(hostId);
|
||||
}
|
||||
}
|
||||
} else if (action == StorageAction.DELETEVOLUME) {
|
||||
VolumeInfo volume = (VolumeInfo)object;
|
||||
if (volume.getHypervisorType() == Hypervisor.HypervisorType.VMware) {
|
||||
VirtualMachine vm = volume.getAttachedVM();
|
||||
if (vm != null) {
|
||||
Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
|
||||
if (hostId != null) {
|
||||
return getEndPointFromHostId(hostId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return select(object);
|
||||
}
|
||||
|
||||
@ -1594,9 +1594,12 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
|
||||
String vmName = vol.getVmName();
|
||||
if (vmName != null) {
|
||||
// Find VM under the datacenter and not just the cluster.
|
||||
DatacenterMO dcMo = new DatacenterMO(context, morDc);
|
||||
VirtualMachineMO vmMo = dcMo.findVm(vmName);
|
||||
VirtualMachineMO vmMo = clusterMo.findVmOnHyperHost(vmName);
|
||||
if (vmMo == null) {
|
||||
// Volume might be on a zone-wide storage pool, look for VM in datacenter
|
||||
DatacenterMO dcMo = new DatacenterMO(context, morDc);
|
||||
vmMo = dcMo.findVm(vmName);
|
||||
}
|
||||
if (vmMo != null) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Destroy root volume and VM itself. vmName " + vmName);
|
||||
|
||||
@ -204,7 +204,12 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
|
||||
|
||||
CommandResult result = new CommandResult();
|
||||
try {
|
||||
EndPoint ep = epSelector.select(data);
|
||||
EndPoint ep = null;
|
||||
if (data.getType() == DataObjectType.VOLUME) {
|
||||
ep = epSelector.select(data, StorageAction.DELETEVOLUME);
|
||||
} else {
|
||||
ep = epSelector.select(data);
|
||||
}
|
||||
if (ep == null) {
|
||||
String errMsg = "No remote endpoint to send DeleteCommand, check if host or ssvm is down?";
|
||||
s_logger.error(errMsg);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user