Updated Branches:
  refs/heads/4.2-forward d7da3ceae -> 7cc8ccead

CLOUDSTACK-4471. If an instance fails to start then mark the volumes allocated 
as part of VM creation as removed and set the volume state as destroyed.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7cc8ccea
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7cc8ccea
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7cc8ccea

Branch: refs/heads/4.2-forward
Commit: 7cc8ccead541f6089ed48d9a1c335daa458b74fc
Parents: d7da3ce
Author: Likitha Shetty <[email protected]>
Authored: Tue Aug 27 15:23:31 2013 +0530
Committer: Likitha Shetty <[email protected]>
Committed: Tue Aug 27 15:52:10 2013 +0530

----------------------------------------------------------------------
 server/src/com/cloud/storage/VolumeManagerImpl.java | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7cc8ccea/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java 
b/server/src/com/cloud/storage/VolumeManagerImpl.java
index 6b7788b..35fe72a 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -2676,8 +2676,14 @@ public class VolumeManagerImpl extends ManagerBase 
implements VolumeManager {
     @Override
     public void destroyVolume(VolumeVO volume) {
         try {
-            volService.destroyVolume(volume.getId());
-        } catch (ConcurrentOperationException e) {
+            // Mark volume as removed if volume has not been created on primary
+            if (volume.getState() == Volume.State.Allocated) {
+                _volsDao.remove(volume.getId());
+                stateTransitTo(volume, Volume.Event.DestroyRequested);
+            } else {
+                volService.destroyVolume(volume.getId());
+            }
+        } catch (Exception e) {
             s_logger.debug("Failed to destroy volume" + volume.getId(), e);
             throw new CloudRuntimeException("Failed to destroy volume" + 
volume.getId(), e);
         }

Reply via email to