This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a commit to branch 4.18
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.18 by this push:
new fb3a2ecb57e Fix NPE if global setting implicit.host.tags is set to
null (#8066)
fb3a2ecb57e is described below
commit fb3a2ecb57e5c9c0256a3251da613cf1f950ca33
Author: Harikrishna <[email protected]>
AuthorDate: Thu Oct 12 00:25:34 2023 +0530
Fix NPE if global setting implicit.host.tags is set to null (#8066)
---
server/src/main/java/com/cloud/deploy/FirstFitPlanner.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java
b/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java
index 695521e5272..4e838510010 100644
--- a/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java
+++ b/server/src/main/java/com/cloud/deploy/FirstFitPlanner.java
@@ -124,7 +124,7 @@ public class FirstFitPlanner extends AdapterBase implements
DeploymentClusterPla
protected String allocationAlgorithm = "random";
protected String globalDeploymentPlanner = "FirstFitPlanner";
- protected String[] implicitHostTags;
+ protected String[] implicitHostTags = new String[0];
@Override
public List<Long> orderClusters(VirtualMachineProfile vmProfile,
DeploymentPlan plan, ExcludeList avoid) throws
InsufficientServerCapacityException {
@@ -214,11 +214,11 @@ public class FirstFitPlanner extends AdapterBase
implements DeploymentClusterPla
Long uniqueTags;
for (Long clusterId : clusterList) {
uniqueTags = (long) 0;
- List<Long> hostList =
capacityDao.listHostsWithEnoughCapacity(requiredCpu, requiredRam, clusterId,
Host.Type.Routing.toString());
- if (!hostList.isEmpty() && implicitHostTags.length > 0) {
- uniqueTags = new
Long(hostTagsDao.getDistinctImplicitHostTags(hostList,
implicitHostTags).size());
- uniqueTags = uniqueTags + getHostsByCapability(hostList,
Host.HOST_UEFI_ENABLE);
- }
+ List<Long> hostList =
capacityDao.listHostsWithEnoughCapacity(requiredCpu, requiredRam, clusterId,
Host.Type.Routing.toString());
+ if (!hostList.isEmpty() && implicitHostTags.length > 0) {
+ uniqueTags = new
Long(hostTagsDao.getDistinctImplicitHostTags(hostList,
implicitHostTags).size());
+ uniqueTags = uniqueTags + getHostsByCapability(hostList,
Host.HOST_UEFI_ENABLE);
+ }
UniqueTagsInClusterMap.put(clusterId, uniqueTags);
}
Collections.sort(clusterList, new Comparator<Long>() {