DaanHoogland commented on code in PR #14042:
URL: https://github.com/apache/cloudstack/pull/14042#discussion_r4142318064


##########
server/src/main/java/com/cloud/deploy/FirstFitPlanner.java:
##########
@@ -388,6 +388,20 @@ protected void removeClustersCrossingThreshold(List<Long> 
clusterListForVmAlloca
                 logger.warn(warnMessageForClusterReachedCapacityThreshold);
             }
 
+            // Exclude clusters that would cross the HA failover reserve 
threshold, reserving
+            // capacity for HA-triggered restarts. Threshold is 
Cluster-scoped, resolved per-cluster by the DAO.
+            long haRequested = (capacity == Capacity.CAPACITY_TYPE_CPU) ? 
cpu_requested : ram_requested;
+            List<Long> clustersCrossingHAReserve = 
capacityDao.listClustersCrossingThreshold(
+                    capacity, plan.getDataCenterId(), 
ClusterHAFailoverReserveThreshold.key(), haRequested);
+            if (clustersCrossingHAReserve != null && 
!clustersCrossingHAReserve.isEmpty()) {
+                avoid.addClusterList(clustersCrossingHAReserve);
+                
clusterListForVmAllocation.removeAll(clustersCrossingHAReserve);
+                logger.warn(String.format(
+                        "HA admission control: excluding clusters %s from new 
deployments; their %s allocation would cross the HA failover reserve threshold 
[%s], reserving capacity for HA failover",
+                        clustersCrossingHAReserve, 
CapacityVO.getCapacityName(capacity),
+                        ClusterHAFailoverReserveThreshold.key()));
+            }

Review Comment:
   please extract a method and use the comment as javadoc



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