Skip to content

Commit c290cbc

Browse files
authored
server: fix scale vm with compute offering having same disk offering (#6688)
Fixes #6679 Fixes behaviour when the VM is scaled to a new compute offering which has the same disk offering associated as the earlier compute offering.
1 parent a21efe7 commit c290cbc

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,13 +2042,25 @@ private void changeDiskOfferingForRootVolume(Long vmId, DiskOfferingVO newDiskOf
20422042

20432043
for (final VolumeVO rootVolumeOfVm : vols) {
20442044
DiskOfferingVO currentRootDiskOffering = _diskOfferingDao.findById(rootVolumeOfVm.getDiskOfferingId());
2045+
Long rootDiskSize= null;
2046+
Long rootDiskSizeBytes = null;
2047+
if (customParameters.containsKey(ApiConstants.ROOT_DISK_SIZE)) {
2048+
rootDiskSize = Long.parseLong(customParameters.get(ApiConstants.ROOT_DISK_SIZE));
2049+
rootDiskSizeBytes = rootDiskSize << 30;
2050+
}
2051+
if (currentRootDiskOffering.getId() == newDiskOffering.getId() &&
2052+
(!newDiskOffering.isCustomized() || (newDiskOffering.isCustomized() && Objects.equals(rootVolumeOfVm.getSize(), rootDiskSizeBytes)))) {
2053+
if (s_logger.isDebugEnabled()) {
2054+
s_logger.debug(String.format("Volume %s is already having disk offering %s", rootVolumeOfVm, newDiskOffering.getUuid()));
2055+
}
2056+
continue;
2057+
}
20452058
HypervisorType hypervisorType = _volsDao.getHypervisorType(rootVolumeOfVm.getId());
20462059
if (HypervisorType.Simulator != hypervisorType) {
20472060
Long minIopsInNewDiskOffering = null;
20482061
Long maxIopsInNewDiskOffering = null;
20492062
boolean autoMigrate = false;
20502063
boolean shrinkOk = false;
2051-
Long rootDiskSize = null;
20522064
if (customParameters.containsKey(ApiConstants.MIN_IOPS)) {
20532065
minIopsInNewDiskOffering = Long.parseLong(customParameters.get(ApiConstants.MIN_IOPS));
20542066
}
@@ -2061,9 +2073,6 @@ private void changeDiskOfferingForRootVolume(Long vmId, DiskOfferingVO newDiskOf
20612073
if (customParameters.containsKey(ApiConstants.SHRINK_OK)) {
20622074
shrinkOk = Boolean.parseBoolean(customParameters.get(ApiConstants.SHRINK_OK));
20632075
}
2064-
if (customParameters.containsKey(ApiConstants.ROOT_DISK_SIZE)) {
2065-
rootDiskSize = Long.parseLong(customParameters.get(ApiConstants.ROOT_DISK_SIZE));
2066-
}
20672076
ChangeOfferingForVolumeCmd changeOfferingForVolumeCmd = new ChangeOfferingForVolumeCmd(rootVolumeOfVm.getId(), newDiskOffering.getId(), minIopsInNewDiskOffering, maxIopsInNewDiskOffering, autoMigrate, shrinkOk);
20682077
if (rootDiskSize != null) {
20692078
changeOfferingForVolumeCmd.setSize(rootDiskSize);

0 commit comments

Comments
 (0)