ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject [1/2] ambari git commit: AMBARI-12465. Non-Root: Knox fails to start during install with custom pid directory (aonishuk)
Date Tue, 21 Jul 2015 09:45:20 GMT
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 <aonishuk@hortonworks.com>
Authored: Tue Jul 21 12:45:11 2015 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
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()
 


Mime
View raw message