mirror of https://github.com/apache/cloudstack.git
Merge pull request #787 from anshul1886/CLOUDSTACK-8824-8825
CLOUDSTACK-8825, CLOUDSTACK-8824 : Fixed issues if vm.allocation.algorithm is set to firstfitleastconsumedFixed following issues if vm.allocation.algorithm is set to firstfitleastconsumed 1. VM deployment failure if thre is only ZWPS in setup 2. VM migration is impossible from UI To test 1. Create setup with ZWPS only 2. set vm.allocation.algorithm to firstfitleastconsumed in global settings 3. deploy virtual machine observation: vm deployment will fail After this fix it will pass second scenario 1. Create Cloudstack Setup with two hosts (As it needs setup for migration) 2. Try migrating VM from UI Observation: There will be error response in logs with nothing available in UI After fix it will pass Regarding BVT I am not sure whether there exists tests for firstfitleastconsumed vm allocation algorithm. * pr/787: CLOUDSTACK-8825, CLOUDSTACK-8824 : Fixed following issues if vm.allocation.algorithm is set to firstfitleastconsumed 1. VM deployment failure if thre is only ZWPS in setup 2. VM migration is impossible from UI Signed-off-by: Remi Bergsma <github@remi.nl>
This commit is contained in:
commit
a981d34f49
|
|
@ -98,9 +98,9 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||
|
||||
private static final String ORDER_PODS_BY_AGGREGATE_OVERCOMMIT_CAPACITY =
|
||||
"SELECT capacity.pod_id, SUM(used_capacity+reserved_capacity)/SUM(total_capacity * cluster_details.value) FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`cluster_details` cluster_details ON (capacity.cluster_id = cluster_details.cluster_id) WHERE data_center_id=? AND capacity_type = ? AND cluster_details.name = ? GROUP BY capacity.pod_id ORDER BY SUM(used_capacity+reserved_capacity)/SUM(total_capacity * cluster_details.value) ASC";
|
||||
private static final String ORDER_HOSTS_BY_FREE_CAPACITY = "SELECT host_id, SUM(total_capacity - (used_capacity+reserved_capacity))/SUM(total_capacity) FROM `cloud`.`op_host_capacity` WHERE "
|
||||
+ " cluster_id = ? AND capacity_type = ? GROUP BY host_id ORDER BY SUM(total_capacity - (used_capacity+reserved_capacity))/SUM(total_capacity) DESC ";
|
||||
|
||||
private static final String ORDER_HOSTS_BY_FREE_CAPACITY_PART1 = "SELECT host_id, SUM(total_capacity - (used_capacity+reserved_capacity))/SUM(total_capacity) FROM `cloud`.`op_host_capacity` WHERE "
|
||||
+ "capacity_type = ? ";
|
||||
private static final String ORDER_HOSTS_BY_FREE_CAPACITY_PART2 = " GROUP BY host_id ORDER BY SUM(total_capacity - (used_capacity+reserved_capacity))/SUM(total_capacity) DESC ";
|
||||
private static final String LIST_CAPACITY_BY_RESOURCE_STATE =
|
||||
"SELECT capacity.data_center_id, sum(capacity.used_capacity), sum(capacity.reserved_quantity), sum(capacity.total_capacity), capacity_capacity_type "
|
||||
+ "FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`data_center` dc ON (dc.id = capacity.data_center_id AND dc.removed is NULL)"
|
||||
|
|
@ -864,12 +864,18 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
List<Long> result = new ArrayList<Long>();
|
||||
StringBuilder sql = new StringBuilder(ORDER_HOSTS_BY_FREE_CAPACITY);
|
||||
|
||||
StringBuilder sql = new StringBuilder(ORDER_HOSTS_BY_FREE_CAPACITY_PART1);
|
||||
if(clusterId != null) {
|
||||
sql.append("AND cluster_id = ?");
|
||||
}
|
||||
sql.append(ORDER_HOSTS_BY_FREE_CAPACITY_PART2);
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(sql.toString());
|
||||
pstmt.setLong(1, clusterId);
|
||||
pstmt.setShort(2, capacityTypeForOrdering);
|
||||
pstmt.setShort(1, capacityTypeForOrdering);
|
||||
if(clusterId != null) {
|
||||
pstmt.setLong(2, clusterId);
|
||||
}
|
||||
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
result.add(rs.getLong(1));
|
||||
|
|
|
|||
Loading…
Reference in New Issue