GutoVeronezi commented on code in PR #6704:
URL: https://github.com/apache/cloudstack/pull/6704#discussion_r1034683565
##########
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java:
##########
@@ -1823,6 +1824,21 @@ private Volume
changeDiskOfferingForVolumeInternal(VolumeVO volume, Long newDisk
return volume;
}
+ /**
+ * This method is to compare long values, in miniops and maxiops a or b
can be null or 0.
+ * Use this method to treat 0 and null as same
+ *
+ * @param a
+ * @param b
+ * @return true if a and b are equal excluding 0 and null values.
+ */
+ private boolean compareEqualsIncludingNullOrZero(Long a, Long b) {
+ a = ObjectUtils.defaultIfNull(a, 0L);
+ b = ObjectUtils.defaultIfNull(b, 0L);
+
+ return a.equals(b);
+ }
Review Comment:
@shwstppr, we could move this method to `com.cloud.utils.NumbersUtils` and
add some unit tests.
##########
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java:
##########
@@ -1823,6 +1824,21 @@ private Volume
changeDiskOfferingForVolumeInternal(VolumeVO volume, Long newDisk
return volume;
}
+ /**
+ * This method is to compare long values, in miniops and maxiops a or b
can be null or 0.
+ * Use this method to treat 0 and null as same
+ *
+ * @param a
+ * @param b
+ * @return true if a and b are equal excluding 0 and null values.
+ */
+ private boolean compareEqualsIncludingNullOrZero(Long a, Long b) {
Review Comment:
@shwstppr, what do you think about renaming the method to
`compareLongsDefaultingNullToZero`?
##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -2036,7 +2036,14 @@ private void
validateDiskOfferingChecks(ServiceOfferingVO currentServiceOffering
}
}
- private void changeDiskOfferingForRootVolume(Long vmId, DiskOfferingVO
newDiskOffering, Map<String, String> customParameters) throws
ResourceAllocationException {
+ private void changeDiskOfferingForRootVolume(Long vmId, DiskOfferingVO
newDiskOffering, Map<String, String> customParameters, Long zoneId) throws
ResourceAllocationException {
+
+ if (!AllowDiskOfferingChangeDuringScaleVm.valueIn(zoneId)) {
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug(String.format("Disk Offering change for the
root volume is disabled during the compute offering change operation. Please
check the setting %s", AllowDiskOfferingChangeDuringScaleVm.key()));
Review Comment:
```suggestion
s_logger.debug(String.format("Changing the disk offering of
the root volume during the compute offering change operation is disabled.
Please check the setting [%s].", AllowDiskOfferingChangeDuringScaleVm.key()));
```
##########
server/src/main/java/com/cloud/vm/UserVmManager.java:
##########
@@ -47,9 +47,12 @@
*/
public interface UserVmManager extends UserVmService {
String EnableDynamicallyScaleVmCK = "enable.dynamic.scale.vm";
+ String AllowDiskOfferingChangeDuringScaleVmCK =
"allow.diskOffering.change.during.scale.vm";
String AllowUserExpungeRecoverVmCK ="allow.user.expunge.recover.vm";
ConfigKey<Boolean> EnableDynamicallyScaleVm = new
ConfigKey<Boolean>("Advanced", Boolean.class, EnableDynamicallyScaleVmCK,
"false",
"Enables/Disables dynamically scaling a vm", true,
ConfigKey.Scope.Zone);
+ ConfigKey<Boolean> AllowDiskOfferingChangeDuringScaleVm = new
ConfigKey<Boolean>("Advanced", Boolean.class,
AllowDiskOfferingChangeDuringScaleVmCK, "false",
+ "Determines whether to allow or disallow disk offering change for
root volume during scaling of a stopped or running vm", true,
ConfigKey.Scope.Zone);
Review Comment:
I think we could remove the `String` variable:
```suggestion
String AllowUserExpungeRecoverVmCK ="allow.user.expunge.recover.vm";
ConfigKey<Boolean> EnableDynamicallyScaleVm = new
ConfigKey<Boolean>("Advanced", Boolean.class, EnableDynamicallyScaleVmCK,
"false",
"Enables/Disables dynamically scaling a vm", true,
ConfigKey.Scope.Zone);
ConfigKey<Boolean> AllowDiskOfferingChangeDuringScaleVm = new
ConfigKey<Boolean>("Advanced", Boolean.class,
"allow.diskOffering.change.during.scale.vm", "false",
"Determines whether to allow or disallow disk offering change
for root volume during scaling of a stopped or running vm", true,
ConfigKey.Scope.Zone);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]