You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by gi...@git.apache.org on 2017/05/09 09:08:39 UTC

[GitHub] borisstoyanov commented on a change in pull request #2026: CLOUDSTACK-9861: Expire VM snapshots after configured duration

borisstoyanov commented on a change in pull request #2026: CLOUDSTACK-9861: Expire VM snapshots after configured duration
URL: https://github.com/apache/cloudstack/pull/2026#discussion_r115441355
 
 

 ##########
 File path: server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java
 ##########
 @@ -220,6 +237,26 @@ private void checkStatusOfCurrentlyExecutingSnapshots() {
     }
 
     @DB
+    protected void deleteExpiredVMSnapshots() {
+        String displayTime = DateUtil.displayDateInTimezone(DateUtil.GMT_TIMEZONE, _currentTimestamp);
+        Date now = new Date();
+
+        List<VMSnapshotVO> vmSnapshots = _vmSnapshotDao.listAll();
+        for (VMSnapshotVO vmSnapshot : vmSnapshots) {
+            long accountId = vmSnapshot.getAccountId();
+            int expiration_interval_hours = VMSnapshotManager.VMSnapshotExpireInterval.valueIn(accountId);
+            if (expiration_interval_hours < 0 ) {
+                continue;
+            }
+            Date creationTime = vmSnapshot.getCreated();
+            long diffInHours = TimeUnit.MILLISECONDS.toHours(now.getTime() - creationTime.getTime());
+            if (diffInHours > expiration_interval_hours) {
 
 Review comment:
   but `long diffHours` can be either 4 or 5, in our case 4th hour will be the time between 3 and 4. When it gets to 4 it's in the 5th hour already. I'm +1 on '>='
 
----------------------------------------------------------------
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