Repository: ambari Updated Branches: refs/heads/branch-2.0.0 41ca3cc68 -> d481b4d6f refs/heads/trunk c12bce3ac -> 1b22d34e5
AMBARI-10031. Ambari-agent died under SLES (and could not even restart automatically) (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1b22d34e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1b22d34e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1b22d34e Branch: refs/heads/trunk Commit: 1b22d34e51375e265fc125fda6b587438e02d185 Parents: c12bce3 Author: Andrew Onishuk <aonis...@hortonworks.com> Authored: Wed Mar 11 20:01:37 2015 +0200 Committer: Andrew Onishuk <aonis...@hortonworks.com> Committed: Wed Mar 11 20:01:37 2015 +0200 ---------------------------------------------------------------------- .../resource_management/TestGroupResource.py | 10 ++++----- .../resource_management/TestUserResource.py | 22 ++++++++++---------- .../python/resource_management/core/shell.py | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/1b22d34e/ambari-agent/src/test/python/resource_management/TestGroupResource.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/test/python/resource_management/TestGroupResource.py b/ambari-agent/src/test/python/resource_management/TestGroupResource.py index 597a6ee..d0ca261 100644 --- a/ambari-agent/src/test/python/resource_management/TestGroupResource.py +++ b/ambari-agent/src/test/python/resource_management/TestGroupResource.py @@ -51,7 +51,7 @@ class TestGroupResource(TestCase): self.assertEqual(popen_mock.call_count, 1) - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E groupadd -p secure hadoop"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E groupadd -p secure hadoop"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) getgrnam_mock.assert_called_with('hadoop') @@ -73,7 +73,7 @@ class TestGroupResource(TestCase): self.assertEqual(popen_mock.call_count, 1) - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E groupmod -p secure -g 2 mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E groupmod -p secure -g 2 mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) getgrnam_mock.assert_called_with('mapred') @@ -98,7 +98,7 @@ class TestGroupResource(TestCase): except Fail: pass self.assertEqual(popen_mock.call_count, 1) - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E groupmod -p secure -g 2 mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E groupmod -p secure -g 2 mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) getgrnam_mock.assert_called_with('mapred') @@ -119,7 +119,7 @@ class TestGroupResource(TestCase): self.assertEqual(popen_mock.call_count, 1) - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', 'groupdel mapred'], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', 'groupdel mapred'], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) getgrnam_mock.assert_called_with('mapred') @@ -144,5 +144,5 @@ class TestGroupResource(TestCase): pass self.assertEqual(popen_mock.call_count, 1) - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', 'groupdel mapred'], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', 'groupdel mapred'], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) getgrnam_mock.assert_called_with('mapred') http://git-wip-us.apache.org/repos/asf/ambari/blob/1b22d34e/ambari-agent/src/test/python/resource_management/TestUserResource.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/test/python/resource_management/TestUserResource.py b/ambari-agent/src/test/python/resource_management/TestUserResource.py index c946fed..800e823 100644 --- a/ambari-agent/src/test/python/resource_management/TestUserResource.py +++ b/ambari-agent/src/test/python/resource_management/TestUserResource.py @@ -44,7 +44,7 @@ class TestUserResource(TestCase): with Environment('/') as env: user = User("mapred", action = "create", shell = "/bin/bash") - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E useradd -m -s /bin/bash mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, env={'PATH': '/bin'}, bufsize=1, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E useradd -m -s /bin/bash mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, env={'PATH': '/bin'}, bufsize=1, cwd=None, close_fds=True) self.assertEqual(popen_mock.call_count, 1) @patch.object(subprocess, "Popen") @@ -59,7 +59,7 @@ class TestUserResource(TestCase): with Environment('/') as env: user = User("mapred", action = "create", shell = "/bin/bash") - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -s /bin/bash mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -s /bin/bash mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) self.assertEqual(popen_mock.call_count, 1) @patch.object(subprocess, "Popen") @@ -74,7 +74,7 @@ class TestUserResource(TestCase): with Environment('/') as env: user = User("mapred", action = "remove", shell = "/bin/bash") - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', 'userdel mapred'], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', 'userdel mapred'], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) self.assertEqual(popen_mock.call_count, 1) @patch.object(subprocess, "Popen") @@ -90,7 +90,7 @@ class TestUserResource(TestCase): user = User("mapred", action = "create", comment = "testComment", shell = "/bin/bash") - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -c testComment -s /bin/bash mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -c testComment -s /bin/bash mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) self.assertEqual(popen_mock.call_count, 1) @patch.object(subprocess, "Popen") @@ -106,7 +106,7 @@ class TestUserResource(TestCase): user = User("mapred", action = "create", home = "/test/home", shell = "/bin/bash") - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -s /bin/bash -d /test/home mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -s /bin/bash -d /test/home mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) self.assertEqual(popen_mock.call_count, 1) @patch.object(subprocess, "Popen") @@ -122,7 +122,7 @@ class TestUserResource(TestCase): user = User("mapred", action = "create", password = "secure", shell = "/bin/bash") - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -s /bin/bash -p secure mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -s /bin/bash -p secure mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) self.assertEqual(popen_mock.call_count, 1) @patch.object(subprocess, "Popen") @@ -137,7 +137,7 @@ class TestUserResource(TestCase): with Environment('/') as env: user = User("mapred", action = "create", shell = "/bin/sh") - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -s /bin/sh mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -s /bin/sh mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) self.assertEqual(popen_mock.call_count, 1) @patch.object(subprocess, "Popen") @@ -152,7 +152,7 @@ class TestUserResource(TestCase): with Environment('/') as env: user = User("mapred", action = "create", uid = "1", shell = "/bin/bash") - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -s /bin/bash -u 1 mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -s /bin/bash -u 1 mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) self.assertEqual(popen_mock.call_count, 1) @patch.object(subprocess, "Popen") @@ -167,7 +167,7 @@ class TestUserResource(TestCase): with Environment('/') as env: user = User("mapred", action = "create", gid = "1", shell = "/bin/bash") - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -s /bin/bash -g 1 mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E usermod -s /bin/bash -g 1 mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) self.assertEqual(popen_mock.call_count, 1) @patch.object(subprocess, "Popen") @@ -183,7 +183,7 @@ class TestUserResource(TestCase): user = User("mapred", action = "create", groups = ['1','2','3'], shell = "/bin/bash") - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', 'ambari-sudo.sh PATH=/bin -H -E usermod -G 1,2,3 -s /bin/bash mapred'], shell=False, preexec_fn=None, stderr=-2, stdout=5, env={'PATH': '/bin'}, bufsize=1, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', 'ambari-sudo.sh PATH=/bin -H -E usermod -G 1,2,3 -s /bin/bash mapred'], shell=False, preexec_fn=None, stderr=-2, stdout=5, env={'PATH': '/bin'}, bufsize=1, cwd=None, close_fds=True) self.assertEqual(popen_mock.call_count, 1) @patch.object(subprocess, "Popen") @@ -197,6 +197,6 @@ class TestUserResource(TestCase): with Environment('/') as env: user = User("mapred", action = "create") - popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E useradd -m mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None) + popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh PATH=/bin -H -E useradd -m mapred"], shell=False, preexec_fn=None, stderr=-2, stdout=5, bufsize=1, env={'PATH': '/bin'}, cwd=None, close_fds=True) self.assertEqual(popen_mock.call_count, 1) http://git-wip-us.apache.org/repos/asf/ambari/blob/1b22d34e/ambari-common/src/main/python/resource_management/core/shell.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/core/shell.py b/ambari-common/src/main/python/resource_management/core/shell.py index d57a450..cfa87f6 100644 --- a/ambari-common/src/main/python/resource_management/core/shell.py +++ b/ambari-common/src/main/python/resource_management/core/shell.py @@ -142,7 +142,7 @@ def _call(command, logoutput=None, throw_on_failure=True, # --noprofile is used to preserve PATH set for ambari-agent subprocess_command = ["/bin/bash","--login","--noprofile","-c", command] proc = subprocess.Popen(subprocess_command, bufsize=1, stdout=slave_fd, stderr=subprocess.STDOUT, - cwd=cwd, env=env, shell=False, + cwd=cwd, env=env, shell=False, close_fds=True, preexec_fn=preexec_fn) if timeout: