File tree Expand file tree Collapse file tree
server/src/main/java/com/cloud/storage/snapshot Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1890,9 +1890,24 @@ public boolean start() {
18901890 logger .debug ("Failed to delete snapshot in destroying state: {}" , snapshotVO );
18911891 }
18921892 }
1893+ cleanupOrphanSnapshotPolicies ();
1894+
18931895 return true ;
18941896 }
18951897
1898+ private void cleanupOrphanSnapshotPolicies () {
1899+ List <SnapshotPolicyVO > policies = _snapshotPolicyDao .listActivePolicies ();
1900+ if (CollectionUtils .isEmpty (policies )) {
1901+ return ;
1902+ }
1903+ for (SnapshotPolicyVO policy : policies ) {
1904+ if (_volsDao .findByIdIncludingRemoved (policy .getVolumeId ()) == null ) {
1905+ logger .info ("Removing orphan snapshot policy {} for non-existent volume {}" , policy .getId (), policy .getVolumeId ());
1906+ deletePolicy (policy .getId ());
1907+ }
1908+ }
1909+ }
1910+
18961911 @ Override
18971912 public boolean stop () {
18981913 backupSnapshotExecutor .shutdown ();
You can’t perform that action at this time.
0 commit comments