cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] niteshsarda commented on a change in pull request #2373: CLOUDSTACK-10202:createSnapshotPolicy API create multiple entries in DB for same volume.
Date Thu, 01 Jan 1970 00:00:00 GMT
niteshsarda commented on a change in pull request #2373: CLOUDSTACK-10202:createSnapshotPolicy
API create multiple entries in DB for same volume.
URL: https://github.com/apache/cloudstack/pull/2373#discussion_r158793730
 
 

 ##########
 File path: server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
 ##########
 @@ -854,15 +856,18 @@ public SnapshotPolicyVO createPolicy(CreateSnapshotPolicyCmd cmd, Account
policy
                 throw new InvalidParameterValueException("Max number of snapshots shouldn't
exceed the " + message + " level snapshot limit");
             }
         }
-        SnapshotPolicyVO policy = _snapshotPolicyDao.findOneByVolumeInterval(volumeId, intvType);
-        if (policy == null) {
-            policy = new SnapshotPolicyVO(volumeId, cmd.getSchedule(), timezoneId, intvType,
cmd.getMaxSnaps(), display);
-            policy = _snapshotPolicyDao.persist(policy);
-            _snapSchedMgr.scheduleNextSnapshotJob(policy);
-        } else {
-            try {
+
+        final GlobalLock createSnapshotPolicyLock = GlobalLock.getInternLock("createSnapshotPolicy_"
+ volumeId);
+        createSnapshotPolicyLock.lock(5);
 
 Review comment:
   @marcaurele : Incorporated the changes suggested by you for handling the condition of lock
not acquired. In case if lock is not acquired, null value will be returned.
   In CreateSnapshotPolicyCmd class, inside execute method from where this method is called,
we have already handled the null condition, and in case of null value exception will be thrown.
   
   Please review the latest code.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message