mirror of https://github.com/apache/cloudstack.git
server: Prevent vm snapshots being indefinitely stuck in Expunging state on deletion failure (#4898)
Fixes #4201 This PR addresses the issue of a vm snapshot being indefinitely stuck is Expunging state in case deletion fails. Co-authored-by: Pearl Dsilva <pearl.dsilva@shapeblue.com>
This commit is contained in:
parent
e824fdba20
commit
a64ad9d9b7
|
|
@ -59,6 +59,7 @@ public interface VMSnapshot extends ControlledEntity, Identity, InternalIdentity
|
|||
s_fsm.addTransition(Error, Event.ExpungeRequested, Expunging);
|
||||
s_fsm.addTransition(Expunging, Event.ExpungeRequested, Expunging);
|
||||
s_fsm.addTransition(Expunging, Event.OperationSucceeded, Removed);
|
||||
s_fsm.addTransition(Expunging, Event.OperationFailed, Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -230,11 +230,10 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot
|
|||
} else {
|
||||
String errMsg = (answer == null) ? null : answer.getDetails();
|
||||
s_logger.error("Delete vm snapshot " + vmSnapshot.getName() + " of vm " + userVm.getInstanceName() + " failed due to " + errMsg);
|
||||
processAnswer(vmSnapshotVO, userVm, answer, hostId);
|
||||
throw new CloudRuntimeException("Delete vm snapshot " + vmSnapshot.getName() + " of vm " + userVm.getInstanceName() + " failed due to " + errMsg);
|
||||
}
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new CloudRuntimeException("Delete vm snapshot " + vmSnapshot.getName() + " of vm " + userVm.getInstanceName() + " failed due to " + e.getMessage());
|
||||
} catch (AgentUnavailableException e) {
|
||||
} catch (OperationTimedoutException | AgentUnavailableException e) {
|
||||
throw new CloudRuntimeException("Delete vm snapshot " + vmSnapshot.getName() + " of vm " + userVm.getInstanceName() + " failed due to " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -254,9 +253,13 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot
|
|||
finalizeRevert(vmSnapshot, answer.getVolumeTOs());
|
||||
vmSnapshotHelper.vmSnapshotStateTransitTo(vmSnapshot, VMSnapshot.Event.OperationSucceeded);
|
||||
} else if (as instanceof DeleteVMSnapshotAnswer) {
|
||||
DeleteVMSnapshotAnswer answer = (DeleteVMSnapshotAnswer)as;
|
||||
finalizeDelete(vmSnapshot, answer.getVolumeTOs());
|
||||
vmSnapshotDao.remove(vmSnapshot.getId());
|
||||
if (as.getResult()) {
|
||||
DeleteVMSnapshotAnswer answer = (DeleteVMSnapshotAnswer) as;
|
||||
finalizeDelete(vmSnapshot, answer.getVolumeTOs());
|
||||
vmSnapshotDao.remove(vmSnapshot.getId());
|
||||
} else {
|
||||
vmSnapshotHelper.vmSnapshotStateTransitTo(vmSnapshot, VMSnapshot.Event.OperationFailed);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue