JoaoJandre commented on code in PR #9270:
URL: https://github.com/apache/cloudstack/pull/9270#discussion_r1733191569


##########
engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java:
##########
@@ -522,6 +522,21 @@ public Void 
deleteVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, Comm
         return null;
     }
 
+    /**
+     * Deletes the snapshot from primary storage if the only storage 
associated with the snapshot is of the Primary role; else, just removes the 
primary record on the DB.
+     * */
+    protected void deleteKvmSnapshotOnPrimary(SnapshotDataStoreVO 
snapshotDataStoreVO) {
+        List<SnapshotDataStoreVO> snapshotDataStoreVOList = 
_snapshotStoreDao.findBySnapshotId(snapshotDataStoreVO.getSnapshotId());
+        for (SnapshotDataStoreVO snapshotStore : snapshotDataStoreVOList) {
+            if (DataStoreRole.Image.equals(snapshotStore.getRole())) {
+                _snapshotStoreDao.remove(snapshotDataStoreVO.getId());
+                return;
+            }
+        }
+
+        snapshotApiService.deleteSnapshot(snapshotDataStoreVO.getSnapshotId(), 
null);

Review Comment:
   @slavkap I believe that keeping snapshots on primary storage is meant mainly 
as a fast(er) way to rewind a volume. When the volume is removed, the snapshots 
on primary kind of lose their purpose, so they are removed. However, this could 
be debated further in another issue or the ML. In any case, changing this 
behavior is our of scope for this PR, I only added the file deletion as a bug 
fix. If need be, I can extract it into another PR.



-- 
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: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to