Skip to content

Commit fdef4d6

Browse files
sureshanapartiLocharla, Sandeep
authored andcommitted
Add volumes in 'Expunging' state to storage cleanup thread and during delete storage pool (apache#12602)
1 parent d6806aa commit fdef4d6

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

engine/schema/src/main/java/com/cloud/storage/dao/VolumeDaoImpl.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ public ImageFormat getImageFormat(Long volumeId) {
383383

384384
public VolumeDaoImpl() {
385385
AllFieldsSearch = createSearchBuilder();
386-
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
386+
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.IN);
387387
AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), Op.EQ);
388388
AllFieldsSearch.and("dcId", AllFieldsSearch.entity().getDataCenterId(), Op.EQ);
389389
AllFieldsSearch.and("pod", AllFieldsSearch.entity().getPodId(), Op.EQ);
@@ -581,17 +581,16 @@ public long secondaryStorageUsedForAccount(long accountId) {
581581

582582
@Override
583583
public List<VolumeVO> listVolumesToBeDestroyed() {
584-
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
585-
sc.setParameters("state", Volume.State.Destroy);
586-
587-
return listBy(sc);
584+
return listVolumesToBeDestroyed(null);
588585
}
589586

590587
@Override
591588
public List<VolumeVO> listVolumesToBeDestroyed(Date date) {
592589
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
593-
sc.setParameters("state", Volume.State.Destroy);
594-
sc.setParameters("updateTime", date);
590+
sc.setParameters("state", Volume.State.Destroy, Volume.State.Expunging);
591+
if (date != null) {
592+
sc.setParameters("updateTime", date);
593+
}
595594

596595
return listBy(sc);
597596
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,9 @@ public AsyncCallFuture<VolumeApiResult> expungeVolumeAsync(VolumeInfo volume) {
436436
// no need to change state in volumes table
437437
volume.processEventOnly(Event.DestroyRequested);
438438
} else if (volume.getDataStore().getRole() == DataStoreRole.Primary) {
439+
if (vol.getState() == Volume.State.Expunging) {
440+
logger.info("Volume {} is already in Expunging, retrying", volume);
441+
}
439442
volume.processEvent(Event.ExpungeRequested);
440443
}
441444

0 commit comments

Comments
 (0)