From fd7b9c44bc96a1e797ca79f5ffeb7e4b6c5610c9 Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Tue, 6 Aug 2013 15:30:11 +0530 Subject: [PATCH] CLOUDSTACK-4038. State of the DATA volumes remains in Allocated state if they are deleted before using them. If a volume is in Allocated state i.e. not present in primary or secondary mark the volume as removed. --- server/src/com/cloud/storage/VolumeManagerImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java index a55f2326736..3310d64c5af 100644 --- a/server/src/com/cloud/storage/VolumeManagerImpl.java +++ b/server/src/com/cloud/storage/VolumeManagerImpl.java @@ -1336,6 +1336,12 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager { Volume.class.getName(), volume.getUuid()); } } + // Mark volume as removed if volume has not been created on primary or secondary + if (volume.getState() == Volume.State.Allocated) { + _volsDao.remove(volumeId); + stateTransitTo(volume, Volume.Event.DestroyRequested); + return true; + } // expunge volume from primary if volume is on primary VolumeInfo volOnPrimary = volFactory.getVolume(volume.getId(), DataStoreRole.Primary); if (volOnPrimary != null) {