You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2020/01/15 20:03:12 UTC

[GitHub] [cloudstack] wido commented on a change in pull request #3681: Validate disk offering IOPS normal and maximum read/write values

wido commented on a change in pull request #3681: Validate disk offering IOPS normal and maximum read/write values
URL: https://github.com/apache/cloudstack/pull/3681#discussion_r367079155
 
 

 ##########
 File path: server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
 ##########
 @@ -2975,6 +2983,49 @@ public DiskOffering createDiskOffering(final CreateDiskOfferingCmd cmd) {
                 hypervisorSnapshotReserve);
     }
 
+    /**
+     * Validates IOPS read and write rate offerings. It throws InvalidParameterValueException in case of one of the following cases is not respected: </br>
+     * <ul>
+     *  <li>IOPS write rate cannot be greater than IOPS write maximum rate</li>
+     *  <li>IOPS read rate cannot be greater than IOPS read maximum rate</li>
+     *  <li>IOPS read rate max length (seconds) must be greater than zero</li>
+     *  <li>IOPS write rate max length (seconds) must be greater than zero</li>
+     *  <li>If iops.maximum.rate.length is not 0 (zero), blank or null, IOPS write/read maximum rate length (seconds) cannot be bigger than thevalue from iops.maximum.rate.length</li>
+     * </ul>
+     */
+    protected void valildateIopsRateOfferings(final Long iopsReadRate, final Long iopsReadRateMax, final Long iopsReadRateMaxLength, final Long iopsWriteRate,
+            final Long iopsWriteRateMax, final Long iopsWriteRateMaxLength) {
+        if (iopsWriteRateMax != null && iopsWriteRate != null && iopsWriteRateMax < iopsWriteRate) {
+            throw new InvalidParameterValueException(
+                    String.format("IOPS write rate (rate: %d) cannot be greater than IOPS write maximum rate (maximum rate: %d)", iopsWriteRate, iopsWriteRateMax));
+        }
+
+        if (iopsReadRateMax != null && iopsReadRate != null && iopsReadRateMax < iopsReadRate) {
+            throw new InvalidParameterValueException(
+                    String.format("IOPS read rate (rate: %d) cannot be greater than IOPS read maximum rate (maximum rate: %d)", iopsReadRate, iopsReadRateMax));
+        }
+
+        if (iopsReadRateMaxLength != null && iopsReadRateMaxLength <= 0) {
+            throw new InvalidParameterValueException(String.format("IOPS read rate max length (max length: %d seconds) must be greater than zero", iopsReadRateMaxLength));
+        }
+
+        if (iopsWriteRateMaxLength != null && iopsWriteRateMaxLength <= 0) {
+            throw new InvalidParameterValueException(String.format("IOPS write rate max length (max length: %d seconds) must be greater than zero", iopsWriteRateMaxLength));
+        }
+
+        if (iopsMaximumRateLength.value() != null && !iopsMaximumRateLength.value().equals(0L)) {
+            if (iopsReadRateMaxLength != null && iopsReadRateMaxLength > iopsMaximumRateLength.value()) {
+                throw new InvalidParameterValueException(String.format("IOPS read max length (%d seconds) cannot be greater than iops.maximum.rate.length (%ds seconds)",
+                        iopsReadRateMaxLength, iopsMaximumRateLength.value()));
+            }
+
+            if (iopsWriteRateMaxLength != null && iopsWriteRateMaxLength > iopsMaximumRateLength.value()) {
+                throw new InvalidParameterValueException(String.format("IOPS write max length (%d seconds) cannot be greater than sane.iops.maximum.rate.length (%d seconds)",
+                        iopsWriteRateMaxLength, iopsMaximumRateLength.value()));
+            }
+        }
+    }
+
 
 Review comment:
   As suggested I would also validate the bytes duration here

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services