JoaoJandre commented on code in PR #7214:
URL: https://github.com/apache/cloudstack/pull/7214#discussion_r1500615169


##########
server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java:
##########
@@ -298,24 +301,33 @@ protected void 
avoidOtherClustersForDeploymentIfMigrationDisabled(VirtualMachine
     @Override
     public DeployDestination planDeployment(VirtualMachineProfile vmProfile, 
DeploymentPlan plan, ExcludeList avoids, DeploymentPlanner planner)
             throws InsufficientServerCapacityException, 
AffinityConflictException {
+        
logger.debug(logDeploymentWithoutException(vmProfile.getVirtualMachine(), plan, 
avoids, planner));
 
         ServiceOffering offering = vmProfile.getServiceOffering();
-        int cpu_requested = offering.getCpu() * offering.getSpeed();
-        long ram_requested = offering.getRamSize() * 1024L * 1024L;
+        int cpuRequested = offering.getCpu() * offering.getSpeed();
+        long ramRequested = offering.getRamSize() * 1024L * 1024L;
         VirtualMachine vm = vmProfile.getVirtualMachine();
         DataCenter dc = _dcDao.findById(vm.getDataCenterId());
         boolean volumesRequireEncryption = 
anyVolumeRequiresEncryption(_volsDao.findByInstance(vm.getId()));
 
         if (vm.getType() == VirtualMachine.Type.User || vm.getType() == 
VirtualMachine.Type.DomainRouter) {
+            logger.debug("Checking non dedicated resources to deploy VM 
[{}].", () -> ReflectionToStringBuilderUtils.reflectOnlySelectedFields(vm, 
"uuid", "type", "instanceName"));
             checkForNonDedicatedResources(vmProfile, dc, avoids);
         }
-        if (logger.isDebugEnabled()) {
-            logger.debug("DeploymentPlanner allocation algorithm: " + planner);
 
-            logger.debug("Trying to allocate a host and storage pools from 
dc:" + plan.getDataCenterId() + ", pod:" + plan.getPodId() + ",cluster:" +
-                    plan.getClusterId() + ", requested cpu: " + cpu_requested 
+ ", requested ram: " + toHumanReadableSize(ram_requested));
+        logger.debug(() -> {
+            String datacenter = 
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(dc, "uuid", "name");
+            String podVO = 
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(_podDao.findById(plan.getPodId()),
 "uuid", "name");
+            String clusterVO = 
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(_clusterDao.findById(plan.getClusterId()),
 "uuid", "name");
+            String vmDetails = 
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(vm, "uuid", "type", 
"instanceName");
+            return String.format("Trying to allocate a host and storage pools 
from datacenter [%s], pod [%s], cluster [%s], to deploy VM [%s] "
+                    + "with requested CPU [%s] and requested RAM [%s].", 
datacenter, podVO, clusterVO, vmDetails, cpuRequested, 
toHumanReadableSize(ramRequested));
+        });
 
-            logger.debug("Is ROOT volume READY (pool already allocated)?: " + 
(plan.getPoolId() != null ? "Yes" : "No"));
+        if (logger.isDebugEnabled()) {
+            String rootVolumeUuid = 
getRootVolumeUuid(_volsDao.findByInstance(vm.getId()));
+            String isRootVolumeReadyMsg = plan.getPoolId() != null ? "is 
ready" : "is not ready";
+            logger.debug("ROOT volume [{}] {} to deploy VM [{}].", 
rootVolumeUuid, isRootVolumeReadyMsg, vm.getUuid());
         }

Review Comment:
   The first debug log has only 1 parameter: a lambda function, that will only 
be interpreted if the debug level is active, thus we don't need a log guard.
   
   About the log guard below, after taking a second look at it, I don't think 
it's needed, I'd rather just use lambda as well. I've made a new commit 
updating this.



-- 
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: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to