AMBARI-16144. Stack advisor scripts should handle calls where dependent services do not exist (smohanty)
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
index a007817..40f8267 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
@@ -624,11 +624,14 @@
# If no local DN in distributed mode
if operatingMode == "distributed":
dn_hosts = self.getComponentHostNames(services, "HDFS", "DATANODE")
- if set(amsCollectorHosts).intersection(dn_hosts):
- collector_cohosted_with_dn = "true"
- else:
- collector_cohosted_with_dn = "false"
- putAmsHbaseSiteProperty("dfs.client.read.shortcircuit", collector_cohosted_with_dn)
+ # call by Kerberos wizard sends only the service being affected
+ # so it is possible for dn_hosts to be None but not amsCollectorHosts
+ if dn_hosts and len(dn_hosts) > 0:
+ if set(amsCollectorHosts).intersection(dn_hosts):
+ collector_cohosted_with_dn = "true"
+ else:
+ collector_cohosted_with_dn = "false"
+ putAmsHbaseSiteProperty("dfs.client.read.shortcircuit", collector_cohosted_with_dn)
#split points
scriptDir = os.path.dirname(os.path.abspath(__file__))
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
index 21b4bff..8ffa720 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
@@ -133,7 +133,12 @@
return parentItems
def __getHosts(self, componentsList, componentName):
- return [component["hostnames"] for component in componentsList if component["component_name"] == componentName][0]
+ host_lists = [component["hostnames"] for component in componentsList if
+ component["component_name"] == componentName]
+ if host_lists and len(host_lists) > 0:
+ return host_lists[0]
+ else:
+ return []
def getNotPreferableOnServerComponents(self):
parentComponents = super(HDP23StackAdvisor, self).getNotPreferableOnServerComponents()