GaOrtiga commented on code in PR #9531:
URL: https://github.com/apache/cloudstack/pull/9531#discussion_r3453911646


##########
engine/schema/src/main/java/com/cloud/capacity/dao/CapacityDaoImpl.java:
##########
@@ -87,6 +87,13 @@ public class CapacityDaoImpl extends 
GenericDaoBase<CapacityVO, Long> implements
                     "LEFT JOIN dedicated_resources dr_cluster ON 
dr_cluster.cluster_id IS NOT NULL AND dr_cluster.cluster_id = host.cluster_id " 
+
                     "LEFT JOIN dedicated_resources dr_host ON dr_host.host_id 
IS NOT NULL AND dr_host.host_id = host.id ";
 
+    private static final String 
ORDER_CLUSTERS_BY_AGGREGATE_CAPACITY_INCLUDE_DEDICATED_JOIN_CLAUSE =
+            "JOIN host ON capacity.host_id = host.id " +
+                    "LEFT JOIN (SELECT affinity_group.id, agvm.instance_id 
FROM affinity_group_vm_map agvm JOIN affinity_group ON agvm.affinity_group_id = 
affinity_group.id AND affinity_group.type='ExplicitDedication') AS ag ON 
ag.instance_id = ? " +
+                    "LEFT JOIN dedicated_resources dr_pod ON dr_pod.pod_id IS 
NOT NULL AND dr_pod.pod_id = host.pod_id AND dr_pod.account_id IS NOT NULL AND 
dr_pod.account_id != ownerId " +

Review Comment:
   Dedication to domains is already being addressed in this query



##########
engine/schema/src/main/java/com/cloud/capacity/dao/CapacityDaoImpl.java:
##########
@@ -998,7 +1005,12 @@ public Pair<List<Long>, Map<Long, Double>> 
orderClustersByAggregateCapacity(long
             sql.append(ORDER_CLUSTERS_BY_AGGREGATE_OVERCOMMIT_CAPACITY_PART1);
         }
 
-        sql.append(ORDER_CLUSTERS_BY_AGGREGATE_CAPACITY_JOIN_1);
+        if (isVr && allowRoutersOnDedicatedResources) {
+            
sql.append(ORDER_CLUSTERS_BY_AGGREGATE_CAPACITY_INCLUDE_DEDICATED_JOIN_CLAUSE.replace("ownerId",
 ownerId.toString()));

Review Comment:
   @weizhouapache @DaanHoogland 
   
   Using `?` was my first option aswell, since it's how it's done elsewhere in 
the method, however, the values for `?` are injected informing the order (how 
many `?`s before it). Since this one is optional, it may or may not change the 
order of the remaining `?` that come after it, thus, I'd have to add at least 3 
more ifs to account for this possible change of order, which IMO ends up being 
even less elegant.



##########
api/src/main/java/com/cloud/deploy/DeploymentClusterPlanner.java:
##########
@@ -68,6 +68,14 @@ public interface DeploymentClusterPlanner extends 
DeploymentPlanner {
             ConfigKey.Kind.Select,
             "random,firstfit,userdispersing,firstfitleastconsumed");
 
+    ConfigKey<Boolean> allowRoutersOnDedicatedResources = new ConfigKey<>(

Review Comment:
   Ok, I'll remove the config



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