Skip to content

Commit 42941b3

Browse files
author
Likitha Shetty
committed
CLOUDSTACK-5122. System VMs are getting recreated with old template after upgrading to 4.2.
In VMware during VM start the existing disk information is used to configure the VMs. So even if a new disk is created using the new template VM continues to use the old disk. Once the old root disk is marked for destroy force expunge it and sync the new disk into the VM folder before VM start
1 parent 6d8dbd5 commit 42941b3

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,6 @@ public Answer cloneVolumeFromBaseTemplate(CopyCommand cmd) {
397397
// restoreVM - move the new ROOT disk into corresponding VM folder
398398
String vmInternalCSName = volume.getVmName();
399399
if (dsMo.folderExists(String.format("[%s]", dsMo.getName()), vmInternalCSName)) {
400-
String oldRootDisk = VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(dsMo, vmInternalCSName, vmdkName);
401-
if (oldRootDisk != null)
402400
VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(dcMo, vmInternalCSName, dsMo, vmdkName);
403401
}
404402

‎server/src/com/cloud/storage/VolumeManagerImpl.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,6 +2133,16 @@ protected VolumeVO switchVolume(VolumeVO existingVolume,
21332133
} catch (NoTransitionException e) {
21342134
s_logger.debug("Unable to destroy existing volume: " + e.toString());
21352135
}
2136+
// In case of VMware VM will continue to use the old root disk until expunged, so force expunge old root disk
2137+
if (vm.getHypervisorType() == HypervisorType.VMware) {
2138+
s_logger.info("Expunging volume " + existingVolume.getId() + " from primary data store");
2139+
AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volFactory.getVolume(existingVolume.getId()));
2140+
try {
2141+
future.get();
2142+
} catch (Exception e) {
2143+
s_logger.debug("Failed to expunge volume:" + existingVolume.getId(), e);
2144+
}
2145+
}
21362146
txn.commit();
21372147
return newVolume;
21382148

0 commit comments

Comments
 (0)