From 995ce06cb740052ed36bbb86bdbf2664577b42a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Beims=20Br=C3=A4scher?= Date: Wed, 22 Dec 2021 01:40:40 -0300 Subject: [PATCH] Enhance log message in FirstFitPlanner (#5762) * Enhance log message in FirstFitPlanner When cluster reached capacity threshold the message is: "capacity threshold defined at each cluster/ at global value for capacity Type : 0" Admins hardly remember the Capacity Type and it can take a while to look at which is the resource for the respective ID. This enhancement addes log message pointing to the capacity name (e.g. Memory / CPU) as well as global settings parameter name and value to be looked at. * Change formatation in String 'warnMessageForClusterReachedCapacityThreshold' --- .../main/java/com/cloud/deploy/FirstFitPlanner.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java b/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java index f5263e21045..7dc2a50382b 100644 --- a/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java +++ b/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java @@ -26,6 +26,7 @@ import java.util.Map; import javax.inject.Inject; import javax.naming.ConfigurationException; +import com.cloud.capacity.CapacityVO; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.Configurable; @@ -353,12 +354,16 @@ public class FirstFitPlanner extends AdapterBase implements DeploymentClusterPla return; } + String configurationName = ClusterCPUCapacityDisableThreshold.key(); + float configurationValue = ClusterCPUCapacityDisableThreshold.value(); if (capacity == Capacity.CAPACITY_TYPE_CPU) { clustersCrossingThreshold = capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterCPUCapacityDisableThreshold.key(), cpu_requested); } else if (capacity == Capacity.CAPACITY_TYPE_MEMORY) { clustersCrossingThreshold = capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterMemoryCapacityDisableThreshold.key(), ram_requested); + configurationName = ClusterMemoryCapacityDisableThreshold.key(); + configurationValue = ClusterMemoryCapacityDisableThreshold.value(); } if (clustersCrossingThreshold != null && clustersCrossingThreshold.size() != 0) { @@ -367,8 +372,11 @@ public class FirstFitPlanner extends AdapterBase implements DeploymentClusterPla // Remove clusters crossing disabled threshold clusterListForVmAllocation.removeAll(clustersCrossingThreshold); - s_logger.debug("Cannot allocate cluster list " + clustersCrossingThreshold.toString() + " for vm creation since their allocated percentage" + - " crosses the disable capacity threshold defined at each cluster/ at global value for capacity Type : " + capacity + ", skipping these clusters"); + String warnMessageForClusterReachedCapacityThreshold = String.format( + "Cannot allocate cluster list %s for VM creation since their allocated percentage crosses the disable capacity threshold defined at each cluster at" + + " Global Settings Configuration [name: %s, value: %s] for capacity Type : %s, skipping these clusters", clustersCrossingThreshold.toString(), + configurationName, String.valueOf(configurationValue), CapacityVO.getCapacityName(capacity)); + s_logger.warn(warnMessageForClusterReachedCapacityThreshold); } }