Skip to content

Commit af2951a

Browse files
committed
CLOUDSTACK-4534:[object_store_refactor] Deleting uploaded volume is not
deleting the volume from backend.
1 parent 39f7ddb commit af2951a

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

‎engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private boolean canVolumeBeRemoved(long volumeId) {
226226
return false;
227227
}
228228
VolumeDataStoreVO volumeStore = _volumeStoreDao.findByVolume(volumeId);
229-
if (vol.getState() == State.Expunged && volumeStore == null) {
229+
if ((vol.getState() == State.Expunged || (vol.getPodId() == null && vol.getState() == State.Destroy)) && volumeStore == null) {
230230
// volume is expunged from primary, as well as on secondary
231231
return true;
232232
} else {
@@ -264,18 +264,23 @@ public AsyncCallFuture<VolumeApiResult> expungeVolumeAsync(VolumeInfo volume) {
264264

265265
String volumePath = vol.getPath();
266266
Long poolId = vol.getPoolId();
267-
if (poolId == null || volumePath == null || volumePath.trim().isEmpty()) {
268-
if (s_logger.isDebugEnabled()) {
269-
s_logger.debug("Marking volume that was never created as destroyed: " + vol);
267+
if (poolId == null || volumePath == null || volumePath.trim().isEmpty() ) {
268+
// not created on primary store
269+
if (volumeStore == null) {
270+
// also not created on secondary store
271+
if (s_logger.isDebugEnabled()) {
272+
s_logger.debug("Marking volume that was never created as destroyed: " + vol);
273+
}
274+
volDao.remove(vol.getId());
275+
future.complete(result);
276+
return future;
270277
}
271-
volDao.remove(vol.getId());
272-
future.complete(result);
273-
return future;
274278
}
275279
VolumeObject vo = (VolumeObject) volume;
276280

277281
if (volume.getDataStore().getRole() == DataStoreRole.Image) {
278-
volume.processEvent(Event.DestroyRequested);
282+
// no need to change state in volumes table
283+
volume.processEventOnly(Event.DestroyRequested);
279284
} else if (volume.getDataStore().getRole() == DataStoreRole.Primary) {
280285
volume.processEvent(Event.ExpungeRequested);
281286
}

0 commit comments

Comments
 (0)