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


##########
server/src/main/java/com/cloud/resource/RollingMaintenanceManagerImpl.java:
##########
@@ -622,9 +628,35 @@ private Pair<Boolean, String> 
performCapacityChecksBeforeHostInMaintenance(Host
         for (VMInstanceVO runningVM : vmsRunning) {
             boolean canMigrateVm = false;
             ServiceOfferingVO serviceOffering = 
serviceOfferingDao.findById(runningVM.getServiceOfferingId());
+            Integer cpu = serviceOffering.getCpu();
+            Integer speed = serviceOffering.getSpeed();
+            Integer ramSize = serviceOffering.getRamSize();
+            if (serviceOffering.isDynamic()) {
+                List<UserVmDetailVO> vmDetails = 
userVmDetailsDao.listDetails(runningVM.getId());
+                if (CollectionUtils.isNotEmpty(vmDetails)) {
+                    for (UserVmDetailVO vmDetail : vmDetails) {
+                        if (vmDetail.getName() != null &&vmDetail.getValue() 
!= null) {
+                            if (cpu == null && 
VmDetailConstants.CPU_NUMBER.equals(vmDetail.getName())) {
+                                cpu = Integer.valueOf(vmDetail.getValue());
+                            }
+                            if (speed == null && 
VmDetailConstants.CPU_SPEED.equals(vmDetail.getName())) {
+                                speed = Integer.valueOf(vmDetail.getValue());
+                            }
+                            if (ramSize == null && 
VmDetailConstants.MEMORY.equals(vmDetail.getName())) {
+                                ramSize = Integer.valueOf(vmDetail.getValue());
+                            }
+                        }
+                    }
+                }
+            }
+            if (cpu == null || speed == null || ramSize == null) {
+                s_logger.warn(String.format("Cannot fetch compute resources 
for the VM %s, skipping it from the capacity check", runningVM));
+                continue;
+            }

Review Comment:
   this is a lot of complexity and deserves its own method, I think.



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