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'
This commit is contained in:
Gabriel Beims Bräscher 2021-12-22 01:40:40 -03:00 committed by GitHub
parent 29c7518613
commit 995ce06cb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -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);
}
}