From eac3631abe56b97a8b14d6b75dc4c181cfcb8b2e 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 0d0c1c08121..86e6a5adc82 100644 --- a/server/src/com/cloud/storage/VolumeManagerImpl.java +++ b/server/src/com/cloud/storage/VolumeManagerImpl.java @@ -1337,6 +1337,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) {