This is an automated email from the ASF dual-hosted git repository.
nvazquez pushed a commit to branch 4.15
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.15 by this push:
new 41f6f0e server: allow destroy/recover volumes which are attached to
removed vms (#5364)
41f6f0e is described below
commit 41f6f0e568f7a2352a7adbccdce33b214c40a370
Author: Wei Zhou <[email protected]>
AuthorDate: Sat Aug 28 14:10:31 2021 +0200
server: allow destroy/recover volumes which are attached to removed vms
(#5364)
* server: allow destroy volumes which attach to a expunged vm
* server: recover volume which is attached to a removed vm
---
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
index 9791267..abb8265 100644
--- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1364,7 +1364,7 @@ public class VolumeApiServiceImpl extends ManagerBase
implements VolumeApiServic
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) {
@@ -1520,6 +1520,7 @@ public class VolumeApiServiceImpl extends ManagerBase
implements VolumeApiServic
}
try {
+ _volsDao.detachVolume(volume.getId());
stateTransitTo(volume, Volume.Event.RecoverRequested);
} catch (NoTransitionException e) {
s_logger.debug("Failed to recover volume" + volume.getId(), e);