Bladeren bron

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

This reverts commit 02f535cf9ff204dd53f7d78272c07eb33ac4b532.
Mahadev Konar 10 jaren geleden
bovenliggende
commit
c8f8045e0c

+ 3 - 3
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.killpg(os.getpgid(pid), signal.SIGTERM)
+    os.kill(pid, signal.SIGTERM)
     time.sleep(5)
     if os.path.exists(ProcessHelper.pidfile):
       raise Exception("PID file still exists.")
     os._exit(0)
-  except Exception:
+  except Exception, err:
     if pid == -1:
       print ("Agent process is not running")
     else:
-      os.killpg(os.getpgid(pid), signal.SIGKILL)
+      os.kill(pid, signal.SIGKILL)
     os._exit(1)
 
 def reset_agent(options):

+ 4 - 4
ambari-agent/src/test/python/ambari_agent/TestMain.py

@@ -189,7 +189,7 @@ class TestMain(unittest.TestCase):
 
 
   @patch("time.sleep")
-  @patch("os.killpg")
+  @patch("os.kill")
   @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(os.getpgid(int(pid)), signal.SIGTERM)
+    kill_mock.assert_called_with(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(os.getpgid(int(pid)), signal.SIGTERM)
-    kill_mock.assert_any_call(os.getpgid(int(pid)), signal.SIGKILL)
+    kill_mock.assert_any_call(int(pid), signal.SIGTERM)
+    kill_mock.assert_any_call(int(pid), signal.SIGKILL)
     _exit_mock.assert_called_with(1)
 
     # Restore