Skip to content

Commit 35e008d

Browse files
SowjanyaPatharafaelweingartner
authored andcommitted
CLOUDSTACK-10223 Snapshots are not getting deleted when domain is deleted (#2399)
1 parent 46c56ea commit 35e008d

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
3434

3535
List<VolumeVO> findByAccount(long accountId);
3636

37+
List<VolumeVO> findIncludingRemovedByAccount(long accountId);
38+
3739
Pair<Long, Long> getCountAndTotalByPool(long poolId);
3840

3941
Pair<Long, Long> getNonDestroyedCountAndTotalByPool(long poolId);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ public List<VolumeVO> findByAccount(long accountId) {
9696
return listBy(sc);
9797
}
9898

99+
@Override
100+
public List<VolumeVO> findIncludingRemovedByAccount(long accountId) {
101+
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
102+
sc.setParameters("accountId", accountId);
103+
return listIncludingRemovedBy(sc);
104+
}
105+
99106
@Override
100107
public List<VolumeVO> findByInstance(long id) {
101108
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();

server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ public Pair<List<? extends Snapshot>, Integer> listSnapshots(ListSnapshotsCmd cm
715715
@Override
716716
public boolean deleteSnapshotDirsForAccount(long accountId) {
717717

718-
List<VolumeVO> volumes = _volsDao.findByAccount(accountId);
718+
List<VolumeVO> volumes = _volsDao.findIncludingRemovedByAccount(accountId);
719719
// The above call will list only non-destroyed volumes.
720720
// So call this method before marking the volumes as destroyed.
721721
// i.e Call them before the VMs for those volumes are destroyed.

0 commit comments

Comments
 (0)