DaanHoogland commented on code in PR #8169:
URL: https://github.com/apache/cloudstack/pull/8169#discussion_r1378644546
##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -8208,18 +8208,22 @@ private void postProcessingUnmanageVM(UserVmVO vm) {
Long cpu = offering.getCpu() != null ? new Long(offering.getCpu()) :
0L;
Long ram = offering.getRamSize() != null ? new
Long(offering.getRamSize()) : 0L;
// First generate a VM stop event if the VM was not stopped already
+ boolean resourceCountNotDecremented = true;
if (vm.getState() != State.Stopped) {
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VM_STOP,
vm.getAccountId(), vm.getDataCenterId(),
vm.getId(), vm.getHostName(), vm.getServiceOfferingId(),
vm.getTemplateId(),
vm.getHypervisorType().toString(),
VirtualMachine.class.getName(), vm.getUuid(), vm.isDisplayVm());
resourceCountDecrement(vm.getAccountId(), vm.isDisplayVm(), cpu,
ram);
+ resourceCountNotDecremented = false;
Review Comment:
why not postpone decrementing the count altogether and only do it at the
destroy call below? It seems that one is being done in any case. Only the
removal of the call to `resourceCountDecrement(vm.getAccountId(),
vm.isDisplayVm(), cpu, ram);` above is needed.
--
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]