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


##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java:
##########
@@ -1227,14 +1233,15 @@ public Pair<NicProfile, Integer> allocateNic(final 
NicProfile requested, final N
         NicVO vo = checkForRaceAndAllocateNic(requested, network, 
isDefaultNic, deviceId, vm);
 
         final Integer networkRate = 
_networkModel.getNetworkRate(network.getId(), vm.getId());
+        vo.setNetworkRate(networkRate);

Review Comment:
   The import path persists the NIC inside the transaction before this later 
rate calculation, and unlike `allocateNic`/`prepareNic` it never calls 
`vo.setNetworkRate(...)` or updates the row afterward. Imported NICs therefore 
keep `network_rate = NULL`, so the newly exposed API reports `-1` even when the 
returned profile is throttled. Set and persist the effective rate before 
returning from `importNic`.



##########
server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java:
##########
@@ -2816,6 +2845,9 @@ public boolean restartVpc(Long vpcId, boolean cleanUp, 
boolean makeRedundant, bo
                 // clean up.
                 forceCleanup = true;
             }
+            // Refresh the persisted public network rate snapshot so a restart 
picks up
+            // any zone/offering rate change made since the VPC was created or 
last restarted.
+            saveVpcNetworkRateInDetails(vpc);

Review Comment:
   This snapshot is updated before either restart path succeeds. If 
`rollingRestartVpc()` or `startVpc()` fails, the VPC response will already 
report the new rate even though the running router still has the old throttle, 
and a later restart is needed to correct the snapshot. Persist the new detail 
only after a successful restart (or restore the old value on failure).



##########
api/src/main/java/org/apache/cloudstack/api/response/VpcOfferingResponse.java:
##########
@@ -106,6 +106,10 @@ public class VpcOfferingResponse extends BaseResponse {
     @Param(description = "True if the VPC offering is IP conserve mode 
enabled, allowing public IP services to be used across multiple VPC tiers.", 
since = "4.23.0")
     private Boolean conserveMode;
 
+    @SerializedName(ApiConstants.PUBLIC_NETWORK_RATE)
+    @Param(description = "Data transfer rate in megabits per second allowed 
for a VPC's public gateway (internet-facing network), created with this 
offering; null if not set (falls back to the zone/global default)", since = 
"4.24.0")

Review Comment:
   The response implementation normalizes an unset offering value to `-1` (the 
documented API convention for unlimited), but this description still says the 
response is `null` when unset. Update the contract text to describe `-1` for 
both unset and unlimited values; otherwise API consumers will implement the 
wrong null handling.



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