CLOUDSTACK-10223 Snapshots are not getting deleted when domain is deleted (#2399)

This commit is contained in:
SowjanyaPatha 2018-08-12 18:47:03 +05:30 committed by Rafael Weingärtner
parent 46c56eaaf9
commit 35e008df6c
3 changed files with 10 additions and 1 deletions

View File

@ -34,6 +34,8 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
List<VolumeVO> findByAccount(long accountId);
List<VolumeVO> findIncludingRemovedByAccount(long accountId);
Pair<Long, Long> getCountAndTotalByPool(long poolId);
Pair<Long, Long> getNonDestroyedCountAndTotalByPool(long poolId);

View File

@ -96,6 +96,13 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
return listBy(sc);
}
@Override
public List<VolumeVO> findIncludingRemovedByAccount(long accountId) {
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
sc.setParameters("accountId", accountId);
return listIncludingRemovedBy(sc);
}
@Override
public List<VolumeVO> findByInstance(long id) {
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();

View File

@ -715,7 +715,7 @@ public class SnapshotManagerImpl extends MutualExclusiveIdsManagerBase implement
@Override
public boolean deleteSnapshotDirsForAccount(long accountId) {
List<VolumeVO> volumes = _volsDao.findByAccount(accountId);
List<VolumeVO> volumes = _volsDao.findIncludingRemovedByAccount(accountId);
// The above call will list only non-destroyed volumes.
// So call this method before marking the volumes as destroyed.
// i.e Call them before the VMs for those volumes are destroyed.