AdvanceStart: do cleanup() call with force=true when the start command wasn't sent to the backend yet

This commit is contained in:
Alena Prokharchyk 2012-04-13 17:16:24 -07:00
parent bd47cd104c
commit 9b089f2eb7
1 changed files with 7 additions and 1 deletions

View File

@ -837,8 +837,14 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
throw new AgentUnavailableException("Unable to start instance due to " + e.getMessage(), destHostId, e);
} finally {
if (startedVm == null && canRetry) {
Step prevStep = work.getStep();
_workDao.updateStep(work, Step.Release);
cleanup(vmGuru, vmProfile, work, Event.OperationFailed, false, caller, account);
if (prevStep == Step.Started || prevStep == Step.Starting) {
cleanup(vmGuru, vmProfile, work, Event.OperationFailed, false, caller, account);
} else {
//if step is not starting/started, send cleanup command with force=true
cleanup(vmGuru, vmProfile, work, Event.OperationFailed, true, caller, account);
}
}
}
}