You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2016/04/20 17:42:43 UTC

ambari git commit: AMBARI-15993. Ambari does not show ATS is down even when the service is down (aonishuk)

Repository: ambari
Updated Branches:
  refs/heads/trunk 7948fe75d -> 291a61954


AMBARI-15993. Ambari does not show ATS is down even when the service is down (aonishuk)


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

Branch: refs/heads/trunk
Commit: 291a6195484c529f464b20ac47b583137d6b5ffd
Parents: 7948fe7
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Wed Apr 20 18:39:57 2016 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Wed Apr 20 18:39:57 2016 +0300

----------------------------------------------------------------------
 ambari-agent/src/main/python/ambari_agent/HostInfo.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/291a6195/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 805597a..2aae19e 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -209,7 +209,13 @@ class HostInfoLinux(HostInfo):
     try:
       pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
       for pid in pids:
-        cmd = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
+        try:
+          fp = open(os.path.join('/proc', pid, 'cmdline'), 'rb')
+        except IOError:
+          continue # avoid race condition if this process already died, since the moment we got pids list.
+
+        cmd = fp.read()
+        fp.close()
         cmd = cmd.replace('\0', ' ')
         if not 'AmbariServer' in cmd:
           if 'java' in cmd: