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.
This commit is contained in:
Abhishek Kumar 2022-09-01 12:28:39 +05:30 committed by GitHub
parent a21efe75df
commit c290cbcb71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 4 deletions

View File

@ -2042,13 +2042,25 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
for (final VolumeVO rootVolumeOfVm : vols) {
DiskOfferingVO currentRootDiskOffering = _diskOfferingDao.findById(rootVolumeOfVm.getDiskOfferingId());
Long rootDiskSize= null;
Long rootDiskSizeBytes = null;
if (customParameters.containsKey(ApiConstants.ROOT_DISK_SIZE)) {
rootDiskSize = Long.parseLong(customParameters.get(ApiConstants.ROOT_DISK_SIZE));
rootDiskSizeBytes = rootDiskSize << 30;
}
if (currentRootDiskOffering.getId() == newDiskOffering.getId() &&
(!newDiskOffering.isCustomized() || (newDiskOffering.isCustomized() && Objects.equals(rootVolumeOfVm.getSize(), rootDiskSizeBytes)))) {
if (s_logger.isDebugEnabled()) {
s_logger.debug(String.format("Volume %s is already having disk offering %s", rootVolumeOfVm, newDiskOffering.getUuid()));
}
continue;
}
HypervisorType hypervisorType = _volsDao.getHypervisorType(rootVolumeOfVm.getId());
if (HypervisorType.Simulator != hypervisorType) {
Long minIopsInNewDiskOffering = null;
Long maxIopsInNewDiskOffering = null;
boolean autoMigrate = false;
boolean shrinkOk = false;
Long rootDiskSize = null;
if (customParameters.containsKey(ApiConstants.MIN_IOPS)) {
minIopsInNewDiskOffering = Long.parseLong(customParameters.get(ApiConstants.MIN_IOPS));
}
@ -2061,9 +2073,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
if (customParameters.containsKey(ApiConstants.SHRINK_OK)) {
shrinkOk = Boolean.parseBoolean(customParameters.get(ApiConstants.SHRINK_OK));
}
if (customParameters.containsKey(ApiConstants.ROOT_DISK_SIZE)) {
rootDiskSize = Long.parseLong(customParameters.get(ApiConstants.ROOT_DISK_SIZE));
}
ChangeOfferingForVolumeCmd changeOfferingForVolumeCmd = new ChangeOfferingForVolumeCmd(rootVolumeOfVm.getId(), newDiskOffering.getId(), minIopsInNewDiskOffering, maxIopsInNewDiskOffering, autoMigrate, shrinkOk);
if (rootDiskSize != null) {
changeOfferingForVolumeCmd.setSize(rootDiskSize);