CLOUDSTACK-7778: Start VM checkWorkItem loop should also check VM DB state before going into idle waiting to exit faster.

This commit is contained in:
Min Chen 2014-10-23 14:08:49 -07:00
parent fed5422c10
commit 94969b0654
1 changed files with 9 additions and 0 deletions

View File

@ -631,6 +631,15 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
return true;
}
// also check DB to get latest VM state to detect vm update from concurrent process before idle waiting to get an early exit
VMInstanceVO instance = _vmDao.findById(vm.getId());
if (instance != null && instance.getState() == State.Running) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("VM is already started in DB: " + vm);
}
return true;
}
if (vo.getSecondsTaskIsInactive() > VmOpCancelInterval.value()) {
s_logger.warn("The task item for vm " + vm + " has been inactive for " + vo.getSecondsTaskIsInactive());
return false;