Source:
<code>private AutoStartVmToRestart.State processVmDown(AutoStartVmToRestart autoStartVmToRestart, int neededPriority, DateTime iterationStartTime) { Guid vmId = autoStartVmToRestart.getVmId(); VM vm = autoStartVmToRestart.getVm(); if (!isVmNeedsToBeAutoStarted(vm)) { return AutoStartVmToRestart.State.STARTING; } if (!autoStartVmToRestart.isTimeToRun(iterationStartTime)) { return AutoStartVmToRestart.State.DOWN; } if (considerPriority && autoStartVmToRestart.isBlockedOnPriority(neededPriority, iterationStartTime)) { log.debug("VM has lower priority than other VMs. The start will be delayed."); return AutoStartVmToRestart.State.DOWN; } if (isNextRunConfiguration(vmId)) { log.debug("NextRun config found for '{}' vm, the RunVm will be delayed", vm.getName()); if (autoStartVmToRestart.delayNextTimeToRun(iterationStartTime)) { return AutoStartVmToRestart.State.DOWN; } log.warn("Failed to wait for the NextRun config to be applied on vm '{}', trying to run the VM anyway", vm.getName()); } EngineLock runVmLock = createEngineLockForRunVm(vmId); if (!acquireLock(runVmLock)) { log.debug("Could not acquire lock for auto starting VM '{}'", vm.getName()); return AutoStartVmToRestart.State.DOWN; } if (!isVmNeedsToBeAutoStarted(vm)) { releaseLock(runVmLock); return AutoStartVmToRestart.State.STARTING; } if (runVmAndUpdateStatus(vm, runVmLock)) { return AutoStartVmToRestart.State.STARTING; } logFailedAttemptToRestartVm(vm); if (autoStartVmToRestart.scheduleNextTimeToRun(iterationStartTime)) { return AutoStartVmToRestart.State.DOWN; } logFailureToRestartVm(vm); <START> return AutoStartVmToRestart.State.RUNNING; <END> }</code><technical_language>is confusing return RUNNING state auto start process failed. add a new FAILED state mark explicitly</technical_language>

Target:
private AutoStartVmToRestart.State processVmDown(AutoStartVmToRestart autoStartVmToRestart, int neededPriority, DateTime iterationStartTime) { Guid vmId = autoStartVmToRestart.getVmId(); VM vm = autoStartVmToRestart.getVm(); if (!vmNeedsToBeAutoStarted(vm)) { return AutoStartVmToRestart.State.VM_STARTING; } if (!autoStartVmToRestart.isTimeToRun(iterationStartTime)) { return AutoStartVmToRestart.State.VM_DOWN; } if (considerPriority && autoStartVmToRestart.isBlockedOnPriority(neededPriority, iterationStartTime)) { log.debug("VM has lower priority than other VMs. The start will be delayed."); return AutoStartVmToRestart.State.VM_DOWN; } if (isNextRunConfiguration(vmId)) { log.debug("NextRun config found for '{}' vm, the RunVm will be delayed", vm.getName()); if (autoStartVmToRestart.delayNextTimeToRun(iterationStartTime)) { return AutoStartVmToRestart.State.VM_DOWN; } log.warn("Failed to wait for the NextRun config to be applied on vm '{}', trying to run the VM anyway", vm.getName()); } EngineLock runVmLock = createEngineLockForRunVm(vmId); if (!acquireLock(runVmLock)) { log.debug("Could not acquire lock for auto starting VM '{}'", vm.getName()); return AutoStartVmToRestart.State.VM_DOWN; } if (!vmNeedsToBeAutoStarted(vm)) { releaseLock(runVmLock); return AutoStartVmToRestart.State.VM_STARTING; } if (runVmAndUpdateStatus(vm, runVmLock)) { return AutoStartVmToRestart.State.VM_STARTING; } return scheduleNextTimeToStart(autoStartVmToRestart, iterationStartTime, vm); }