Repository: ambari Updated Branches: refs/heads/trunk e96c68fcb -> 8b0939355
AMBARI-18935: 'HAWQ segments unregistered' shows incorrect alert (mithmatt) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8b093935 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8b093935 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8b093935 Branch: refs/heads/trunk Commit: 8b0939355612f331da3d1b029dc2878f2267c1b2 Parents: e96c68f Author: Matt <mmat...@pivotal.io> Authored: Fri Nov 18 11:23:15 2016 -0800 Committer: Matt <mmat...@pivotal.io> Committed: Fri Nov 18 11:23:15 2016 -0800 ---------------------------------------------------------------------- .../package/alerts/alert_segment_registration_status.py | 10 ++++------ .../HAWQ/test_alert_segment_registration_status.py | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/8b093935/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_segment_registration_status.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_segment_registration_status.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_segment_registration_status.py index ee8999e..157059b 100644 --- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_segment_registration_status.py +++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_segment_registration_status.py @@ -68,7 +68,7 @@ def execute(configurations={}, parameters={}, host_name=None): ambari_segment_list = get_segment_list_ambari() db_segment_list = get_segment_list_db(configurations[HAWQMASTER_PORT]) # Replace any occurence of 'localhost' in segment_list with host_name - hawq_segment_list = [host_name if name == 'localhost' else name for name in db_segment_list] + hawq_segment_list = [host_name.lower() if name == 'localhost' else name for name in db_segment_list] #Converted to set to omit any duplicates inserted into slaves file segment_diff = (set(hawq_segment_list) ^ set(ambari_segment_list)) @@ -94,7 +94,7 @@ def get_segment_list_db(port): Gets the Segment registrations count from HAWQMASTER by running a SQL command. """ logger.debug("Fetching segment list from HAWQ Master Database.") - query = " SELECT hostname FROM gp_segment_configuration where role = 'p' and status = 'u' " + query = " SELECT lower(hostname) FROM gp_segment_configuration where role = 'p' and status = 'u' " cmd = "source {0} && psql -p {1} -t -d {2} -c \"{3};\"".format(HAWQ_GREENPLUM_PATH_FILE, port, POSTGRES, query) returncode, command_output = call(cmd, user=HAWQ_USER, timeout=60) @@ -108,14 +108,12 @@ def get_segment_list_ambari(): """ Gets the Segment count from HAWQMASTER host from /usr/local/hawq/etc/slaves saved from ambari configurations file. """ - segment_list = [] logger.debug("Fetching Slaves from Slaves file in {0}".format(HAWQ_SLAVES_FILE)) try: - #regex to read all not empty lines in a file. with open(HAWQ_SLAVES_FILE, "r") as slaves_file: slaves = slaves_file.read() - segment_list = re.findall('\S+' , slaves) - return segment_list + #regex to read all non empty lines in a file. + return [segment.lower() for segment in re.findall('\S+' , slaves)] except Exception as ex: logger.error("[Alert HAWQ] Get Segment list from Slaves : Could not read slaves from {0}".format(HAWQ_SLAVES_FILE)) raise ex http://git-wip-us.apache.org/repos/asf/ambari/blob/8b093935/ambari-server/src/test/python/common-services/HAWQ/test_alert_segment_registration_status.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/common-services/HAWQ/test_alert_segment_registration_status.py b/ambari-server/src/test/python/common-services/HAWQ/test_alert_segment_registration_status.py index f1fde066..9c5dc59 100644 --- a/ambari-server/src/test/python/common-services/HAWQ/test_alert_segment_registration_status.py +++ b/ambari-server/src/test/python/common-services/HAWQ/test_alert_segment_registration_status.py @@ -39,9 +39,9 @@ RESULT_STATE_SKIPPED = 'SKIPPED' class TestAlertRegistrationStatus(RMFTestCase): - HOST_LIST_A = ['HOST1','HOST2','HOST3','HOST4'] - HOST_LIST_B = ['HOST1','HOST3','HOST5','HOST4'] - HOST_LIST_C = ['HOST1','HOST2','HOST3'] + HOST_LIST_A = ['host1','host2','host3','host4'] + HOST_LIST_B = ['host1','host3','host5','host4'] + HOST_LIST_C = ['host1','host2','host3'] def setUp(self): """