Bläddra i källkod

AMBARI-10553. symlinks for libsnappy.so are not accurate for HDP-2.2

Sumit Mohanty 10 år sedan
förälder
incheckning
7f542913ba

+ 1 - 1
ambari-agent/src/test/python/resource_management/TestLinkResource.py

@@ -62,7 +62,7 @@ class TestLinkResource(TestCase):
         
         self.fail("Must fail when directory or file with name /some_path exist")
       except Fail as e:
-        self.assertEqual("LinkProvider[Link['/some_path']] trying to create a symlink with the same name as an existing file or directory",
+        self.assertEqual("Link['/some_path'] trying to create a symlink with the same name as an existing file or directory",
                        str(e))
         
   @patch.object(sudo,  "path_lexists")

+ 4 - 2
ambari-agent/src/test/python/resource_management/TestUserResource.py

@@ -17,7 +17,7 @@ limitations under the License.
 '''
 
 from unittest import TestCase
-from mock.mock import patch, MagicMock
+from mock.mock import patch, MagicMock, PropertyMock
 
 from resource_management.core import Environment, Fail
 from resource_management.core.system import System
@@ -170,11 +170,13 @@ class TestUserResource(TestCase):
     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('resource_management.core.providers.accounts.UserProvider.user_groups', new_callable=PropertyMock)
   @patch.object(subprocess, "Popen")
   @patch.object(pwd, "getpwnam")
-  def test_attribute_groups(self, getpwnam_mock, popen_mock):
+  def test_attribute_groups(self, getpwnam_mock, popen_mock, user_groups_mock):
     subproc_mock = MagicMock()
     subproc_mock.returncode = 0
+    user_groups_mock.return_value = ['hadoop']
     subproc_mock.stdout.readline = MagicMock(side_effect = ['OK'])
     popen_mock.return_value = subproc_mock
     getpwnam_mock.return_value = 1

+ 2 - 2
ambari-common/src/main/python/resource_management/core/providers/system.py

@@ -208,7 +208,7 @@ class LinkProvider(Provider):
         return
       if not sudo.path_lexists(path):
         raise Fail(
-          "%s trying to create a symlink with the same name as an existing file or directory" % self)
+          "%s trying to create a symlink with the same name as an existing file or directory" % self.resource)
       Logger.info("%s replacing old symlink to %s" % (self.resource, oldpath))
       sudo.unlink(path)
       
@@ -224,7 +224,7 @@ class LinkProvider(Provider):
       if not sudo.path_exists(self.resource.to):
         Logger.info("Warning: linking to nonexistent location %s" % self.resource.to)
         
-      Logger.info("Creating symbolic %s" % self.resource)
+      Logger.info("Creating symbolic %s to %s" % (self.resource, self.resource.to))
       sudo.symlink(self.resource.to, path)
 
   def action_delete(self):

+ 2 - 0
ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/params.py

@@ -35,12 +35,14 @@ if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0:
   hadoop_lib_home = "/usr/hdp/current/hadoop-client/lib"
   hadoop_bin = "/usr/hdp/current/hadoop-client/sbin"
   hadoop_home = '/usr/hdp/current/hadoop-client'
+  create_lib_snappy_symlinks = False
 else:
   mapreduce_libs_path = "/usr/lib/hadoop-mapreduce/*"
   hadoop_libexec_dir = "/usr/lib/hadoop/libexec"
   hadoop_lib_home = "/usr/lib/hadoop/lib"
   hadoop_bin = "/usr/lib/hadoop/sbin"
   hadoop_home = '/usr'
+  create_lib_snappy_symlinks = True
 
 current_service = config['serviceName']
 hadoop_conf_dir = "/etc/hadoop/conf"

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/shared_initialization.py

@@ -160,7 +160,7 @@ def install_snappy():
   so_src_dir_x64 = format("{hadoop_home}/lib64")
   so_src_x86 = format("{so_src_dir_x86}/{snappy_so}")
   so_src_x64 = format("{so_src_dir_x64}/{snappy_so}")
-  if params.has_namenode:
+  if params.has_namenode and params.create_lib_snappy_symlinks:
     Directory([so_target_dir_x86, so_target_dir_x64],
               recursive=True,
     )