Updated Branches: refs/heads/4.2-forward 39f7ddbb8 -> af2951ad5
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/af2951ad Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/af2951ad Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/af2951ad Branch: refs/heads/4.2-forward Commit: af2951ad56481ae599f0f0e0c4e47eb5ffefca5b Parents: 39f7ddb Author: Min Chen <[email protected]> Authored: Tue Sep 17 15:15:05 2013 -0700 Committer: Min Chen <[email protected]> Committed: Tue Sep 17 15:15:05 2013 -0700 ---------------------------------------------------------------------- .../storage/volume/VolumeServiceImpl.java | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/af2951ad/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 c93dcee..5e63316 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 @@ -226,7 +226,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 { @@ -264,18 +264,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); }
