You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2017/02/02 18:12:38 UTC

ambari git commit: AMBARI-19746 Ambari HDFS Metric alerts turns to UNKNOWN status with error "argument of type 'NoneType' is not iterable" (dsen)

Repository: ambari
Updated Branches:
  refs/heads/trunk f297c48f0 -> 5d4d99efb


AMBARI-19746 Ambari HDFS Metric alerts turns to UNKNOWN status with error "argument of type 'NoneType' is not iterable" (dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/5d4d99ef
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/5d4d99ef
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/5d4d99ef

Branch: refs/heads/trunk
Commit: 5d4d99efbd1a7de059c1257c09b396b90bade83e
Parents: f297c48
Author: Dmytro Sen <ds...@apache.org>
Authored: Thu Feb 2 20:12:30 2017 +0200
Committer: Dmytro Sen <ds...@apache.org>
Committed: Thu Feb 2 20:12:30 2017 +0200

----------------------------------------------------------------------
 .../src/main/python/ambari_agent/ActionQueue.py  |  5 +++++
 .../ambari_commons/ambari_metrics_helper.py      | 19 +++++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5d4d99ef/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
index 8514a88..5300b52 100644
--- a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
+++ b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
@@ -36,6 +36,7 @@ from CommandStatusDict import CommandStatusDict
 from CustomServiceOrchestrator import CustomServiceOrchestrator
 from ambari_agent.BackgroundCommandExecutionHandle import BackgroundCommandExecutionHandle
 from ambari_commons.str_utils import split_on_chunks
+from resource_management.libraries.script import Script
 
 
 logger = logging.getLogger()
@@ -549,6 +550,10 @@ class ActionQueue(threading.Thread):
       else:
         globalConfig = {}
 
+      if not Script.config :
+        logger.debug('Setting Script.config to last status command configuration')
+        Script.config = command
+
       livestatus = LiveStatus(cluster, service, component,
                               globalConfig, self.config, self.configTags)
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d4d99ef/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py b/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py
index 7841bde..6444dfd 100644
--- a/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py
+++ b/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py
@@ -24,7 +24,6 @@ from resource_management.libraries.functions import conf_select
 
 DEFAULT_COLLECTOR_SUFFIX = '.sink.timeline.collector.hosts'
 DEFAULT_METRICS2_PROPERTIES_FILE_NAME = 'hadoop-metrics2.properties'
-DEFAULT_HADOOP_CONF_DIR_PATH = '/usr/hdp/current/hadoop-client/conf/'
 
 def select_metric_collector_for_sink(sink_name):
   # TODO check '*' sink_name
@@ -46,10 +45,18 @@ def get_metric_collectors_from_properties_file(sink_name):
   try:
     hadoop_conf_dir = conf_select.get_hadoop_conf_dir()
   except Exception as e:
-    print "Can't get hadoop conf directory from conf_select.get_hadoop_conf_dir() - " + str(e)
-    hadoop_conf_dir = DEFAULT_HADOOP_CONF_DIR_PATH
-  props = load_properties_from_file(os.path.join(hadoop_conf_dir, DEFAULT_METRICS2_PROPERTIES_FILE_NAME))
-  return props.get(sink_name + DEFAULT_COLLECTOR_SUFFIX)
+    raise Exception("Couldn't define hadoop_conf_dir: {0}".format(e))
+  properties_filepath = os.path.join(hadoop_conf_dir, DEFAULT_METRICS2_PROPERTIES_FILE_NAME)
+
+  if not os.path.exists(properties_filepath):
+    raise Exception("Properties file doesn't exist : {0}. Can't define metric collector hosts".format(properties_filepath))
+  props = load_properties_from_file(properties_filepath)
+
+  property_key = sink_name + DEFAULT_COLLECTOR_SUFFIX
+  if property_key in props:
+    return props.get(property_key)
+  else:
+    raise Exception("Properties file doesn't contain {0}. Can't define metric collector hosts".format(property_key))
 
 def load_properties_from_file(filepath, sep='=', comment_char='#'):
   """
@@ -64,4 +71,4 @@ def load_properties_from_file(filepath, sep='=', comment_char='#'):
         key = key_value[0].strip()
         value = sep.join(key_value[1:]).strip('" \t')
         props[key] = value
-  return props
+  return props
\ No newline at end of file