Skip to content

Commit 94ea273

Browse files
author
Likitha Shetty
committed
CLOUDSTACK-5927. Storage garbage collector is trying to destroy the SSVM/CPVM root disk that is in use.
In case of VMware VM during root volume preparation if we are switching to a new volume, force expunge root disk that was created from the old template. Because otherwise storage garbage collector will later try to expunge the old disk marked for expunge and fail with 'Cannot delete file' exception since in VMware the new root vmdk has the same name and is now in use.
1 parent d5e0dcd commit 94ea273

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,16 @@ public VolumeVO doInTransaction(TransactionStatus status) {
808808
} catch (NoTransitionException e) {
809809
s_logger.debug("Unable to destroy existing volume: " + e.toString());
810810
}
811-
811+
// In case of VMware VM will continue to use the old root disk until expunged, so force expunge old root disk
812+
if (vm.getHypervisorType() == HypervisorType.VMware) {
813+
s_logger.info("Expunging volume " + existingVolume.getId() + " from primary data store");
814+
AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volFactory.getVolume(existingVolume.getId()));
815+
try {
816+
future.get();
817+
} catch (Exception e) {
818+
s_logger.debug("Failed to expunge volume:" + existingVolume.getId(), e);
819+
}
820+
}
812821
return newVolume;
813822
}
814823
});

‎plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,7 @@ public Answer cloneVolumeFromBaseTemplate(CopyCommand cmd) {
363363
// restoreVM - move the new ROOT disk into corresponding VM folder
364364
String vmInternalCSName = volume.getVmName();
365365
if (dsMo.folderExists(String.format("[%s]", dsMo.getName()), vmInternalCSName)) {
366-
String oldRootDisk = VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(dsMo, vmInternalCSName, vmdkFileBaseName);
367-
if (oldRootDisk != null)
368-
VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(dcMo, vmInternalCSName, dsMo, vmdkFileBaseName);
366+
VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(dcMo, vmInternalCSName, dsMo, vmdkName);
369367
}
370368

371369
VolumeObjectTO newVol = new VolumeObjectTO();

0 commit comments

Comments
 (0)