This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.15
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.15 by this push:
new e266419 server: Fix NPE while cloudstack agent failed to connect to
mgt server (#4779)
e266419 is described below
commit e2664197ecbc63f7a24a82faf1ccb2e776a961cf
Author: Rakesh <[email protected]>
AuthorDate: Wed Mar 17 13:12:02 2021 +0100
server: Fix NPE while cloudstack agent failed to connect to mgt server
(#4779)
* Fix NPE while cloudstack agent failed to connect to mgt server
If `ramOvercommitRatio` field is missing in user_vm_details table
is missing then agent throws NPE after restarting
It is because in user_vm_details, there are 'cpuOvercommitRatio' for all
vms, but for vms the field 'ramOvercommitRatio' is missing in the table.
* code feedback
---
server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java
b/server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java
index fba24e0..4761349 100644
--- a/server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java
+++ b/server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java
@@ -665,11 +665,9 @@ public class CapacityManagerImpl extends ManagerBase
implements CapacityManager,
Map<String, String> vmDetails =
_userVmDetailsDao.listDetailsKeyPairs(vm.getId());
String vmDetailCpu = vmDetails.get("cpuOvercommitRatio");
String vmDetailRam = vmDetails.get("memoryOvercommitRatio");
- if (vmDetailCpu != null) {
- //if vmDetail_cpu is not null it means it is running in a
overcommited cluster.
- cpuOvercommitRatio = Float.parseFloat(vmDetailCpu);
- ramOvercommitRatio = Float.parseFloat(vmDetailRam);
- }
+ // if vmDetailCpu or vmDetailRam is not null it means it is
running in a overcommitted cluster.
+ cpuOvercommitRatio = (vmDetailCpu != null) ?
Float.parseFloat(vmDetailCpu) : clusterCpuOvercommitRatio;
+ ramOvercommitRatio = (vmDetailRam != null) ?
Float.parseFloat(vmDetailRam) : clusterRamOvercommitRatio;
ServiceOffering so = offeringsMap.get(vm.getServiceOfferingId());
if (so == null) {
so =
_offeringsDao.findByIdIncludingRemoved(vm.getServiceOfferingId());