From 9b089f2eb7cd6e685c12030a8750e874634c1923 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Fri, 13 Apr 2012 17:16:24 -0700 Subject: [PATCH] AdvanceStart: do cleanup() call with force=true when the start command wasn't sent to the backend yet --- server/src/com/cloud/vm/VirtualMachineManagerImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index 7bab3dc5d99..c6e957f3271 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -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); + } } } }