AMBARI-18824 - MOTD Can Prevent WebHCat From Shutting Down (jonathanhurley)
(cherry picked from commit 7a6d871f43f0d8e0357048f8a9d7ecf2156b0bdb) Change-Id: I32bba0b4176ba550979c07944fd97eb8489075c1 Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9ba25983 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9ba25983 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9ba25983 Branch: refs/heads/AMBARI-2.4.2.16 Commit: 9ba25983c46bd9b6de8648325c2e687713fd5914 Parents: 729199f Author: Jonathan Hurley <jhur...@hortonworks.com> Authored: Tue Nov 8 13:01:59 2016 -0500 Committer: Zuul <rel...@hortonworks.com> Committed: Tue Nov 8 20:53:35 2016 -0800 ---------------------------------------------------------------------- .../package/scripts/webhcat_service.py | 7 +++-- .../stacks/2.0.6/HIVE/test_webhcat_server.py | 28 ++++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9ba25983/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat_service.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat_service.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat_service.py index 962becc..646090a 100644 --- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat_service.py +++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat_service.py @@ -21,7 +21,6 @@ Ambari Agent from resource_management import * from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl from ambari_commons import OSConst -from resource_management.core.shell import as_user from resource_management.core.logger import Logger import traceback @@ -48,7 +47,7 @@ def webhcat_service(action='start', upgrade_type=None): environ['HADOOP_HOME'] = format("{stack_root}/{version}/hadoop") daemon_cmd = format('cd {hcat_pid_dir} ; {cmd} start') - no_op_test = as_user(format('ls {webhcat_pid_file} >/dev/null 2>&1 && ps -p `cat {webhcat_pid_file}` >/dev/null 2>&1'), user=params.webhcat_user) + no_op_test = format('ls {webhcat_pid_file} >/dev/null 2>&1 && ps -p `cat {webhcat_pid_file}` >/dev/null 2>&1') try: Execute(daemon_cmd, user=params.webhcat_user, @@ -65,8 +64,8 @@ def webhcat_service(action='start', upgrade_type=None): show_logs(params.hcat_log_dir, params.webhcat_user) Logger.info(traceback.format_exc()) - # run this as WebHcat since the Execute conditions of not_of and only_if can't - pid_expression = "`" + as_user(format("cat {webhcat_pid_file}"), user=params.webhcat_user) + "`" + # this will retrieve the PID + pid_expression = format("`cat {webhcat_pid_file}`") # the PID must exist AND'd with the process must be alive # the return code here is going to be 0 IFF both conditions are met correctly http://git-wip-us.apache.org/repos/asf/ambari/blob/9ba25983/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_webhcat_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_webhcat_server.py b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_webhcat_server.py index 0880a19..2b26dd8 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_webhcat_server.py +++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_webhcat_server.py @@ -51,7 +51,7 @@ class TestWebHCatServer(RMFTestCase): self.assert_configure_default() self.assertResourceCalled('Execute', 'cd /var/run/webhcat ; /usr/hdp/current/hive-webhcat/sbin/webhcat_server.sh start', environment = {'HADOOP_HOME': '/usr/hdp/current/hadoop-client'}, - not_if = "ambari-sudo.sh su hcat -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `cat /var/run/webhcat/webhcat.pid` >/dev/null 2>&1'", + not_if = "ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `cat /var/run/webhcat/webhcat.pid` >/dev/null 2>&1", user = 'hcat', ) self.assertNoMoreResources() @@ -70,12 +70,12 @@ class TestWebHCatServer(RMFTestCase): environment = {'HADOOP_HOME': '/usr/hdp/current/hadoop-client' } ) - self.assertResourceCalled('Execute', 'ambari-sudo.sh kill -9 `ambari-sudo.sh su hcat -l -s /bin/bash -c \'[RMF_EXPORT_PLACEHOLDER]cat /var/run/webhcat/webhcat.pid\'`', - only_if = "ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh su hcat -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/webhcat/webhcat.pid'` >/dev/null 2>&1", + self.assertResourceCalled('Execute', 'ambari-sudo.sh kill -9 `cat /var/run/webhcat/webhcat.pid`', + only_if = "ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `cat /var/run/webhcat/webhcat.pid` >/dev/null 2>&1", ignore_failures = True ) - self.assertResourceCalled('Execute', "! (ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh su hcat -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/webhcat/webhcat.pid'` >/dev/null 2>&1)") + self.assertResourceCalled('Execute', "! (ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `cat /var/run/webhcat/webhcat.pid` >/dev/null 2>&1)") self.assertResourceCalled('File', '/var/run/webhcat/webhcat.pid', action = ['delete'], @@ -110,12 +110,12 @@ class TestWebHCatServer(RMFTestCase): user = 'hcat', ) - self.assertResourceCalled('Execute', 'ambari-sudo.sh kill -9 `ambari-sudo.sh su hcat -l -s /bin/bash -c \'[RMF_EXPORT_PLACEHOLDER]cat /var/run/webhcat/webhcat.pid\'`', - only_if = "ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh su hcat -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/webhcat/webhcat.pid'` >/dev/null 2>&1", + self.assertResourceCalled('Execute', 'ambari-sudo.sh kill -9 `cat /var/run/webhcat/webhcat.pid`', + only_if = "ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `cat /var/run/webhcat/webhcat.pid` >/dev/null 2>&1", ignore_failures = True ) - self.assertResourceCalled('Execute', "! (ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh su hcat -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/webhcat/webhcat.pid'` >/dev/null 2>&1)") + self.assertResourceCalled('Execute', "! (ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `cat /var/run/webhcat/webhcat.pid` >/dev/null 2>&1)") self.assertResourceCalled('File', '/var/run/webhcat/webhcat.pid', action = ['delete'], @@ -134,7 +134,7 @@ class TestWebHCatServer(RMFTestCase): self.assert_configure_secured() self.assertResourceCalled('Execute', 'cd /var/run/webhcat ; /usr/hdp/current/hive-webhcat/sbin/webhcat_server.sh start', environment = {'HADOOP_HOME': '/usr/hdp/current/hadoop-client'}, - not_if = "ambari-sudo.sh su hcat -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `cat /var/run/webhcat/webhcat.pid` >/dev/null 2>&1'", + not_if = "ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `cat /var/run/webhcat/webhcat.pid` >/dev/null 2>&1", user = 'hcat', ) self.assertNoMoreResources() @@ -153,12 +153,12 @@ class TestWebHCatServer(RMFTestCase): environment = {'HADOOP_HOME': '/usr/hdp/current/hadoop-client' } ) - self.assertResourceCalled('Execute', 'ambari-sudo.sh kill -9 `ambari-sudo.sh su hcat -l -s /bin/bash -c \'[RMF_EXPORT_PLACEHOLDER]cat /var/run/webhcat/webhcat.pid\'`', - only_if = "ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh su hcat -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/webhcat/webhcat.pid'` >/dev/null 2>&1", + self.assertResourceCalled('Execute', 'ambari-sudo.sh kill -9 `cat /var/run/webhcat/webhcat.pid`', + only_if = "ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `cat /var/run/webhcat/webhcat.pid` >/dev/null 2>&1", ignore_failures = True ) - self.assertResourceCalled('Execute', "! (ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh su hcat -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/webhcat/webhcat.pid'` >/dev/null 2>&1)") + self.assertResourceCalled('Execute', "! (ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `cat /var/run/webhcat/webhcat.pid` >/dev/null 2>&1)") self.assertResourceCalled('File', '/var/run/webhcat/webhcat.pid', action = ['delete'], ) @@ -180,12 +180,12 @@ class TestWebHCatServer(RMFTestCase): user = 'hcat', ) - self.assertResourceCalled('Execute', 'ambari-sudo.sh kill -9 `ambari-sudo.sh su hcat -l -s /bin/bash -c \'[RMF_EXPORT_PLACEHOLDER]cat /var/run/webhcat/webhcat.pid\'`', - only_if = "ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh su hcat -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/webhcat/webhcat.pid'` >/dev/null 2>&1", + self.assertResourceCalled('Execute', 'ambari-sudo.sh kill -9 `cat /var/run/webhcat/webhcat.pid`', + only_if = "ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `cat /var/run/webhcat/webhcat.pid` >/dev/null 2>&1", ignore_failures = True ) - self.assertResourceCalled('Execute', "! (ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh su hcat -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/webhcat/webhcat.pid'` >/dev/null 2>&1)") + self.assertResourceCalled('Execute', "! (ls /var/run/webhcat/webhcat.pid >/dev/null 2>&1 && ps -p `cat /var/run/webhcat/webhcat.pid` >/dev/null 2>&1)") self.assertResourceCalled('File', '/var/run/webhcat/webhcat.pid', action = ['delete'], )