Skip to content

Commit bb812aa

Browse files
sureshanapartivishesh92
authored andcommitted
Do not consider transitional states (Starting, Stopping) to check power state sync
1 parent e4ada9f commit bb812aa

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ private void advanceStop(final VMInstanceVO vm, final boolean cleanUpEvenIfUnabl
22142214

22152215
if (ResourceCountRunningVMsonly.value()) {
22162216
ServiceOfferingVO offering = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId());
2217-
resourceCountDecrement(vm.getAccountId(),new Long(offering.getCpu()), new Long(offering.getRamSize()));
2217+
resourceCountDecrement(vm.getAccountId(), offering.getCpu().longValue(), offering.getRamSize().longValue());
22182218
}
22192219
}
22202220
} else {

engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -932,23 +932,12 @@ public Boolean doInTransaction(TransactionStatus status) {
932932
}
933933

934934
private boolean isPowerStateInSyncWithInstanceState(final VirtualMachine.PowerState powerState, final long powerHostId, final VMInstanceVO instance) {
935-
switch (instance.getState()) {
936-
case Starting:
937-
case Running:
938-
if (powerState == VirtualMachine.PowerState.PowerOff) {
939-
s_logger.debug(String.format("VM id: %d on host id: %d and power host id: %d is in %s state, but power state is %s",
940-
instance.getId(), instance.getHostId(), powerHostId, instance.getState(), powerState));
941-
return false;
942-
}
943-
break;
944-
case Stopping:
945-
case Stopped:
946-
if (powerState == VirtualMachine.PowerState.PowerOn) {
947-
s_logger.debug(String.format("VM id: %d on host id: %d and power host id: %d is in %s state, but power state is %s",
948-
instance.getId(), instance.getHostId(), powerHostId, instance.getState(), powerState));
949-
return false;
950-
}
951-
break;
935+
State instanceState = instance.getState();
936+
if ((powerState == VirtualMachine.PowerState.PowerOff && instanceState == State.Running)
937+
|| (powerState == VirtualMachine.PowerState.PowerOn && instanceState == State.Stopped)) {
938+
s_logger.debug(String.format("VM id: %d on host id: %d and power host id: %d is in %s state, but power state is %s",
939+
instance.getId(), instance.getHostId(), powerHostId, instanceState, powerState));
940+
return false;
952941
}
953942
return true;
954943
}

0 commit comments

Comments
 (0)