This is an automated email from the ASF dual-hosted git repository.

shwstppr pushed a commit to branch 4.17
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.17 by this push:
     new 814dbbaf860 cks: fix k8s cluster deployment with host tagged offering 
(#6658)
814dbbaf860 is described below

commit 814dbbaf860d204e2cb35b84a1414f6b6e111366
Author: Abhishek Kumar <[email protected]>
AuthorDate: Mon Aug 22 14:39:36 2022 +0530

    cks: fix k8s cluster deployment with host tagged offering (#6658)
    
    Fixes #6657
    
    Fixes k8s cluster node VM deployment when the underlying hypervisor host 
has multiple host tags and the service offering used for the cluster deployment 
does not contain all of those host tags.
---
 .../kubernetes/cluster/KubernetesClusterManagerImpl.java | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git 
a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java
 
b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java
index 113cee9bbbf..fa96e8b24b7 100644
--- 
a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java
+++ 
b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java
@@ -469,26 +469,26 @@ public class KubernetesClusterManagerImpl extends 
ManagerBase implements Kuberne
             suitable_host_found = false;
             for (Map.Entry<String, Pair<HostVO, Integer>> hostEntry : 
hosts_with_resevered_capacity.entrySet()) {
                 Pair<HostVO, Integer> hp = hostEntry.getValue();
-                HostVO h = hp.first();
-                hostDao.loadHostTags(h);
-                if (StringUtils.isNotEmpty(offering.getHostTag()) && 
!(h.getHostTags() != null && h.getHostTags().contains(offering.getHostTag()))) {
+                HostVO hostVO = hp.first();
+                hostDao.loadHostTags(hostVO);
+                if (!hostVO.checkHostServiceOfferingTags(offering)) {
                     continue;
                 }
                 int reserved = hp.second();
                 reserved++;
-                ClusterVO cluster = clusterDao.findById(h.getClusterId());
+                ClusterVO cluster = clusterDao.findById(hostVO.getClusterId());
                 ClusterDetailsVO cluster_detail_cpu = 
clusterDetailsDao.findDetail(cluster.getId(), "cpuOvercommitRatio");
                 ClusterDetailsVO cluster_detail_ram = 
clusterDetailsDao.findDetail(cluster.getId(), "memoryOvercommitRatio");
                 Float cpuOvercommitRatio = 
Float.parseFloat(cluster_detail_cpu.getValue());
                 Float memoryOvercommitRatio = 
Float.parseFloat(cluster_detail_ram.getValue());
                 if (LOGGER.isDebugEnabled()) {
-                    LOGGER.debug(String.format("Checking host ID: %s for 
capacity already reserved %d", h.getUuid(), reserved));
+                    LOGGER.debug(String.format("Checking host ID: %s for 
capacity already reserved %d", hostVO.getUuid(), reserved));
                 }
-                if (capacityManager.checkIfHostHasCapacity(h.getId(), 
cpu_requested * reserved, ram_requested * reserved, false, cpuOvercommitRatio, 
memoryOvercommitRatio, true)) {
+                if (capacityManager.checkIfHostHasCapacity(hostVO.getId(), 
cpu_requested * reserved, ram_requested * reserved, false, cpuOvercommitRatio, 
memoryOvercommitRatio, true)) {
                     if (LOGGER.isDebugEnabled()) {
-                        LOGGER.debug(String.format("Found host ID: %s for with 
enough capacity, CPU=%d RAM=%s", h.getUuid(), cpu_requested * reserved, 
toHumanReadableSize(ram_requested * reserved)));
+                        LOGGER.debug(String.format("Found host ID: %s for with 
enough capacity, CPU=%d RAM=%s", hostVO.getUuid(), cpu_requested * reserved, 
toHumanReadableSize(ram_requested * reserved)));
                     }
-                    hostEntry.setValue(new Pair<HostVO, Integer>(h, reserved));
+                    hostEntry.setValue(new Pair<HostVO, Integer>(hostVO, 
reserved));
                     suitable_host_found = true;
                     planCluster = cluster;
                     break;

Reply via email to