Updated Branches: refs/heads/master f10601ef8 -> 6fccd74ae
CLOUDSTACK-4534:[object_store_refactor] Deleting uploaded volume is not deleting the volume from backend. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6fccd74a Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6fccd74a Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6fccd74a Branch: refs/heads/master Commit: 6fccd74ae8da5b865ad1a4a166802f105c6a5b2e Parents: f10601e Author: Min Chen <[email protected]> Authored: Tue Sep 17 15:15:05 2013 -0700 Committer: Min Chen <[email protected]> Committed: Tue Sep 17 15:20:20 2013 -0700 ---------------------------------------------------------------------- .../storage/volume/VolumeServiceImpl.java | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6fccd74a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java ---------------------------------------------------------------------- diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java index 7b4047a..e7ff021 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java @@ -227,7 +227,7 @@ public class VolumeServiceImpl implements VolumeService { return false; } VolumeDataStoreVO volumeStore = _volumeStoreDao.findByVolume(volumeId); - if (vol.getState() == State.Expunged && volumeStore == null) { + if ((vol.getState() == State.Expunged || (vol.getPodId() == null && vol.getState() == State.Destroy)) && volumeStore == null) { // volume is expunged from primary, as well as on secondary return true; } else { @@ -265,18 +265,23 @@ public class VolumeServiceImpl implements VolumeService { String volumePath = vol.getPath(); Long poolId = vol.getPoolId(); - if (poolId == null || volumePath == null || volumePath.trim().isEmpty()) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Marking volume that was never created as destroyed: " + vol); + if (poolId == null || volumePath == null || volumePath.trim().isEmpty() ) { + // not created on primary store + if (volumeStore == null) { + // also not created on secondary store + if (s_logger.isDebugEnabled()) { + s_logger.debug("Marking volume that was never created as destroyed: " + vol); + } + volDao.remove(vol.getId()); + future.complete(result); + return future; } - volDao.remove(vol.getId()); - future.complete(result); - return future; } VolumeObject vo = (VolumeObject) volume; if (volume.getDataStore().getRole() == DataStoreRole.Image) { - volume.processEvent(Event.DestroyRequested); + // no need to change state in volumes table + volume.processEventOnly(Event.DestroyRequested); } else if (volume.getDataStore().getRole() == DataStoreRole.Primary) { volume.processEvent(Event.ExpungeRequested); }
