ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adorosz...@apache.org
Subject ambari git commit: AMBARI-21466. KNOX upgrade fails due to wrong stack root
Date Thu, 13 Jul 2017 16:06:07 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 0cb9194f5 -> a7b6d5a0f


AMBARI-21466. KNOX upgrade fails due to wrong stack root


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

Branch: refs/heads/branch-2.5
Commit: a7b6d5a0fc72c3d20c50210e887b7294007b0dba
Parents: 0cb9194
Author: Attila Doroszlai <adoroszlai@hortonworks.com>
Authored: Thu Jul 13 12:54:47 2017 +0200
Committer: Attila Doroszlai <adoroszlai@hortonworks.com>
Committed: Thu Jul 13 12:54:47 2017 +0200

----------------------------------------------------------------------
 .../libraries/functions/stack_tools.py                 | 13 +++++++++++++
 .../upgrades/ChangeStackReferencesAction.java          |  4 +++-
 .../KNOX/0.5.0.2.2/package/scripts/params_linux.py     |  8 ++++++++
 .../KNOX/0.5.0.2.2/package/scripts/upgrade.py          |  2 +-
 .../upgrades/ChangeStackReferencesActionTest.java      |  1 +
 5 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a7b6d5a0/ambari-common/src/main/python/resource_management/libraries/functions/stack_tools.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/stack_tools.py
b/ambari-common/src/main/python/resource_management/libraries/functions/stack_tools.py
index 420ae11..830598b 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/stack_tools.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/stack_tools.py
@@ -120,3 +120,16 @@ def get_stack_root(stack_name, stack_root_json):
     return "/usr/{0}".format(stack_name.lower())
 
   return stack_root[stack_name]
+
+
+def get_stack_name(stack_formatted):
+  """
+  Get the stack name (eg. HDP) from formatted string that may contain stack version (eg.
HDP-2.6.1.0-123)
+  """
+  if stack_formatted is None:
+    return None
+
+  if '-' not in stack_formatted:
+    return stack_formatted
+
+  return stack_formatted.split('-')[0]

http://git-wip-us.apache.org/repos/asf/ambari/blob/a7b6d5a0/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ChangeStackReferencesAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ChangeStackReferencesAction.java
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ChangeStackReferencesAction.java
index d75d031..03e5caf 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ChangeStackReferencesAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ChangeStackReferencesAction.java
@@ -35,6 +35,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 
@@ -45,6 +46,7 @@ import com.google.common.collect.Sets;
 public class ChangeStackReferencesAction extends AbstractServerAction {
 
   private static final Logger LOG = LoggerFactory.getLogger(ChangeStackReferencesAction.class);
+  private static final Set<String> SKIP_PROPERTIES = ImmutableSet.of("cluster-env/stack_root");
   private static final Set<Map.Entry<String, String>> REPLACEMENTS = Maps.asMap(
     Sets.newHashSet("/usr/iop", "iop/apps", "iop.version", "IOP_VERSION"),
     new Function<String, String>() {
@@ -83,7 +85,7 @@ public class ChangeStackReferencesAction extends AbstractServerAction {
         for (Map.Entry<String, String> entry : properties.entrySet()) {
           String key = entry.getKey();
           String original = entry.getValue();
-          if (original != null) {
+          if (original != null && !SKIP_PROPERTIES.contains(configType + "/" + key))
{
             String replaced = original;
             for (Map.Entry<String, String> replacement : REPLACEMENTS) {
               replaced = replaced.replace(replacement.getKey(), replacement.getValue());

http://git-wip-us.apache.org/repos/asf/ambari/blob/a7b6d5a0/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py
b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py
index 5a2ef19..9b0bbfc 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py
@@ -28,6 +28,7 @@ from resource_management.libraries.functions.version import format_stack_version
 from resource_management.libraries.functions.default import default
 from resource_management.libraries.functions.get_port_from_url import get_port_from_url
 from resource_management.libraries.functions.get_stack_version import get_stack_version
+from resource_management.libraries.functions.stack_tools import get_stack_name, get_stack_root
 from resource_management.libraries.functions import get_kinit_path
 from resource_management.libraries.script.script import Script
 from status_params import *
@@ -67,6 +68,13 @@ stack_supports_core_site_for_ranger_plugin = check_stack_feature(StackFeature.CO
 # DO NOT format it since we need the build number too.
 upgrade_from_version = default("/hostLevelParams/current_version", None)
 
+source_stack = default("/commandParams/source_stack", None)
+source_stack_name = get_stack_name(source_stack)
+if source_stack_name is not None and source_stack_name != stack_name:
+  source_stack_root = get_stack_root(source_stack_name, default('/configurations/cluster-env/stack_root',
None))
+else:
+  source_stack_root = stack_root
+
 # server configurations
 # Default value used in HDP 2.3.0.0 and earlier.
 knox_data_dir = '/var/lib/knox/data'

http://git-wip-us.apache.org/repos/asf/ambari/blob/a7b6d5a0/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/upgrade.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/upgrade.py
b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/upgrade.py
index 917f340..fa035c7 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/upgrade.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/upgrade.py
@@ -91,7 +91,7 @@ def seed_current_data_directory():
     Logger.info("Seeding Knox data from prior version...")
 
     # <stack-root>/2.3.0.0-1234/knox/data/.
-    source_data_dir = os.path.join(params.stack_root, params.upgrade_from_version, "knox",
"data", ".")
+    source_data_dir = os.path.join(params.source_stack_root, params.upgrade_from_version,
"knox", "data", ".")
 
     # <stack-root>/current/knox-server/data
     target_data_dir = os.path.join(params.stack_root, "current", "knox-server", "data")

http://git-wip-us.apache.org/repos/asf/ambari/blob/a7b6d5a0/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ChangeStackReferencesActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ChangeStackReferencesActionTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ChangeStackReferencesActionTest.java
index 592a95f..1104c96 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ChangeStackReferencesActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ChangeStackReferencesActionTest.java
@@ -69,6 +69,7 @@ public class ChangeStackReferencesActionTest {
     originalProperties.put("mapreduce_tar_source", "/usr/iop/current/hadoop-client/mapreduce.tar.gz");
     originalProperties.put("pig_tar_destination_folder", "hdfs:///iop/apps/{{ stack_version
}}/pig/");
     originalProperties.put("pig_tar_source", "/usr/iop/current/pig-client/pig.tar.gz");
+    originalProperties.put("stack_root", "/usr/iop");
     expect(clusterEnv.getProperties()).andReturn(originalProperties).anyTimes();
 
     // this is the crux of the test


Mime
View raw message