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

wuzhiguo pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new f12431c035 AMBARI-25604: During blueprint deploy tasks sometimes fail 
due to KeyError (#3555)
f12431c035 is described below

commit f12431c0357e8988f48a1d778dcba7a7ffb636c4
Author: Yu Hou <[email protected]>
AuthorDate: Tue Nov 22 17:21:18 2022 +0800

    AMBARI-25604: During blueprint deploy tasks sometimes fail due to KeyError 
(#3555)
---
 .../src/main/python/ambari_agent/ClusterTopologyCache.py         | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ambari-agent/src/main/python/ambari_agent/ClusterTopologyCache.py 
b/ambari-agent/src/main/python/ambari_agent/ClusterTopologyCache.py
index b7863c6b39..90987ca000 100644
--- a/ambari-agent/src/main/python/ambari_agent/ClusterTopologyCache.py
+++ b/ambari-agent/src/main/python/ambari_agent/ClusterTopologyCache.py
@@ -109,7 +109,14 @@ class ClusterTopologyCache(ClusterCache):
     cluster_host_info = defaultdict(lambda: [])
     for component_dict in self[cluster_id].components:
       component_name = component_dict.componentName
-      hostnames = [self.hosts_to_id[cluster_id][host_id].hostName for host_id 
in component_dict.hostIds]
+      hostnames = []
+      for host_id in component_dict.hostIds:
+        if host_id in self.hosts_to_id[cluster_id]:
+          hostnames.append(self.hosts_to_id[cluster_id][host_id].hostName)
+        else:
+          # In theory this should never happen. But in practice it happened 
when ambari-server had corrupt DB cache.
+          logger.warning("Cannot find host_id={} in 
cluster_id={}".format(host_id, cluster_id))
+
       cluster_host_info[component_name.lower()+"_hosts"] += hostnames
 
     cluster_host_info['all_hosts'] = []


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to