koushik-das commented on a change in pull request #2081: CLOUDSTACK-9894
Separate creation and backup operations for a volume snapshot
URL: https://github.com/apache/cloudstack/pull/2081#discussion_r123686134
##########
File path: server/src/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -2608,6 +2609,21 @@ public UserVm destroyVm(DestroyVMCmd cmd) throws
ResourceUnavailableException, C
CallContext ctx = CallContext.current();
long vmId = cmd.getId();
boolean expunge = cmd.getExpunge();
+ // check if VM exists
+ UserVmVO vm = _vmDao.findById(vmId);
+ // check if there are active volume snapshots tasks
+ List<VolumeVO> listVolumes = _volsDao.findRootVolumeByInstance(vmId);
+ for (VolumeVO volume : listVolumes) {
+ // for the volumes got, check if any snapshot associated with this
volume is in backing up state.
+ List<SnapshotVO> activeSnapshots =
_snapshotDao.listByStatus(volume.getInstanceId(), Snapshot.State.Creating,
Snapshot.State.CreatedOnPrimary,
+ Snapshot.State.BackingUp);
+ if (activeSnapshots.size() > 0) {
+ throw new CloudRuntimeException("There is active snapshot on
ROOT volume, vm destroy is not permitted, please try again later.");
Review comment:
What is the meaning of 'active snapshot'? Try a better phrase
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services