Skip to content

Commit 32c0cdb

Browse files
Add volumes in 'Expunging' state to storage cleanup thread and during delete storage pool (#12602)
1 parent 8b38cea commit 32c0cdb

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

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
@@ -382,7 +382,7 @@ public ImageFormat getImageFormat(Long volumeId) {
382382

383383
public VolumeDaoImpl() {
384384
AllFieldsSearch = createSearchBuilder();
385-
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
385+
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.IN);
386386
AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), Op.EQ);
387387
AllFieldsSearch.and("dcId", AllFieldsSearch.entity().getDataCenterId(), Op.EQ);
388388
AllFieldsSearch.and("pod", AllFieldsSearch.entity().getPodId(), Op.EQ);
@@ -579,17 +579,16 @@ public long secondaryStorageUsedForAccount(long accountId) {
579579

580580
@Override
581581
public List<VolumeVO> listVolumesToBeDestroyed() {
582-
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
583-
sc.setParameters("state", Volume.State.Destroy);
584-
585-
return listBy(sc);
582+
return listVolumesToBeDestroyed(null);
586583
}
587584

588585
@Override
589586
public List<VolumeVO> listVolumesToBeDestroyed(Date date) {
590587
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
591-
sc.setParameters("state", Volume.State.Destroy);
592-
sc.setParameters("updateTime", date);
588+
sc.setParameters("state", Volume.State.Destroy, Volume.State.Expunging);
589+
if (date != null) {
590+
sc.setParameters("updateTime", date);
591+
}
593592

594593
return listBy(sc);
595594
}

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
@@ -434,6 +434,9 @@ public AsyncCallFuture<VolumeApiResult> expungeVolumeAsync(VolumeInfo volume) {
434434
// no need to change state in volumes table
435435
volume.processEventOnly(Event.DestroyRequested);
436436
} else if (volume.getDataStore().getRole() == DataStoreRole.Primary) {
437+
if (vol.getState() == Volume.State.Expunging) {
438+
logger.info("Volume {} is already in Expunging, retrying", volume);
439+
}
437440
volume.processEvent(Event.ExpungeRequested);
438441
}
439442

0 commit comments

Comments
 (0)