harikrishna-patnala commented on code in PR #11971:
URL: https://github.com/apache/cloudstack/pull/11971#discussion_r2730202893
##########
server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java:
##########
@@ -938,7 +928,7 @@ public void doInTransactionWithoutResult(TransactionStatus
status) {
capacity =
new CapacityVO(host.getId(), host.getDataCenterId(),
host.getPodId(), host.getClusterId(), usedCpuFinal, host.getCpus().longValue() *
- host.getSpeed().longValue(),
Capacity.CAPACITY_TYPE_CPU);
+ host.getSpeed(), Capacity.CAPACITY_TYPE_CPU);
Review Comment:
@DaanHoogland this may cause NPE right! if speed is null in the host table.
mysql> desc host;
+-----------------------+-----------------+------+-----+----------+----------------+
| Field | Type | Null | Key | Default | Extra
|
+-----------------------+-----------------+------+-----+----------+----------------+
| speed | int unsigned | YES | | NULL |
|
speed value can be null.
Though this may not directly cause NPE as this is in the loop of VMs and
here it will be routing host entries only.
##########
server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java:
##########
@@ -761,28 +751,28 @@ public void updateCapacityForHost(final Host host) {
}
if (so.isDynamic()) {
reservedMemory +=
-
((Integer.parseInt(vmDetails.get(UsageEventVO.DynamicParameters.memory.name()))
* 1024L * 1024L) / ramOvercommitRatio) *
- clusterRamOvercommitRatio;
+ (long)
(((Integer.parseInt(vmDetails.get(UsageEventVO.DynamicParameters.memory.name()))
* 1024L * 1024L) / ramOvercommitRatio) *
+
clusterRamOvercommitRatio);
if(vmDetails.containsKey(UsageEventVO.DynamicParameters.cpuSpeed.name())) {
reservedCpu +=
-
((Integer.parseInt(vmDetails.get(UsageEventVO.DynamicParameters.cpuNumber.name()))
*
Integer.parseInt(vmDetails.get(UsageEventVO.DynamicParameters.cpuSpeed.name())))
/ cpuOvercommitRatio) *
- clusterCpuOvercommitRatio;
+ (long)
(((Long.parseLong(vmDetails.get(UsageEventVO.DynamicParameters.cpuNumber.name()))
*
Integer.parseInt(vmDetails.get(UsageEventVO.DynamicParameters.cpuSpeed.name())))
/ cpuOvercommitRatio) *
Review Comment:
@DaanHoogland can you check this, there are other lines which uses parseInt()
reservedCpuCore +=
Integer.parseInt(vmDetails.get(UsageEventVO.DynamicParameters.cpuNumber.name()));
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]