ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject ambari git commit: AMBARI-22160. hadooplzo package installation failed on devdeploys (aonishuk)
Date Mon, 09 Oct 2017 13:07:33 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.6 518172c10 -> eaa878063


AMBARI-22160. hadooplzo package installation failed on devdeploys (aonishuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/eaa87806
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/eaa87806
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/eaa87806

Branch: refs/heads/branch-2.6
Commit: eaa8780635cdcbe40c704bb88f4f9aa0f00df494
Parents: 518172c
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Mon Oct 9 16:07:27 2017 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Mon Oct 9 16:07:27 2017 +0300

----------------------------------------------------------------------
 .../libraries/script/script.py                  | 43 ++++++++++++++------
 .../stacks/2.0.6/HBASE/test_hbase_master.py     |  2 +
 .../src/test/python/stacks/utils/RMFTestCase.py |  4 +-
 3 files changed, 35 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/eaa87806/ambari-common/src/main/python/resource_management/libraries/script/script.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/script/script.py
b/ambari-common/src/main/python/resource_management/libraries/script/script.py
index a1fd1f3..e36392c 100644
--- a/ambari-common/src/main/python/resource_management/libraries/script/script.py
+++ b/ambari-common/src/main/python/resource_management/libraries/script/script.py
@@ -482,6 +482,7 @@ class Script(object):
       Script.stack_version_from_distro_select = pkg_provider.get_installed_package_version(
               stack_tools.get_stack_tool_package(stack_tools.STACK_SELECTOR_NAME))
 
+
     return Script.stack_version_from_distro_select
 
 
@@ -506,22 +507,20 @@ class Script(object):
     """
     This function replaces ${stack_version} placeholder with actual version.  If the package
     version is passed from the server, use that as an absolute truth.
-    
+
     :param name name of the package
     :param repo_version actual version of the repo currently installing
     """
-    stack_version_package_formatted = ""
+    if not STACK_VERSION_PLACEHOLDER in name:
+      return name
 
-    if not repo_version:
-      repo_version = self.get_stack_version_before_packages_installed()
+    stack_version_package_formatted = ""
 
     package_delimiter = '-' if OSCheck.is_ubuntu_family() else '_'
 
     # repositoryFile is the truth
     # package_version should be made to the form W_X_Y_Z_nnnn
     package_version = default("repositoryFile/repoVersion", None)
-    if package_version is not None:
-      package_version = package_version.replace('.', package_delimiter).replace('-', package_delimiter)
 
     # TODO remove legacy checks
     if package_version is None:
@@ -531,6 +530,16 @@ class Script(object):
     if package_version is None:
       package_version = default("hostLevelParams/package_version", None)
 
+    if package_version is None or '-' not in package_version:
+        self.load_available_packages()
+        package_name = self.get_package_from_available(name, self.available_packages_in_repos)
+        if package_name is None:
+          raise Fail("Cannot match package for regexp name {0}. Available packages: {1}".format(name,
self.available_packages_in_repos))
+        return package_name
+        
+    if package_version is not None:
+      package_version = package_version.replace('.', package_delimiter).replace('-', package_delimiter)
+
     # The cluster effective version comes down when the version is known after the initial
     # install.  In that case we should not be guessing which version when invoking INSTALL,
but
     # use the supplied version to build the package_version
@@ -549,6 +558,7 @@ class Script(object):
 
     # Wildcards cause a lot of troubles with installing packages, if the version contains
wildcards we try to specify it.
     if not package_version or '*' in package_version:
+      repo_version = self.get_stack_version_before_packages_installed()
       stack_version_package_formatted = repo_version.replace('.', package_delimiter).replace('-',
package_delimiter) if STACK_VERSION_PLACEHOLDER in name else name
 
     package_name = name.replace(STACK_VERSION_PLACEHOLDER, stack_version_package_formatted)
@@ -741,6 +751,18 @@ class Script(object):
     """
     self.install_packages(env)
 
+  def load_available_packages(self):
+    if self.available_packages_in_repos:
+      return self.available_packages_in_repos
+
+    pkg_provider = get_provider("Package")
+    try:
+      self.available_packages_in_repos = pkg_provider.get_available_packages_in_repos(CommandRepository(config['repositoryFile']))
+    except Exception as err:
+      Logger.exception("Unable to load available packages")
+      self.available_packages_in_repos = []
+        
+        
   def install_packages(self, env):
     """
     List of packages that are required< by service is received from the server
@@ -763,17 +785,11 @@ class Script(object):
       package_list_str = config['hostLevelParams']['package_list']
       agent_stack_retry_on_unavailability = bool(config['hostLevelParams']['agent_stack_retry_on_unavailability'])
       agent_stack_retry_count = int(config['hostLevelParams']['agent_stack_retry_count'])
-      pkg_provider = get_provider("Package")
-      try:
-        available_packages_in_repos = pkg_provider.get_available_packages_in_repos(CommandRepository(config['repositoryFile']))
-      except Exception as err:
-        Logger.exception("Unable to load available packages")
-        available_packages_in_repos = []
       if isinstance(package_list_str, basestring) and len(package_list_str) > 0:
         package_list = json.loads(package_list_str)
         for package in package_list:
           if self.check_package_condition(package):
-            name = self.get_package_from_available(package['name'], available_packages_in_repos)
+            name = self.format_package_name(package['name'])
             # HACK: On Windows, only install ambari-metrics packages using Choco Package
Installer
             # TODO: Update this once choco packages for hadoop are created. This is because,
service metainfo.xml support
             # <osFamily>any<osFamily> which would cause installation failure
on Windows.
@@ -1072,5 +1088,6 @@ class Script(object):
 
 
   def __init__(self):
+    self.available_packages_in_repos = []
     if Script.instance is not None:
       raise Fail("An instantiation already exists! Use, get_instance() method.")

http://git-wip-us.apache.org/repos/asf/ambari/blob/eaa87806/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py b/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py
index 370b776..2e940af 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HBASE/test_hbase_master.py
@@ -95,7 +95,9 @@ class TestHBaseMaster(RMFTestCase):
                          try_install=True,
                          os_type=('Redhat', '6.4', 'Final'),
                          checked_call_mocks = [(0, "OK.", "")],
+                         available_packages_in_repos = ['hbase_2_3_0_1_1234'],
                          )
