Skip to content

Commit

Permalink
Fix NPE if global setting implicit.host.tags is set to null (#8066)
Browse files Browse the repository at this point in the history
  • Loading branch information
harikrishna-patnala authored Oct 11, 2023
1 parent 8350ce5 commit fb3a2ec
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions server/src/main/java/com/cloud/deploy/FirstFitPlanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -214,11 +214,11 @@ private void reorderClustersBasedOnImplicitTags(List<Long> clusterList, int requ
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>() {
Expand Down

0 comments on commit fb3a2ec

Please sign in to comment.