sudo87 commented on code in PR #10560:
URL: https://github.com/apache/cloudstack/pull/10560#discussion_r2057263106


##########
server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java:
##########
@@ -717,4 +761,43 @@ public List<UserVmJoinVO> 
listByAccountServiceOfferingTemplateAndNotInState(long
         sc.setParameters("displayVm", 1);
         return customSearch(sc, null);
     }
+
+    /**
+     * This method fetches instances where
+     * 1. lease has expired
+     * 2. leaseExpiryActions are valid, either STOP or DESTROY
+     * 3. instance State is eligible for expiry action
+     * @return list of instances, expiry action can be executed on
+     */
+    @Override
+    public List<UserVmJoinVO> listEligibleInstancesWithExpiredLease() {
+        SearchCriteria<UserVmJoinVO> sc = leaseExpiredInstanceSearch.create();
+        sc.setParameters("leaseExpired", new Date());
+        sc.setParameters("leaseExpiryActions", "STOP", "DESTROY");
+        sc.setParameters("instanceStateNotIn", State.Destroyed, 
State.Expunging, State.Error, State.Unknown, State.Migrating);

Review Comment:
   Instance will be cleaned up in next cycle after migration is completed. 
Running destroy/stop may fail during migration.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to