+      
 
       # only assert that the correct package is trying to be installed
       self.assertResourceCalled('Package', 'hbase_2_3_0_1_1234',

http://git-wip-us.apache.org/repos/asf/ambari/blob/eaa87806/ambari-server/src/test/python/stacks/utils/RMFTestCase.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/utils/RMFTestCase.py b/ambari-server/src/test/python/stacks/utils/RMFTestCase.py
index 7091298..80712c5 100644
--- a/ambari-server/src/test/python/stacks/utils/RMFTestCase.py
+++ b/ambari-server/src/test/python/stacks/utils/RMFTestCase.py
@@ -76,7 +76,8 @@ class RMFTestCase(TestCase):
                     mocks_dict={},
                     try_install=False,
                     command_args=[],
-                    log_out_files=False):
+                    log_out_files=False,
+                    available_packages_in_repos = []):
 
     norm_path = os.path.normpath(path)
 
@@ -121,6 +122,7 @@ class RMFTestCase(TestCase):
         Script.instance = None
         script_class_inst = RMFTestCase._get_attr(script_module, classname)()
         script_class_inst.log_out_files = log_out_files
+        script_class_inst.available_packages_in_repos = available_packages_in_repos
         method = RMFTestCase._get_attr(script_class_inst, command)
     except IOError, err:
       raise RuntimeError("Cannot load class %s from %s: %s" % (classname, norm_path, err.message))


Mime
View raw message