Copilot commented on code in PR #13325:
URL: https://github.com/apache/cloudstack/pull/13325#discussion_r4546831450


##########
ui/src/views/offering/AddVpcOffering.vue:
##########
@@ -740,6 +752,9 @@ export default {
         }
         params.networkmode = values.networkmode
         params.conservemode = values.conservemode
+        if (values.publicnetworkrate) {
+          params.publicnetworkrate = values.publicnetworkrate
+        }

Review Comment:
   A value of `0` is a supported input here and the server normalizes it to 
`-1` (unlimited), but this truthiness check omits `0` from the request. The 
offering is therefore created with `null`, which falls back to the zone setting 
instead of honoring the operator's explicit unlimited choice. Check for 
null/undefined rather than truthiness when adding this parameter.



##########
server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java:
##########
@@ -595,6 +600,16 @@ public VpcOffering createVpcOffering(CreateVPCOfferingCmd 
cmd) {
         boolean specifyAsNumber = cmd.getSpecifyAsNumber();
         String routingModeString = cmd.getRoutingMode();
         boolean conserveMode = cmd.isConserveMode();
+        Integer publicNetworkRate = cmd.getPublicNetworkRate();
+        if (publicNetworkRate != null) {
+            if (publicNetworkRate < -1) {
+                throw new InvalidParameterValueException("Failed to create VPC 
offering " + vpcOfferingName + ": specify the public network rate value as -1 
(unlimited) or a positive value");

Review Comment:
   The validation accepts `0` as an unlimited value, but this error says only 
`-1` or a positive value is valid. If a caller supplies another negative value, 
the message omits the valid `0` option and contradicts the normalization 
immediately below; include `0` (or describe the accepted range as non-negative 
plus `-1`).



-- 
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]

Reply via email to