This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.20 by this push:
new ca7138b3bdf server: Consider Instance in Starting state as well for
allocation algorithm (#11751)
ca7138b3bdf is described below
commit ca7138b3bdf73dafce147d0a730d41db621a7e9b
Author: Manoj Kumar <[email protected]>
AuthorDate: Thu Oct 2 11:43:48 2025 +0530
server: Consider Instance in Starting state as well for allocation
algorithm (#11751)
* Consider Instance in Starting state as well for allocation algorithm
* use IN instead of OR statement
---
engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git
a/engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java
b/engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java
index ef10af63bae..e6405fd34db 100755
--- a/engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java
+++ b/engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java
@@ -116,17 +116,17 @@ public class VMInstanceDaoImpl extends
GenericDaoBase<VMInstanceVO, Long> implem
protected Attribute _updateTimeAttr;
- private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART1
= "SELECT host.cluster_id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1,
0)) " +
+ private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART1
= "SELECT host.cluster_id, SUM(IF(vm.state IN ('Running', 'Starting') AND
vm.account_id = ?, 1, 0)) " +
"FROM `cloud`.`host` host LEFT JOIN `cloud`.`vm_instance` vm ON
host.id = vm.host_id WHERE ";
private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART2
= " AND host.type = 'Routing' AND host.removed is null GROUP BY host.cluster_id
" +
"ORDER BY 2 ASC ";
- private static final String ORDER_PODS_NUMBER_OF_VMS_FOR_ACCOUNT = "SELECT
pod.id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1, 0)) FROM `cloud`.`"
+
+ private static final String ORDER_PODS_NUMBER_OF_VMS_FOR_ACCOUNT = "SELECT
pod.id, SUM(IF(vm.state IN ('Running', 'Starting') AND vm.account_id = ?, 1,
0)) FROM `cloud`.`" +
"host_pod_ref` pod LEFT JOIN `cloud`.`vm_instance` vm ON pod.id =
vm.pod_id WHERE pod.data_center_id = ? AND pod.removed is null "
+ " GROUP BY pod.id ORDER BY 2 ASC ";
private static final String ORDER_HOSTS_NUMBER_OF_VMS_FOR_ACCOUNT =
- "SELECT host.id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1,
0)) FROM `cloud`.`host` host LEFT JOIN `cloud`.`vm_instance` vm ON host.id =
vm.host_id " +
+ "SELECT host.id, SUM(IF(vm.state IN ('Running', 'Starting') AND
vm.account_id = ?, 1, 0)) FROM `cloud`.`host` host LEFT JOIN
`cloud`.`vm_instance` vm ON host.id = vm.host_id " +
"WHERE host.data_center_id = ? AND host.type = 'Routing' AND
host.removed is null ";
private static final String ORDER_HOSTS_NUMBER_OF_VMS_FOR_ACCOUNT_PART2 =
" GROUP BY host.id ORDER BY 2 ASC ";