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/08 16:44:38 UTC

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

PaulAngus 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_r115295028
 
 

 ##########
 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:
   Shouldn't this be (diffInHours >= expiration_interval_hours) ?
   if expiration is 4hrs then if diff is 4 hours or greater it should be triggered...
 
----------------------------------------------------------------
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