mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
CLOUDSTACK-8103: Vmsync marks VM as stopped even after failing to stop it in HV
During vmsync if StopCommand (issued as part of PowerOff/PowerMissing report) fails to stop VM (since VM is running on HV), don't transition VM state to "Stopped" in CS db. Also added a check to throw ConcurrentOperationException if vm state is not "Running" after start operation.
This commit is contained in:
parent
c5d3a73c67
commit
788fe5a273
@ -3688,7 +3688,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
|
||||
VirtualMachineGuru vmGuru = getVmGuru(vm);
|
||||
VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
|
||||
sendStop(vmGuru, profile, true, true);
|
||||
if (!sendStop(vmGuru, profile, true, true)) {
|
||||
// In case StopCommand fails, don't proceed further
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOffReport, null);
|
||||
|
||||
@ -3194,6 +3194,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
try {
|
||||
vmParamPair = startVirtualMachine(vmId, hostId, additonalParams, deploymentPlannerToUse);
|
||||
vm = vmParamPair.first();
|
||||
|
||||
// At this point VM should be in "Running" state
|
||||
UserVmVO tmpVm = _vmDao.findById(vm.getId());
|
||||
if (!tmpVm.getState().equals(State.Running)) {
|
||||
// Some other thread changed state of VM, possibly vmsync
|
||||
throw new ConcurrentOperationException("VM " + tmpVm + " unexpectedly went to " + tmpVm.getState() + " state");
|
||||
}
|
||||
} finally {
|
||||
updateVmStateForFailedVmCreation(vm.getId(), hostId);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user