Pearl1594 commented on code in PR #13363:
URL: https://github.com/apache/cloudstack/pull/13363#discussion_r3989625683
##########
server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java:
##########
@@ -1000,12 +980,8 @@ public boolean
postStateTransitionEvent(StateMachine2.Transition<State, Event> t
}
if ((newState == State.Starting || newState == State.Migrating || event
== Event.AgentReportMigrated) && vm.getHostId() != null) {
- boolean fromLastHost = false;
- if (vm.getHostId().equals(vm.getLastHostId())) {
- logger.debug("VM starting again on the last host it was stopped on");
- fromLastHost = true;
- }
- allocateVmCapacity(vm, fromLastHost);
+ releaseVmCapacity(vm, true, false, lastHost);
+ allocateVmCapacity(vm);
Review Comment:
I believe this comment is valid and needs attention. reservedCapacity on a
host is only ever populated when a VM is stopped there. A running VM's
footprint is never moved into that bucket. So the release should be gated on
oldState == State.Stopped rather than on newState: that still covers Stopped ->
Starting (restart) and Stopped -> Migrating (storage migration
of a stopped VM), both of which genuinely have reserved capacity to
release on lastHost, while skipping it for live migration (Running ->
Migrating) and AgentReportMigrated, where the source host's footprint is in
used, not reserved;releasing there was decrementing unrelated reserved capacity
that happened to exist on that host, since it was never this VM's to begin with.
```
if ((newState == State.Starting || newState == State.Migrating || event ==
Event.AgentReportMigrated) && vm.getHostId() != null) {
if (oldState == State.Stopped) {
releaseVmCapacity(vm, true, false, lastHost);
}
allocateVmCapacity(vm);
}
```
--
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]