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


##########
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:
   lease action for the instance (with migrating state at the time of lease 
expiry) will be performed in the next lease expiry check cycle (what if it is 
in migrating in the next cycle as well - should keep any restirction not to 
allow migration for leased instance, say few hours before expiry)?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to