DaanHoogland commented on code in PR #8545:
URL: https://github.com/apache/cloudstack/pull/8545#discussion_r1462808550
##########
engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java:
##########
@@ -921,6 +921,31 @@ public Boolean doInTransaction(TransactionStatus status) {
instance.setPowerStateUpdateTime(DateUtil.currentGMTTime());
needToUpdate = true;
update(instanceId, instance);
+ } else {
+ switch (instance.getState()) {
+ case Starting:
+ case Running:
+ if (powerState ==
VirtualMachine.PowerState.PowerOff) {
+ 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",
+ instanceId,
instance.getHostId(), powerHostId, instance.getState(), powerState));
+
instance.setPowerStateUpdateTime(DateUtil.currentGMTTime());
+ instance.setPowerStateUpdateCount(1);
+ needToUpdate = true;
+ update(instanceId, instance);
+ }
+ break;
+ case Stopping:
+ case Stopped:
+ if (powerState ==
VirtualMachine.PowerState.PowerOn) {
+ 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",
+ instanceId,
instance.getHostId(), powerHostId, instance.getState(), powerState));
+
instance.setPowerStateUpdateTime(DateUtil.currentGMTTime());
+ instance.setPowerStateUpdateCount(1);
+ needToUpdate = true;
+ update(instanceId, instance);
+ }
+ break;
+ }
Review Comment:
separate method?
--
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]