DaanHoogland commented on a change in pull request #3969: Snapshot deletion 
issues
URL: https://github.com/apache/cloudstack/pull/3969#discussion_r406054109
 
 

 ##########
 File path: 
engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/DefaultSnapshotStrategy.java
 ##########
 @@ -287,18 +287,25 @@ private boolean deleteOnPrimaryIfNeeded(Long snapshotId) 
{
             // Here we handle snapshots which are to be deleted but are not 
marked as destroyed yet.
             // This may occur for instance when they are created only on 
primary because
             // snapshot.backup.to.secondary was set to false.
-            SnapshotObject obj = (SnapshotObject) snapshotOnPrimaryInfo;
-            try {
-                obj.processEvent(Snapshot.Event.DestroyRequested);
-                deletedOnPrimary = deleteSnapshotOnPrimary(snapshotId, 
snapshotOnPrimaryInfo);
-                if (!deletedOnPrimary) {
-                    obj.processEvent(Snapshot.Event.OperationFailed);
-                } else {
-                    obj.processEvent(Snapshot.Event.OperationSucceeded);
+            if (snapshotOnPrimaryInfo == null) {
+                s_logger.debug("Snapshot id:" + snapshotId + " not found on 
primary storage, skipping snapshot deletion on primary and marking it 
destroyed");
+                snapshotVO.setState(Snapshot.State.Destroyed);
+                snapshotDao.update(snapshotId, snapshotVO);
+                return true;
 
 Review comment:
   no extra return please; this means `deletedOnPrimary = true` and we fall 
through?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to