ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject ambari git commit: AMBARI-18761. NTP check fails even if chrony is working on CentOS7. (Masahiro Tanaka via swagle)
Date Mon, 07 Nov 2016 18:58:47 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 2f221bd78 -> 8f20af286


AMBARI-18761. NTP check fails even if chrony is working on CentOS7. (Masahiro Tanaka via swagle)


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

Branch: refs/heads/trunk
Commit: 8f20af2867f39a9fd4943f98e5d62e17083732af
Parents: 2f221bd
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Mon Nov 7 10:58:36 2016 -0800
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Mon Nov 7 10:58:36 2016 -0800

----------------------------------------------------------------------
 .../src/main/python/ambari_agent/HostInfo.py    | 23 +++++++++++------
 .../test/python/ambari_agent/TestHostInfo.py    | 26 +++++++++++++++++---
 2 files changed, 37 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8f20af28/ambari-agent/src/main/python/ambari_agent/HostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/HostInfo.py b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
index 3871e72..338daac 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -66,15 +66,20 @@ class HostInfo(object):
     return 'unknown'
 
   def checkLiveServices(self, services, result):
-    osType = OSCheck.get_os_family()
     for service in services:
       svcCheckResult = {}
-      serviceName = service
-      svcCheckResult['name'] = serviceName
+      svcCheckResult['name'] = " or ".join(service)
       svcCheckResult['status'] = "UNKNOWN"
       svcCheckResult['desc'] = ""
       try:
-        out, err, code = self.getServiceStatus(serviceName)
+        out = ""
+        err = ""
+        for serviceName in service:
+          sys_out, sys_err, code = self.getServiceStatus(serviceName)
+          if code == 0:
+            break
+          out += sys_out if len(out) == 0 else os.linesep + sys_out
+          err += sys_err if len(err) == 0 else os.linesep + sys_err
         if 0 != code:
           svcCheckResult['status'] = "Unhealthy"
           svcCheckResult['desc'] = out
@@ -116,10 +121,12 @@ class HostInfo(object):
     return False
 
 def get_ntp_service():
-  if OSCheck.is_redhat_family():
-    return "ntpd"
+  if OSCheck.is_redhat_family() and int(OSCheck.get_os_major_version()) >= 7:
+    return ("chronyd", "ntpd",)
+  elif OSCheck.is_redhat_family():
+    return ("ntpd",)
   elif OSCheck.is_suse_family() or OSCheck.is_ubuntu_family():
-    return "ntp"
+    return ("ntp",)
 
 
 @OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
@@ -341,7 +348,7 @@ class HostInfoWindows(HostInfo):
   GET_USERS_CMD = '$accounts=(Get-WmiObject -Class Win32_UserAccount -Namespace "root\cimv2"
-Filter "name = \'{0}\' and Disabled=\'False\'" -ErrorAction Stop); foreach ($acc in $accounts)
{{Write-Host ($acc.Domain + "\\" + $acc.Name)}}'
   GET_JAVA_PROC_CMD = 'foreach ($process in (gwmi Win32_Process -Filter "name = \'java.exe\'")){{echo
$process.ProcessId;echo $process.CommandLine; echo $process.GetOwner().User}}'
   DEFAULT_LIVE_SERVICES = [
-    "W32Time"
+    ("W32Time",)
   ]
   DEFAULT_USERS = "hadoop"
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8f20af28/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py b/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
index 0c0a3b3..fcfbc85 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
@@ -369,7 +369,7 @@ class TestHostInfo(TestCase):
     subproc_popen.return_value = p
     result = []
     get_os_type_method.return_value = 'redhat'
-    hostInfo.checkLiveServices(['service1'], result)
+    hostInfo.checkLiveServices([('service1',)], result)
 
     self.assertEquals(result[0]['status'], 'Healthy')
     self.assertEquals(result[0]['name'], 'service1')
@@ -380,7 +380,7 @@ class TestHostInfo(TestCase):
     p.returncode = 1
     p.communicate.return_value = ('out', 'err')
     result = []
-    hostInfo.checkLiveServices(['service1'], result)
+    hostInfo.checkLiveServices([('service1',)], result)
 
     self.assertEquals(result[0]['status'], 'Unhealthy')
     self.assertEquals(result[0]['name'], 'service1')
@@ -388,7 +388,7 @@ class TestHostInfo(TestCase):
 
     p.communicate.return_value = ('', 'err')
     result = []
-    hostInfo.checkLiveServices(['service1'], result)
+    hostInfo.checkLiveServices([('service1',)], result)
 
     self.assertEquals(result[0]['status'], 'Unhealthy')
     self.assertEquals(result[0]['name'], 'service1')
@@ -396,12 +396,30 @@ class TestHostInfo(TestCase):
 
     p.communicate.return_value = ('', 'err', '')
     result = []
-    hostInfo.checkLiveServices(['service1'], result)
+    hostInfo.checkLiveServices([('service1',)], result)
 
     self.assertEquals(result[0]['status'], 'Unhealthy')
     self.assertEquals(result[0]['name'], 'service1')
     self.assertTrue(len(result[0]['desc']) > 0)
 
+    p.returncode = 0
+    p.communicate.return_value = ('', 'err')
+    result = []
+    hostInfo.checkLiveServices([('service1', 'service2',)], result)
+
+    self.assertEquals(result[0]['status'], 'Healthy')
+    self.assertEquals(result[0]['name'], 'service1 or service2')
+    self.assertEquals(result[0]['desc'], '')
+
+    p.returncode = 1
+    p.communicate.return_value = ('out', 'err')
+    result = []
+    hostInfo.checkLiveServices([('service1', 'service2',)], result)
+
+    self.assertEquals(result[0]['status'], 'Unhealthy')
+    self.assertEquals(result[0]['name'], 'service1 or service2')
+    self.assertEquals(result[0]['desc'], 'out\nout')
+
   @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = ('redhat','11','Final')))
   @patch("os.path.exists")
   @patch("os.listdir", create=True, autospec=True)


Mime
View raw message