ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject ambari git commit: AMBARI-8333. Ambari-agent restart fails on Ubuntu. (aonishuk)
Date Fri, 14 Nov 2014 13:09:31 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 8add21831 -> 02f535cf9


AMBARI-8333. Ambari-agent restart fails on Ubuntu. (aonishuk)


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

Branch: refs/heads/trunk
Commit: 02f535cf9ff204dd53f7d78272c07eb33ac4b532
Parents: 8add218
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Fri Nov 14 15:08:41 2014 +0200
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Fri Nov 14 15:08:41 2014 +0200

----------------------------------------------------------------------
 ambari-agent/src/main/python/ambari_agent/main.py     | 6 +++---
 ambari-agent/src/test/python/ambari_agent/TestMain.py | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/02f535cf/ambari-agent/src/main/python/ambari_agent/main.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/main.py b/ambari-agent/src/main/python/ambari_agent/main.py
index e43d901..84182c0 100644
--- a/ambari-agent/src/main/python/ambari_agent/main.py
+++ b/ambari-agent/src/main/python/ambari_agent/main.py
@@ -153,16 +153,16 @@ def stop_agent():
     pid = f.read()
     pid = int(pid)
     f.close()
-    os.kill(pid, signal.SIGTERM)
+    os.killpg(os.getpgid(pid), signal.SIGTERM)
     time.sleep(5)
     if os.path.exists(ProcessHelper.pidfile):
       raise Exception("PID file still exists.")
     os._exit(0)
-  except Exception, err:
+  except Exception:
     if pid == -1:
       print ("Agent process is not running")
     else:
-      os.kill(pid, signal.SIGKILL)
+      os.killpg(os.getpgid(pid), signal.SIGKILL)
     os._exit(1)
 
 def reset_agent(options):

http://git-wip-us.apache.org/repos/asf/ambari/blob/02f535cf/ambari-agent/src/test/python/ambari_agent/TestMain.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestMain.py b/ambari-agent/src/test/python/ambari_agent/TestMain.py
index bb75bac..55901b5 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestMain.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestMain.py
@@ -189,7 +189,7 @@ class TestMain(unittest.TestCase):
 
 
   @patch("time.sleep")
-  @patch("os.kill")
+  @patch("os.killpg")
   @patch("os._exit")
   @patch("os.path.exists")
   def test_daemonize_and_stop(self, exists_mock, _exit_mock, kill_mock, sleep_mock):
@@ -207,7 +207,7 @@ class TestMain(unittest.TestCase):
     # Testing normal exit
     exists_mock.return_value = False
     main.stop_agent()
-    kill_mock.assert_called_with(int(pid), signal.SIGTERM)
+    kill_mock.assert_called_with(os.getpgid(int(pid)), signal.SIGTERM)
     _exit_mock.assert_called_with(0)
 
     # Restore
@@ -217,8 +217,8 @@ class TestMain(unittest.TestCase):
     # Testing exit when failed to remove pid file
     exists_mock.return_value = True
     main.stop_agent()
-    kill_mock.assert_any_call(int(pid), signal.SIGTERM)
-    kill_mock.assert_any_call(int(pid), signal.SIGKILL)
+    kill_mock.assert_any_call(os.getpgid(int(pid)), signal.SIGTERM)
+    kill_mock.assert_any_call(os.getpgid(int(pid)), signal.SIGKILL)
     _exit_mock.assert_called_with(1)
 
     # Restore


Mime
View raw message