Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ protected VolumeVO retrieveAndValidateVolume(long volumeId, Account caller) {
if (!_snapshotMgr.canOperateOnVolume(volume)) {
throw new InvalidParameterValueException("There are snapshot operations in progress on the volume, unable to delete it");
}
if (volume.getInstanceId() != null && volume.getState() != Volume.State.Expunged) {
if (volume.getInstanceId() != null && _vmInstanceDao.findById(volume.getInstanceId()) != null && volume.getState() != Volume.State.Expunged) {
throw new InvalidParameterValueException("Please specify a volume that is not attached to any VM.");
}
if (volume.getState() == Volume.State.UploadOp) {
Expand Down Expand Up @@ -1520,6 +1520,7 @@ public Volume recoverVolume(long volumeId) {
}

try {
_volsDao.detachVolume(volume.getId());
stateTransitTo(volume, Volume.Event.RecoverRequested);
} catch (NoTransitionException e) {
s_logger.debug("Failed to recover volume" + volume.getId(), e);
Expand Down