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


##########
server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java:
##########
@@ -992,20 +972,15 @@ public boolean 
postStateTransitionEvent(StateMachine2.Transition<State, Event> t
           releaseVmCapacity(vm, false, false, oldHost);
         }
       } else if (oldState == State.Stopped) {
-        if (event == Event.DestroyRequested || event == 
Event.ExpungeOperation) {
+        if (event == Event.DestroyRequested || event == Event.ExpungeOperation 
|| event == Event.StartRequested) {
           releaseVmCapacity(vm, true, false, lastHost);

Review Comment:
   Calling `releaseVmCapacity(vm, true, false, lastHost)` here assumes the 
aggregate `reservedCapacity` on `lastHost` still belongs to this VM and matches 
its current offering, but neither is guaranteed. `updateCapacityForHost` 
expires stopped reservations, and stopped VMs can change service offerings 
without adjusting the old reservation; on a later start/retry this can subtract 
another VM's reservation or leave part of this VM's reservation behind, 
corrupting host/cluster capacity. Track the reservation ownership/amount per VM 
or reconcile the old host instead of subtracting the aggregate, with 
regressions for expired reservations and stopped-offering changes.



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