Pearl1594 commented on code in PR #12474:
URL: https://github.com/apache/cloudstack/pull/12474#discussion_r2733764995
##########
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java:
##########
@@ -1889,9 +1890,24 @@ public boolean start() {
logger.debug("Failed to delete snapshot in destroying state:
{}", snapshotVO);
}
}
+ cleanupOrphanSnapshotPolicies();
+
return true;
}
+ private void cleanupOrphanSnapshotPolicies() {
+ List<SnapshotPolicyVO> policies =
_snapshotPolicyDao.listActivePolicies();
+ if (CollectionUtils.isEmpty(policies)) {
+ return;
+ }
+ for (SnapshotPolicyVO policy : policies) {
+ if (_volsDao.findByIdIncludingRemoved(policy.getVolumeId()) ==
null) {
Review Comment:
Correct me if I'm wrong, but this check would mean that the volume entry
doesn't exist in the DB at all, while that could be a possibility, should we
add a check if the policy belongs to an expunged volume as well, i.e.,
```suggestion
VolumeVO volume =
_volsDao.findByIdIncludingRemoved(policy.getVolumeId());
if (volume == null || volume.getState() ==
Volume.State.Expunged) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]