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_r125423818
 
 

 ##########
 File path: 
engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
 ##########
 @@ -386,58 +398,53 @@ public SnapshotInfo takeSnapshot(SnapshotInfo snapshot) {
                     volumeInfo.stateTransit(Volume.Event.OperationFailed);
                 }
             }
+            snapshotOnPrimary = result.getSnapshot();
+            snapshotOnPrimary.addPayload(snapshot.getPayload());
 
-            snapshot = result.getSnapshot();
-            DataStore primaryStore = snapshot.getDataStore();
-            boolean backupFlag = 
Boolean.parseBoolean(configDao.getValue(Config.BackupSnapshotAfterTakingSnapshot.toString()));
-
-            SnapshotInfo backupedSnapshot;
-            if(backupFlag) {
-                backupedSnapshot = backupSnapshot(snapshot);
-            } else {
-                // Fake it to get the transitions to fire in the proper order
-                s_logger.debug("skipping backup of snapshot due to 
configuration "+Config.BackupSnapshotAfterTakingSnapshot.toString());
-
-                SnapshotObject snapObj = (SnapshotObject)snapshot;
-                try {
-                    snapObj.processEvent(Snapshot.Event.OperationNotPerformed);
-                } catch (NoTransitionException e) {
-                    s_logger.debug("Failed to change state: " + 
snapshot.getId() + ": " + e.toString());
-                    throw new CloudRuntimeException(e.toString());
-                }
-                backupedSnapshot = snapshot;
+            /*The Management Server ID is stored in snapshot_details table 
with the snapshot id and (name, value): (MS_ID, <ms_id>), to know which 
snapshots have not been completed in case of some failure situation like
+             *  Mgmt server down etc. and by fetching the entries on restart 
the cleaning up of failed snapshots is done*/
+            
_snapshotDetailsDao.addDetail(((SnapshotObject)snapshotOnPrimary).getId(), 
AsyncJob.Constants.MS_ID, Long.toString(MacAddress.getMacAddress().toLong()), 
false);
+            return snapshotOnPrimary;
+        } finally {
+            if (snapshotVO != null) {
+                snapshotDao.releaseFromLockTable(snapshotOnPrimary.getId());
 
 Review comment:
   It is always a good practice to use the same id (snapshot.getId()) to 
release the lock that was used to acquire it. The earlier code followed that.
 
----------------------------------------------------------------
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