Repository: ambari
Updated Branches:
  refs/heads/trunk 9c5122aaf -> b9ed455d5


AMBARI-16417: More information for Standby sync alert


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

Branch: refs/heads/trunk
Commit: b9ed455d5df1c5cec968234e0e6c7019413b68c8
Parents: 9c5122a
Author: Jun Aoki <ja...@apache.org>
Authored: Wed May 11 14:20:28 2016 -0700
Committer: Jun Aoki <ja...@apache.org>
Committed: Wed May 11 14:20:28 2016 -0700

----------------------------------------------------------------------
 .../2.0.0/package/alerts/alert_sync_status.py   | 24 ++++++++++++--------
 .../stacks/2.3/HAWQ/test_alert_sync_status.py   |  8 +++----
 2 files changed, 18 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b9ed455d/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_sync_status.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_sync_status.py
 
b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_sync_status.py
index c94be9e..e916f07 100644
--- 
a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_sync_status.py
+++ 
b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/alerts/alert_sync_status.py
@@ -60,11 +60,12 @@ def execute(configurations={}, parameters={}, 
host_name=None):
    return (RESULT_STATE_SKIPPED, ['HAWQSTANDBY is not installed.'])
 
   try:
-    sync_status = get_sync_status(configurations[HAWQMASTER_PORT])
-    if sync_status in ('Synchronized', 'Synchronizing'):
+    summary_state, error_message = 
get_sync_status(configurations[HAWQMASTER_PORT])
+
+    if summary_state in ('Synchronized', 'Synchronizing'):
       return (RESULT_STATE_OK, ['HAWQSTANDBY is in sync with HAWQMASTER.'])
-    elif sync_status == 'Not Synchronized':
-      return (RESULT_STATE_WARNING, ['HAWQSTANDBY is not in sync with 
HAWQMASTER.'])
+    elif summary_state == 'Not Synchronized':
+      return (RESULT_STATE_WARNING, ['HAWQSTANDBY is not in sync with 
HAWQMASTER. ERROR: ' + error_message])
   except Exception, e:
     logger.exception('[Alert] Retrieving HAWQSTANDBY sync status from 
HAWQMASTER fails on host, {0}:'.format(host_name))
     logger.exception(str(e))
@@ -78,14 +79,17 @@ def get_sync_status(port):
   Gets the sync status of HAWQSTANDBY from HAWQMASTER by running a SQL command.
   summary_state can be of the following values: ('Synchronized', 
'Synchronizing', 'Not Synchronized', 'None', 'Not Configured', 'Unknown')
   """
-  query = "SELECT summary_state FROM gp_master_mirroring"
-  cmd = "source {0} && psql -p {1} -t -d template1 -c 
\"{2};\"".format(HAWQ_GREENPLUM_PATH_FILE, port, query)
+  
+  query = "SELECT summary_state, error_message FROM gp_master_mirroring"
+  cmd = "source {0} && psql -p {1} -t --no-align -d template1 -c 
\"{2};\"".format(HAWQ_GREENPLUM_PATH_FILE, port, query)
 
-  returncode, output = call(cmd,
-                            user=HAWQ_USER,
-                            timeout=60)
+  returncode, output = call(cmd, user=HAWQ_USER, timeout=60)
 
   if returncode:
     raise
 
-  return output.strip()
+  split_output = output.split("|")
+  summary_state = split_output[0].strip()
+  error_message = split_output[1].strip()
+
+  return (summary_state, error_message)

http://git-wip-us.apache.org/repos/asf/ambari/blob/b9ed455d/ambari-server/src/test/python/stacks/2.3/HAWQ/test_alert_sync_status.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/python/stacks/2.3/HAWQ/test_alert_sync_status.py 
b/ambari-server/src/test/python/stacks/2.3/HAWQ/test_alert_sync_status.py
index 7d030dc..fd4f474 100644
--- a/ambari-server/src/test/python/stacks/2.3/HAWQ/test_alert_sync_status.py
+++ b/ambari-server/src/test/python/stacks/2.3/HAWQ/test_alert_sync_status.py
@@ -91,7 +91,7 @@ class TestAlertSyncStatus(RMFTestCase):
     }
 
     # Mock calls
-    get_sync_status_mock.return_value = 'Synchronized'
+    get_sync_status_mock.return_value = ('Synchronized', "")
 
     [status, messages] = alert_sync_status.execute(configurations=configs)
     self.assertEqual(status, RESULT_STATE_OK)
@@ -110,7 +110,7 @@ class TestAlertSyncStatus(RMFTestCase):
     }
 
     # Mock calls
-    get_sync_status_mock.return_value = 'Synchronizing'
+    get_sync_status_mock.return_value = ('Synchronizing', "")
 
     [status, messages] = alert_sync_status.execute(configurations=configs)
     self.assertEqual(status, RESULT_STATE_OK)
@@ -129,12 +129,12 @@ class TestAlertSyncStatus(RMFTestCase):
     }
 
     # Mock calls
-    get_sync_status_mock.return_value = 'Not Synchronized'
+    get_sync_status_mock.return_value = ('Not Synchronized', "ERROR_MESSAGE")
 
     [status, messages] = alert_sync_status.execute(configurations=configs)
     self.assertEqual(status, RESULT_STATE_WARNING)
     self.assertTrue(messages is not None and len(messages) == 1)
-    self.assertEqual(messages[0], 'HAWQSTANDBY is not in sync with 
HAWQMASTER.')
+    self.assertEqual(messages[0], 'HAWQSTANDBY is not in sync with HAWQMASTER. 
ERROR: ERROR_MESSAGE')
 
 
   @patch("alert_sync_status.get_sync_status")

Reply via email to