You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2020/08/04 18:59:37 UTC

[GitHub] [cloudstack] GabrielBrascher commented on a change in pull request #4220: Fix cpuallocated value in findHostsForMIgration api

GabrielBrascher commented on a change in pull request #4220:
URL: https://github.com/apache/cloudstack/pull/4220#discussion_r465263348



##########
File path: server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java
##########
@@ -330,10 +330,10 @@ public HostForMigrationResponse newHostForMigrationResponse(HostJoinVO host, Enu
 
                 hostResponse.setHypervisorVersion(host.getHypervisorVersion());
 
-                Float cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId()));
-                String cpuAlloc = decimalFormat.format(((float)cpu / cpuWithOverprovisioning * 100f)).toString() + "%";
+                float cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId()));
+                String cpuAlloc = decimalFormat.format(((float)cpu / cpuWithOverprovisioning * 100f)) + "%";

Review comment:
       @ravening sorry for the delay. I think that I was clear about my point.
   
   - the method that you extract [L464](https://github.com/apache/cloudstack/blob/7febf17aa8c8ba6403deeb160a4af5f6dda5111c/server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java#L464):
   `decimalFormat.format(((float)resource / resourceWithOverProvision * 100.0f)) + "%"`
   
   - line [314](https://github.com/apache/cloudstack/blob/7febf17aa8c8ba6403deeb160a4af5f6dda5111c/server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java#L314) that I mentioned:
   `decimalFormat.format((float) mem / memWithOverprovisioning * 100.0f) +"%"`
   
   That is why I thought that it could also benefit from `calculateResourceAllocatedPercentage`.
   




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

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