AMBARI-9979. Oozie server start fails in non-root (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/71c91936 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/71c91936 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/71c91936 Branch: refs/heads/branch-2.0.0 Commit: 71c9193602731020764eea518a0278c80a34c0da Parents: d2625ab Author: Andrew Onishuk <[email protected]> Authored: Sun Mar 8 16:46:05 2015 +0200 Committer: Andrew Onishuk <[email protected]> Committed: Sun Mar 8 16:46:05 2015 +0200 ---------------------------------------------------------------------- .../python/resource_management/TestUserResource.py | 2 +- .../OOZIE/4.0.0.2.0/package/scripts/oozie.py | 4 +++- .../python/stacks/2.0.6/OOZIE/test_oozie_server.py | 13 +++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/71c91936/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 3062881..c946fed 100644 --- a/ambari-agent/src/test/python/resource_management/TestUserResource.py +++ b/ambari-agent/src/test/python/resource_management/TestUserResource.py @@ -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,hadoop -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) self.assertEqual(popen_mock.call_count, 1) @patch.object(subprocess, "Popen") http://git-wip-us.apache.org/repos/asf/ambari/blob/71c91936/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py index 13026c3..82a76aa 100644 --- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py @@ -218,4 +218,6 @@ def oozie_server_specific(): group = params.user_group, mode = 0664 ) - Execute (format("chown -R {oozie_user}:{user_group} {oozie_server_dir}")) + Execute(('chown', '-R', params.oozie_user, params.user_group, params.oozie_server_dir), + sudo=True + ) http://git-wip-us.apache.org/repos/asf/ambari/blob/71c91936/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py index 8cd2f11..4ae5112 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py +++ b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py @@ -217,8 +217,9 @@ class TestOozieServer(RMFTestCase): not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps -p `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1', user = 'oozie', ) - self.assertResourceCalled('Execute', 'chown -R oozie:hadoop /var/lib/oozie/oozie-server',) - self.assertNoMoreResources() + self.assertResourceCalled('Execute', ('chown', '-R', u'oozie', u'hadoop', '/var/lib/oozie/oozie-server'), + sudo = True, + ) @patch("os.path.isfile") def test_start_default(self, isfile_mock): @@ -473,7 +474,9 @@ class TestOozieServer(RMFTestCase): not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps -p `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1', user = 'oozie', ) - self.assertResourceCalled('Execute', 'chown -R oozie:hadoop /var/lib/oozie/oozie-server',) + self.assertResourceCalled('Execute', ('chown', '-R', u'oozie', u'hadoop', '/var/lib/oozie/oozie-server'), + sudo = True, + ) def assert_configure_secured(self): @@ -627,7 +630,9 @@ class TestOozieServer(RMFTestCase): not_if = 'ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps -p `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1', user = 'oozie', ) - self.assertResourceCalled('Execute', 'chown -R oozie:hadoop /var/lib/oozie/oozie-server',) + self.assertResourceCalled('Execute', ('chown', '-R', u'oozie', u'hadoop', '/var/lib/oozie/oozie-server'), + sudo = True, + ) def test_configure_default_hdp22(self): config_file = "stacks/2.0.6/configs/default.json"
