Damans227 commented on code in PR #12474:
URL: https://github.com/apache/cloudstack/pull/12474#discussion_r2733803396


##########
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:
   Good catch @Pearl1594. I will add a check to see if the volume is in 
Expunged state and not just null.



-- 
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]

Reply via email to