koushik-das commented on a change in pull request #2081: CLOUDSTACK-9894 
Separate creation and backup operations for a volume snapshot
URL: https://github.com/apache/cloudstack/pull/2081#discussion_r123685179
 
 

 ##########
 File path: server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
 ##########
 @@ -1123,6 +1150,39 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) 
throws ResourceAllocationExc
         return snapshot;
     }
 
+    protected class BackupSnapshotTask extends ManagedContextRunnable {
+        SnapshotInfo snapshot;
+        int maxAttempts;
+        SnapshotStrategy snapshotStrategy;
+
+        public BackupSnapshotTask(SnapshotInfo snap, int maxRetries, 
SnapshotStrategy strategy) {
+            snapshot = snap;
+            maxAttempts = maxRetries;
+            snapshotStrategy = strategy;
+        }
+
+        @Override
+        protected void runInContext() {
+            try {
+                s_logger.debug("Value of attempts is " + maxAttempts);
+
+                SnapshotInfo backupedSnapshot = 
snapshotStrategy.backupSnapshot(snapshot);
+
+                if (backupedSnapshot != null) {
+                    snapshotStrategy.cleanSnapshotAfterCreation(snapshot);
+                }
+            } catch (final Exception e) {
+                if (maxAttempts >= 0) {
+                    s_logger.debug("Attempt failed, in retrying backup");
+                    backupSnapshotExecutor.schedule(new 
BackupSnapshotTask(snapshot, --maxAttempts, snapshotStrategy), retryInterval, 
TimeUnit.SECONDS);
+                } else {
+                    s_logger.debug("Done with attempts, with backing up");
 
 Review comment:
   Again add more information about the snapshot id, how many retries were 
attempted etc.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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