Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BC354185CF for ; Tue, 21 Jul 2015 09:45:36 +0000 (UTC) Received: (qmail 51831 invoked by uid 500); 21 Jul 2015 09:45:20 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 51800 invoked by uid 500); 21 Jul 2015 09:45:20 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 51791 invoked by uid 99); 21 Jul 2015 09:45:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jul 2015 09:45:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B5565DFFB8; Tue, 21 Jul 2015 09:45:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aonishuk@apache.org To: commits@ambari.apache.org Date: Tue, 21 Jul 2015 09:45:20 -0000 Message-Id: <25c993ab632541b181a377e93840b90f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] ambari git commit: AMBARI-12465. Non-Root: Knox fails to start during install with custom pid directory (aonishuk) Repository: ambari Updated Branches: refs/heads/branch-2.1 6ce421442 -> 8b2186937 refs/heads/trunk 41019f051 -> b1add6e16 AMBARI-12465. Non-Root: Knox fails to start during install with custom pid directory (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b1add6e1 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b1add6e1 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b1add6e1 Branch: refs/heads/trunk Commit: b1add6e16336a638f1cfc12fe1f2a7a0b957df23 Parents: 41019f0 Author: Andrew Onishuk Authored: Tue Jul 21 12:45:11 2015 +0300 Committer: Andrew Onishuk Committed: Tue Jul 21 12:45:11 2015 +0300 ---------------------------------------------------------------------- .../KNOX/0.5.0.2.2/package/scripts/knox_gateway.py | 13 ++++++++----- .../test/python/stacks/2.2/KNOX/test_knox_gateway.py | 10 ++++------ 2 files changed, 12 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/b1add6e1/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py index 8117312..7323a73 100644 --- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py +++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py @@ -32,7 +32,7 @@ from resource_management.libraries.functions import Direction from resource_management.libraries.functions.security_commons import build_expectations, \ cached_kinit_executor, validate_security_config_properties, get_params_from_filesystem, \ FILE_TYPE_XML -from resource_management.core.resources.system import File, Execute, Directory +from resource_management.core.resources.system import File, Execute, Directory, Link from resource_management.core.resources.service import Service from resource_management.core.logger import Logger @@ -148,9 +148,10 @@ class KnoxGatewayDefault(KnoxGateway): no_op_test = format('ls {knox_pid_file} >/dev/null 2>&1 && ps -p `cat {knox_pid_file}` >/dev/null 2>&1') setup_ranger_knox(rolling_upgrade=rolling_restart) # Used to setup symlink, needed to update the knox managed symlink, in case of custom locations - if os.path.islink(params.knox_managed_pid_symlink) and os.path.realpath(params.knox_managed_pid_symlink) != params.knox_pid_dir: - os.unlink(params.knox_managed_pid_symlink) - os.symlink(params.knox_pid_dir, params.knox_managed_pid_symlink) + if os.path.islink(params.knox_managed_pid_symlink): + Link(params.knox_managed_pid_symlink, + to = params.knox_pid_dir, + ) Execute(daemon_cmd, user=params.knox_user, @@ -196,7 +197,9 @@ class KnoxGatewayDefault(KnoxGateway): environment={'JAVA_HOME': params.java_home}, user=params.knox_user, ) - Execute (format("rm -f {ldap_pid_file}")) + File(params.ldap_pid_file, + action = "delete" + ) def security_status(self, env): import status_params http://git-wip-us.apache.org/repos/asf/ambari/blob/b1add6e1/ambari-server/src/test/python/stacks/2.2/KNOX/test_knox_gateway.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.2/KNOX/test_knox_gateway.py b/ambari-server/src/test/python/stacks/2.2/KNOX/test_knox_gateway.py index 5ca5251..11f476e 100644 --- a/ambari-server/src/test/python/stacks/2.2/KNOX/test_knox_gateway.py +++ b/ambari-server/src/test/python/stacks/2.2/KNOX/test_knox_gateway.py @@ -319,10 +319,7 @@ class TestKnoxGateway(RMFTestCase): mocks_dict['call'].call_args_list[0][0][0]) @patch("os.path.islink") - @patch("os.path.realpath") - @patch("os.unlink") - @patch("os.symlink") - def test_start_default(self, symlink_mock, unlink_mock, realpath_mock, islink_mock): + def test_start_default(self, islink_mock): self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/knox_gateway.py", @@ -409,12 +406,13 @@ class TestKnoxGateway(RMFTestCase): owner = 'knox', content = self.getConfig()['configurations']['users-ldif']['content'] ) - + self.assertResourceCalled('Link', '/usr/hdp/current/knox-server/pids', + to = '/var/run/knox', + ) self.assertResourceCalled("Execute", "/usr/hdp/current/knox-server/bin/gateway.sh start", environment = {'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'}, not_if = u'ls /var/run/knox/gateway.pid >/dev/null 2>&1 && ps -p `cat /var/run/knox/gateway.pid` >/dev/null 2>&1', user = u'knox',) self.assertTrue(islink_mock.called) - self.assertTrue(realpath_mock.called) self.assertNoMoreResources()