Skip to content

Commit 2f7bdc9

Browse files
Sachin R Doddagunisureshanaparti
authored andcommitted
Fix bulk power state query missing VM lifecycle state field
The IdsPowerStateSelectSearch partial select did not include the VM lifecycle state, causing isPowerStateInSyncWithInstanceState to always return true when state was null. This prevented retry of failed StopCommands on subsequent ping cycles.
1 parent 5013cf2 commit 2f7bdc9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ protected void init() {
358358
IdsPowerStateSelectSearch.entity().getPowerHostId(),
359359
IdsPowerStateSelectSearch.entity().getPowerState(),
360360
IdsPowerStateSelectSearch.entity().getPowerStateUpdateCount(),
361-
IdsPowerStateSelectSearch.entity().getPowerStateUpdateTime());
361+
IdsPowerStateSelectSearch.entity().getPowerStateUpdateTime(),
362+
IdsPowerStateSelectSearch.entity().getState());
362363
IdsPowerStateSelectSearch.done();
363364

364365
CountByOfferingId = createSearchBuilder(Integer.class);
@@ -1105,6 +1106,10 @@ public Map<Long, VirtualMachine.PowerState> updatePowerState(
11051106

11061107
private boolean isPowerStateInSyncWithInstanceState(final VirtualMachine.PowerState powerState, final long powerHostId, final VMInstanceVO instance) {
11071108
State instanceState = instance.getState();
1109+
if (instanceState == null) {
1110+
s_logger.warn(String.format("VM %s has null instance state during power state sync check, treating as out of sync", instance));
1111+
return false;
1112+
}
11081113
if ((powerState == VirtualMachine.PowerState.PowerOff && instanceState == State.Running)
11091114
|| (powerState == VirtualMachine.PowerState.PowerOn && instanceState == State.Stopped)) {
11101115
HostVO instanceHost = hostDao.findById(instance.getHostId());

0 commit comments

Comments
 (0)