You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2018/05/30 11:37:54 UTC

[ambari] branch trunk updated: [AMBARI-23929] Stack changes for AMS to help with HDP 2.6 to 3.0 EU (dsen) (#1353)

This is an automated email from the ASF dual-hosted git repository.

dsen pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new d447ea5  [AMBARI-23929] Stack changes for AMS to help with HDP 2.6 to 3.0 EU (dsen) (#1353)
d447ea5 is described below

commit d447ea5195832b3d94ca1c22fade8753b8c096e4
Author: Dmitry Sen <ds...@apache.org>
AuthorDate: Wed May 30 14:37:51 2018 +0300

    [AMBARI-23929] Stack changes for AMS to help with HDP 2.6 to 3.0 EU (dsen) (#1353)
    
    * [AMBARI-23929] Stack changes for AMS to help with HDP 2.6 to 3.0 EU. (dsen)
    
    * [AMBARI-23929] Stack changes for AMS to help with HDP 2.6 to 3.0 EU. (dsen)
---
 .../repo_manager/repo_manager_helper.py            | 54 ++++++++++++++++++++++
 .../ambari_commons/repo_manager/yum_manager.py     |  4 +-
 .../ambari_commons/repo_manager/zypper_manager.py  |  6 +--
 .../0.1.0/package/scripts/hbase_service.py         |  4 ++
 .../0.96.0.2.0/package/scripts/hbase_service.py    |  4 ++
 .../HDFS/2.1.0.2.0/package/scripts/utils.py        |  4 ++
 .../0.12.0.2.0/package/scripts/hive_service.py     |  4 ++
 .../YARN/2.1.0.2.0/package/scripts/service.py      |  4 ++
 8 files changed, 79 insertions(+), 5 deletions(-)

diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/repo_manager_helper.py b/ambari-common/src/main/python/ambari_commons/repo_manager/repo_manager_helper.py
new file mode 100644
index 0000000..91d86a6
--- /dev/null
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/repo_manager_helper.py
@@ -0,0 +1,54 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+from . import ManagerFactory
+from resource_management.libraries.functions.version import compare_versions
+from resource_management.core.logger import Logger
+from resource_management.core.exceptions import Fail
+from ambari_commons import OSCheck
+
+def check_installed_metrics_hadoop_sink_version(hadoop_sink_package_name="ambari-metrics-hadoop-sink",
+                                                checked_version="2.7.0.0", less_valid=True, equal_valid=False):
+
+  # The default package name is different for ubuntu and debian, so if the dafault one is used change the name
+  if hadoop_sink_package_name == "ambari-metrics-hadoop-sink" and OSCheck.is_ubuntu_family():
+    hadoop_sink_package_name = "ambari-metrics-assembly"
+
+  pkg_provider = ManagerFactory.get()
+  hadoop_sink_version = pkg_provider.get_installed_package_version(hadoop_sink_package_name)
+
+  if not hadoop_sink_version:
+    Logger.warning("Couldn't determine %s package version, skipping the sink version check" % hadoop_sink_package_name)
+    return
+  else:
+    if "-" in hadoop_sink_version:
+      hadoop_sink_version = hadoop_sink_version.split("-")[0]
+    # installed version should be less than next version
+    compare_result = compare_versions(hadoop_sink_version, checked_version)
+    if equal_valid and compare_result == 0:
+      pass
+    elif less_valid and compare_result != -1:
+      raise Fail("%s installed package version is %s. It should be less than %s due to"
+                 " incompatibility. Please downgrade the package or upgrade the stack and try again."
+                 % (hadoop_sink_package_name, hadoop_sink_version, checked_version))
+
+    elif not less_valid and compare_result != 1:
+      raise Fail("%s installed package version is %s. It should be greater than or equal to %s due to"
+                 " incompatibility. Please upgrade the package or downgrade the stack and try again."
+                 % (hadoop_sink_package_name, hadoop_sink_version, checked_version))
+
+  Logger.info("ambari-metrics-hadoop-sink package version is OK")
\ No newline at end of file
diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
index 7df4632..e3df80e 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
@@ -63,7 +63,7 @@ class YumManagerProperties(GenericManagerProperties):
   }
 
   verify_dependency_cmd = [repo_manager_bin, '-d', '0', '-e', '0', 'check', 'dependencies']
-  installed_package_version_command = [pkg_manager_bin, "-q", "--queryformat", "%{{version}}-%{{release}}"]
+  installed_package_version_command = [pkg_manager_bin, "-q", "--queryformat", "%{version}-%{release}\n"]
 
   remove_without_dependencies_cmd = ['rpm', '-e', '--nodeps']
 
@@ -356,7 +356,7 @@ class YumManager(GenericManager):
 
   def get_installed_package_version(self, package_name):
     version = None
-    cmd = list(self.properties.installed_package_version_command) + ["\"{0}\"".format(package_name)]
+    cmd = list(self.properties.installed_package_version_command) + [package_name]
 
     result = shell.subprocess_executor(cmd)
 
diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
index 8d901c2..789a3d0 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
@@ -31,7 +31,7 @@ class ZypperManagerProperties(GenericManagerProperties):
   repo_error = "Failure when receiving data from the peer"
 
   repo_manager_bin = "/usr/bin/zypper"
-  pkg_manager_bin = "/usr/bin/rpm"
+  pkg_manager_bin = "/bin/rpm"
   repo_update_cmd = [repo_manager_bin, "clean"]
 
   available_packages_cmd = [repo_manager_bin, "--no-gpg-checks", "search", "--uninstalled-only", "--details"]
@@ -52,7 +52,7 @@ class ZypperManagerProperties(GenericManagerProperties):
 
   verify_dependency_cmd = [repo_manager_bin, "--quiet", "--non-interactive", "verify", "--dry-run"]
   list_active_repos_cmd = ['/usr/bin/zypper', 'repos']
-  installed_package_version_command = [pkg_manager_bin, "-q", "--queryformat", "%{{version}}-%{{release}}"]
+  installed_package_version_command = [pkg_manager_bin, "-q", "--queryformat", "%{version}-%{release}\n"]
 
 
 class ZypperManager(GenericManager):
@@ -263,7 +263,7 @@ class ZypperManager(GenericManager):
 
   def get_installed_package_version(self, package_name):
     version = None
-    cmd = list(self.properties.installed_package_version_command) + ["\"{0}\"".format(package_name)]
+    cmd = list(self.properties.installed_package_version_command) + [package_name]
     result = shell.subprocess_executor(cmd)
     try:
       if result.code == 0:
diff --git a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/hbase_service.py b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/hbase_service.py
index 42f23bf..6105139 100644
--- a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/hbase_service.py
+++ b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/hbase_service.py
@@ -20,6 +20,7 @@ limitations under the License.
 
 from resource_management.core.resources.system import Execute, File
 from resource_management.libraries.functions.format import format
+from ambari_commons.repo_manager.repo_manager_helper import check_installed_metrics_hadoop_sink_version
 
 def hbase_service(
   name,
@@ -33,6 +34,9 @@ def hbase_service(
     no_op_test = format("ls {pid_file} >/dev/null 2>&1 && ps `cat {pid_file}` >/dev/null 2>&1")
     
     if action == 'start':
+      # Check ambari-metrics-hadoop-sink version is less than 2.7.0.0
+      check_installed_metrics_hadoop_sink_version()
+
       daemon_cmd = format("{cmd} start {role}")
       
       Execute ( daemon_cmd,
diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_service.py b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_service.py
index 1dbd560..6928182 100644
--- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_service.py
+++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_service.py
@@ -22,6 +22,7 @@ from resource_management.libraries.functions.format import format
 from resource_management.libraries.functions.show_logs import show_logs
 from resource_management.core.shell import as_sudo
 from resource_management.core.resources.system import Execute, File
+from ambari_commons.repo_manager.repo_manager_helper import check_installed_metrics_hadoop_sink_version
 
 def hbase_service(
   name,
@@ -36,6 +37,9 @@ def hbase_service(
     no_op_test = as_sudo(["test", "-f", pid_file]) + format(" && ps -p `{pid_expression}` >/dev/null 2>&1")
     
     if action == 'start':
+      # Check ambari-metrics-hadoop-sink version is less than 2.7.0.0
+      check_installed_metrics_hadoop_sink_version()
+
       daemon_cmd = format("{cmd} start {role}")
       
       try:
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py
index eddf890..f6cea7a 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py
@@ -37,6 +37,7 @@ from resource_management.libraries.functions.curl_krb_request import curl_krb_re
 from resource_management.libraries.script.script import Script
 from resource_management.libraries.functions.namenode_ha_utils import get_namenode_states
 from resource_management.libraries.functions.show_logs import show_logs
+from ambari_commons.repo_manager.repo_manager_helper import check_installed_metrics_hadoop_sink_version
 from ambari_commons.inet_utils import ensure_ssl_using_protocol
 from zkfc_slave import ZkfcSlaveDefault
 
@@ -269,6 +270,9 @@ def service(action=None, name=None, user=None, options="", create_pid_dir=False,
     daemon_cmd = as_user(cmd, user)
      
   if action == "start":
+    # Check ambari-metrics-hadoop-sink version is less than 2.7.0.0
+    check_installed_metrics_hadoop_sink_version()
+
     # remove pid file from dead process
     File(pid_file, action="delete", not_if=process_id_exists_command)
     
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
index 05aedc1..9bc2601 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
@@ -36,6 +36,7 @@ from resource_management.libraries.functions.stack_features import check_stack_f
 
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 from ambari_commons import OSConst
+from ambari_commons.repo_manager.repo_manager_helper import check_installed_metrics_hadoop_sink_version
 
 
 @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
@@ -72,6 +73,9 @@ def hive_service(name, action='start', upgrade_type=None):
   process_id_exists_command = format("ls {pid_file} >/dev/null 2>&1 && ps -p {pid} >/dev/null 2>&1")
 
   if action == 'start':
+    # Check ambari-metrics-hadoop-sink version is less than 2.7.0.0
+    check_installed_metrics_hadoop_sink_version()
+
     if name == 'hiveserver2':
       check_fs_root(params.hive_server_conf_dir, params.execute_path)
 
diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py
index 7c59b60..cc790e9 100644
--- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py
+++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py
@@ -21,6 +21,7 @@ Ambari Agent
 
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 from ambari_commons import OSConst
+from ambari_commons.repo_manager.repo_manager_helper import check_installed_metrics_hadoop_sink_version
 from resource_management.core.shell import as_user, as_sudo
 from resource_management.libraries.functions.show_logs import show_logs
 from resource_management.libraries.functions.format import format
@@ -64,6 +65,9 @@ def service(componentName, action='start', serviceName='yarn'):
   cmd = format("export HADOOP_LIBEXEC_DIR={hadoop_libexec_dir} && {daemon} --config {hadoop_conf_dir}")
 
   if action == 'start':
+    # Check ambari-metrics-hadoop-sink version is less than 2.7.0.0
+    check_installed_metrics_hadoop_sink_version()
+
     daemon_cmd = format("{ulimit_cmd} {cmd} start {componentName}")
     check_process = as_sudo(["test", "-f", pid_file]) + " && " + as_sudo(["pgrep", "-F", pid_file])
 

-- 
To stop receiving notification emails like this one, please contact
dsen@apache.org.