You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2018/05/31 19:58:35 UTC
[ambari] branch trunk updated: [AMBARI-24002] - Set All Versions
only on Upgrades which cannot be Downgraded (#1430)
This is an automated email from the ASF dual-hosted git repository.
jonathanhurley 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 7700ee8 [AMBARI-24002] - Set All Versions only on Upgrades which cannot be Downgraded (#1430)
7700ee8 is described below
commit 7700ee84c0019a8ba0f7c07f57d1009509819cdd
Author: Jonathan Hurley <jo...@apache.org>
AuthorDate: Thu May 31 15:58:31 2018 -0400
[AMBARI-24002] - Set All Versions only on Upgrades which cannot be Downgraded (#1430)
---
.../libraries/functions/upgrade_summary.py | 6 +-
.../internal/HostStackVersionResourceProvider.java | 2 +-
.../apache/ambari/server/state/UpgradeContext.java | 31 +++
.../{ru_set_all.py => stack_select_set_all.py} | 86 ++------
.../HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml | 17 --
.../HDP/2.3/upgrades/nonrolling-upgrade-2.4.xml | 17 --
.../HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml | 17 --
.../HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml | 17 --
.../stacks/HDP/2.3/upgrades/upgrade-2.3.xml | 10 -
.../stacks/HDP/2.3/upgrades/upgrade-2.4.xml | 10 -
.../stacks/HDP/2.3/upgrades/upgrade-2.5.xml | 10 -
.../stacks/HDP/2.3/upgrades/upgrade-2.6.xml | 10 -
.../HDP/2.4/upgrades/nonrolling-upgrade-2.4.xml | 17 --
.../HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml | 18 --
.../HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml | 18 --
.../stacks/HDP/2.4/upgrades/upgrade-2.4.xml | 10 -
.../stacks/HDP/2.4/upgrades/upgrade-2.5.xml | 10 -
.../stacks/HDP/2.4/upgrades/upgrade-2.6.xml | 10 -
.../stacks/HDP/2.5/upgrades/host-upgrade-2.5.xml | 3 +-
.../HDP/2.5/upgrades/nonrolling-upgrade-2.5.xml | 17 --
.../HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml | 17 --
.../stacks/HDP/2.5/upgrades/upgrade-2.5.xml | 10 -
.../stacks/HDP/2.5/upgrades/upgrade-2.6.xml | 10 -
.../PERF/1.0/upgrades/nonrolling-upgrade-2.0.xml | 2 +-
.../stacks/PERF/1.0/upgrades/upgrade-2.0.xml | 2 +-
ambari-server/src/test/python/TestStackFeature.py | 10 +-
ambari-server/src/test/python/TestStackSelect.py | 4 +
.../src/test/python/TestUpgradeSummary.py | 4 +
..._ru_set_all.py => test_stack_select_set_all.py} | 225 +++++++++++----------
.../upgrades/upgrade_nonrolling_new_stack.xml | 4 +-
.../HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml | 2 +-
.../stacks/HDP/2.2.0/upgrades/upgrade_test.xml | 2 +-
.../HDP/2.2.0/upgrades/upgrade_test_15388.xml | 2 +-
.../HDP/2.2.0/upgrades/upgrade_test_15388.xml | 2 +-
34 files changed, 204 insertions(+), 428 deletions(-)
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py b/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py
index 0b30067..e6da97f 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py
@@ -22,7 +22,7 @@ from collections import namedtuple
from resource_management.libraries.script.script import Script
from resource_management.libraries.functions.constants import Direction
-UpgradeSummary = namedtuple("UpgradeSummary", "type direction orchestration is_revert services is_downgrade_allowed is_switch_bits")
+UpgradeSummary = namedtuple("UpgradeSummary", "type direction orchestration is_revert services is_downgrade_allowed is_switch_bits associated_stack associated_version")
UpgradeServiceSummary = namedtuple("UpgradeServiceSummary", "service_name source_stack source_version target_stack target_version")
@@ -102,7 +102,9 @@ def get_upgrade_summary():
orchestration=upgrade_summary["orchestration"], is_revert = upgrade_summary["isRevert"],
services = service_summary_dict,
is_downgrade_allowed=upgrade_summary["isDowngradeAllowed"],
- is_switch_bits=upgrade_summary["isSwitchBits"])
+ is_switch_bits=upgrade_summary["isSwitchBits"],
+ associated_stack=upgrade_summary["associatedStackId"],
+ associated_version = upgrade_summary["associatedVersion"])
def get_downgrade_from_version(service_name = None):
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
index ae3e2f9..fe72c53 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
@@ -105,7 +105,7 @@ public class HostStackVersionResourceProvider extends AbstractControllerResource
protected static final String COMPONENT_NAME_PROPERTY_ID = "name";
protected static final String INSTALL_PACKAGES_ACTION = "install_packages";
- protected static final String STACK_SELECT_ACTION = "ru_set_all";
+ protected static final String STACK_SELECT_ACTION = "stack_select_set_all";
protected static final String INSTALL_PACKAGES_FULL_NAME = "Install Version";
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
index c016bc6..b13aaf9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
@@ -971,6 +971,10 @@ public class UpgradeContext {
summary.isDowngradeAllowed = isDowngradeAllowed();
+ summary.associatedRepositoryId = m_repositoryVersion.getId();
+ summary.associatedStackId = m_repositoryVersion.getStackId().getStackId();
+ summary.associatedVersion = m_repositoryVersion.getVersion();
+
// !!! a) if we are reverting, that can only happen via PATCH or MAINT
// b) if orchestration is a revertible type (on upgrade)
summary.isSwitchBits = m_isRevert || m_orchestration.isRevertable();
@@ -1441,6 +1445,33 @@ public class UpgradeContext {
public Map<String, UpgradeServiceSummary> services;
/**
+ * The ID of the repository associated with the upgrade. For an
+ * {@link Direction#UPGRADE}, this is the target repository, for a
+ * {@link Direction#DOWNGRADE} this was the repository being downgraded
+ * from.
+ */
+ @SerializedName("associatedRepositoryId")
+ public long associatedRepositoryId;
+
+ /**
+ * The ID of the repository associated with the upgrade. For an
+ * {@link Direction#UPGRADE}, this is the target stack, for a
+ * {@link Direction#DOWNGRADE} this was the stack that is being downgraded
+ * from.
+ */
+ @SerializedName("associatedStackId")
+ public String associatedStackId;
+
+ /**
+ * The ID of the repository associated with the upgrade. For an
+ * {@link Direction#UPGRADE}, this is the target versopm, for a
+ * {@link Direction#DOWNGRADE} this was the version that is being downgraded
+ * from.
+ */
+ @SerializedName("associatedVersion")
+ public String associatedVersion;
+
+ /**
* MAINT or PATCH upgrades are meant to just be switching the bits and no other
* incompatible changes.
*/
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py b/ambari-server/src/main/resources/custom_actions/scripts/stack_select_set_all.py
similarity index 52%
rename from ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
rename to ambari-server/src/main/resources/custom_actions/scripts/stack_select_set_all.py
index ef9ea29..ed9a1b0 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/ru_set_all.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/stack_select_set_all.py
@@ -21,20 +21,14 @@ Ambari Agent
"""
import os
-import shutil
import socket
from ambari_commons.os_check import OSCheck
from resource_management.libraries.script import Script
-from resource_management.libraries.functions import conf_select
from resource_management.libraries.functions import stack_tools
-from resource_management.libraries.functions.default import default
-from resource_management.libraries.functions.version import format_stack_version
+from resource_management.libraries.functions import upgrade_summary
+from resource_management.libraries.functions.constants import Direction
from resource_management.core import shell
-from resource_management.core.exceptions import Fail
from resource_management.core.logger import Logger
-from resource_management.core.resources.system import Execute, Link, Directory
-from resource_management.libraries.functions.stack_features import check_stack_feature
-from resource_management.libraries.functions import StackFeature
from resource_management.libraries.functions.decorator import experimental
class UpgradeSetAll(Script):
@@ -42,48 +36,49 @@ class UpgradeSetAll(Script):
This script is a part of stack upgrade workflow and is used to set the
all of the component versions as a final step in the upgrade process
"""
- @experimental(feature="PATCH_UPGRADES", disable = True, comment = "Skipping stack-select set all")
+ @experimental(feature="PATCH_UPGRADES", disable = False, comment = "The stack-select tool will only be invoked if this is a standard upgrade which cannot be downgraded.")
def actionexecute(self, env):
- version = default('/commandParams/version', None)
+ summary = upgrade_summary.get_upgrade_summary()
+ if summary is None:
+ Logger.warning("There is no upgrade in progress")
+ return
+
+ if summary.associated_version is None:
+ Logger.warning("There is no version associated with the upgrade in progress")
+ return
+
+ if summary.orchestration != "STANDARD":
+ Logger.warning("The 'stack-select set all' command can only be invoked during STANDARD upgrades")
+ return
+
+ if summary.direction.lower() != Direction.UPGRADE or summary.is_downgrade_allowed or summary.is_revert:
+ Logger.warning("The 'stack-select set all' command can only be invoked during an UPGRADE which cannot be downgraded")
+ return
- if not version:
- raise Fail("Value is required for '/commandParams/version'")
-
# other os?
if OSCheck.is_redhat_family():
cmd = ('/usr/bin/yum', 'clean', 'all')
code, out = shell.call(cmd, sudo=True)
- formatted_version = format_stack_version(version)
- if not formatted_version:
- raise Fail("Unable to determine a properly formatted stack version from {0}".format(version))
-
stack_selector_path = stack_tools.get_stack_tool_path(stack_tools.STACK_SELECTOR_NAME)
# this script runs on all hosts; if this host doesn't have stack components,
# then don't invoke the stack tool
# (no need to log that it's skipped - the function will do that)
- if is_host_skippable(stack_selector_path, formatted_version):
+ if is_host_skippable(stack_selector_path):
return
# invoke "set all"
- cmd = ('ambari-python-wrap', stack_selector_path, 'set', 'all', version)
+ cmd = ('ambari-python-wrap', stack_selector_path, 'set', 'all', summary.associated_version)
code, out = shell.call(cmd, sudo=True)
if code != 0:
raise Exception("Command '{0}' exit code is nonzero".format(cmd))
- if check_stack_feature(StackFeature.CONFIG_VERSIONING, formatted_version):
- # backup the old and symlink /etc/[component]/conf to <stack-root>/current/[component]
- for k, v in conf_select.get_package_dirs().iteritems():
- for dir_def in v:
- link_config(dir_def['conf_dir'], dir_def['current_dir'])
-
-def is_host_skippable(stack_selector_path, formatted_version):
+def is_host_skippable(stack_selector_path):
"""
Gets whether this host should not have the stack select tool called.
:param stack_selector_path the path to the stack selector tool.
- :param formatted_version: the version to use with the stack selector tool.
:return: True if this host should be skipped, False otherwise.
"""
if not os.path.exists(stack_selector_path):
@@ -110,42 +105,5 @@ def is_host_skippable(stack_selector_path, formatted_version):
return False
-def link_config(old_conf, link_conf):
- """
- Creates a config link following:
- 1. Checks if the old_conf location exists
- 2. If it does, check if it's a link already
- 3. Make a copy to /etc/[component]/conf.backup
- 4. Remove the old directory and create a symlink to link_conf
-
- :old_conf: the old config directory, ie /etc/[component]/conf
- :link_conf: the new target for the config directory, ie <stack-root>/current/[component-dir]/conf
- """
- if os.path.islink(old_conf):
- # if the link exists but is wrong, then change it
- if os.path.realpath(old_conf) != link_conf:
- Link(old_conf, to = link_conf)
- else:
- Logger.debug("Skipping {0}; it is already a link".format(old_conf))
- return
-
- if not os.path.exists(old_conf):
- Logger.debug("Skipping {0}; it does not exist".format(old_conf))
- return
-
- old_parent = os.path.abspath(os.path.join(old_conf, os.pardir))
-
- Logger.info("Linking {0} to {1}".format(old_conf, link_conf))
-
- old_conf_copy = os.path.join(old_parent, "conf.backup")
- if not os.path.exists(old_conf_copy):
- Execute(("cp", "-R", "-p", old_conf, old_conf_copy), sudo=True, logoutput=True)
-
- shutil.rmtree(old_conf, ignore_errors=True)
-
- # link /etc/[component]/conf -> <stack-root>/current/[component]-client/conf
- Link(old_conf, to = link_conf)
-
-
if __name__ == "__main__":
UpgradeSetAll().execute()
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
index f48751a..f43e131 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
@@ -305,23 +305,6 @@
</group>
- <!--
- Invoke "hdp-select set all" to change any components we may have missed
- that are installed on the hosts but not known by Ambari.
- -->
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All Hosts">
- <scope>COMPLETE</scope>
- <skippable>true</skippable>
- <supports-auto-skip-failure>false</supports-auto-skip-failure>
-
- <execute-stage title="Update stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<!-- Now, restart all of the services. -->
<group xsi:type="restart" name="ZOOKEEPER" title="ZooKeeper">
<service-check>false</service-check>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.4.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.4.xml
index 214e80d..47afa38 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.4.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.4.xml
@@ -449,23 +449,6 @@
</group>
- <!--
- Invoke "hdp-select set all" to change any components we may have missed
- that are installed on the hosts but not known by Ambari.
- -->
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All Hosts">
- <scope>COMPLETE</scope>
- <skippable>true</skippable>
- <supports-auto-skip-failure>false</supports-auto-skip-failure>
-
- <execute-stage title="Update stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<!-- Now, restart all of the services. -->
<group xsi:type="restart" name="ZOOKEEPER" title="ZooKeeper">
<service-check>false</service-check>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
index f006cf5..1fc8573 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
@@ -605,23 +605,6 @@
</execute-stage>
</group>
- <!--
- Invoke "hdp-select set all" to change any components we may have missed
- that are installed on the hosts but not known by Ambari.
- -->
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All Hosts">
- <scope>COMPLETE</scope>
- <skippable>true</skippable>
- <supports-auto-skip-failure>false</supports-auto-skip-failure>
-
- <execute-stage title="Update stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<!-- Now, restart all of the services. -->
<group xsi:type="restart" name="ZOOKEEPER" title="ZooKeeper">
<service-check>false</service-check>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml
index 5b701c1..bde3665 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml
@@ -707,23 +707,6 @@
</execute-stage>
</group>
- <!--
- Invoke "hdp-select set all" to change any components we may have missed
- that are installed on the hosts but not known by Ambari.
- -->
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All Hosts">
- <scope>COMPLETE</scope>
- <skippable>true</skippable>
- <supports-auto-skip-failure>false</supports-auto-skip-failure>
-
- <execute-stage title="Update stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<!-- Now, restart all of the services. -->
<group xsi:type="restart" name="ZOOKEEPER" title="ZooKeeper">
<service-check>false</service-check>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
index 5146b7b..f8d17c2 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
@@ -381,16 +381,6 @@
</service>
</group>
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
- <scope>COMPLETE</scope>
- <execute-stage title="Update remaining HDP stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<group xsi:type="cluster" name="FINALIZE_PRE_CHECK" title="Finalize {{direction.text.proper}} Pre-Check">
<direction>UPGRADE</direction>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
index d159ce0..3a9e516 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
@@ -426,16 +426,6 @@
</service>
</group>
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
- <scope>COMPLETE</scope>
- <execute-stage title="Update remaining HDP stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<group xsi:type="cluster" name="FINALIZE_PRE_CHECK" title="Finalize {{direction.text.proper}} Pre-Check">
<direction>UPGRADE</direction>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
index ad9221d..53a2db6 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
@@ -494,16 +494,6 @@
</service>
</group>
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
- <scope>COMPLETE</scope>
- <execute-stage title="Update remaining HDP stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<group xsi:type="cluster" name="FINALIZE_PRE_CHECK" title="Finalize {{direction.text.proper}} Pre-Check">
<direction>UPGRADE</direction>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml
index a4e6a26..8824c74 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml
@@ -497,16 +497,6 @@
</service>
</group>
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
- <scope>COMPLETE</scope>
- <execute-stage title="Update remaining HDP stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<group xsi:type="cluster" name="FINALIZE_PRE_CHECK" title="Finalize {{direction.text.proper}} Pre-Check">
<direction>UPGRADE</direction>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.4.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.4.xml
index af282f9..2f47a41 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.4.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.4.xml
@@ -294,23 +294,6 @@
</execute-stage>
</group>
- <!--
- Invoke "hdp-select set all" to change any components we may have missed
- that are installed on the hosts but not known by Ambari.
- -->
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All Hosts">
- <scope>COMPLETE</scope>
- <skippable>true</skippable>
- <supports-auto-skip-failure>false</supports-auto-skip-failure>
-
- <execute-stage title="Update stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<!-- Now, restart all of the services. -->
<group xsi:type="restart" name="ZOOKEEPER" title="ZooKeeper">
<service-check>false</service-check>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
index 8d73638..443c129 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
@@ -564,24 +564,6 @@
</execute-stage>
</group>
- <!--
- Invoke "hdp-select set all" to change any components we may have missed
- that are installed on the hosts but not known by Ambari.
- -->
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All Hosts">
- <scope>COMPLETE</scope>
- <skippable>true</skippable>
- <supports-auto-skip-failure>false</supports-auto-skip-failure>
-
- <execute-stage title="Update stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
-
<!-- Now, restart all of the services. -->
<group xsi:type="restart" name="ZOOKEEPER" title="ZooKeeper">
<service-check>false</service-check>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml
index 4299f46..55de1c0 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml
@@ -661,24 +661,6 @@
</execute-stage>
</group>
- <!--
- Invoke "hdp-select set all" to change any components we may have missed
- that are installed on the hosts but not known by Ambari.
- -->
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All Hosts">
- <scope>COMPLETE</scope>
- <skippable>true</skippable>
- <supports-auto-skip-failure>false</supports-auto-skip-failure>
-
- <execute-stage title="Update stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
-
<!-- Now, restart all of the services. -->
<group xsi:type="restart" name="ZOOKEEPER" title="ZooKeeper">
<service-check>false</service-check>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml
index 6948a27..2e03e68 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml
@@ -377,16 +377,6 @@
</service>
</group>
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
- <scope>COMPLETE</scope>
- <execute-stage title="Update remaining HDP stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<group xsi:type="cluster" name="FINALIZE_PRE_CHECK" title="Finalize {{direction.text.proper}} Pre-Check">
<direction>UPGRADE</direction>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
index ac69e2f..c6b38eb 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
@@ -479,16 +479,6 @@
</service>
</group>
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
- <scope>COMPLETE</scope>
- <execute-stage title="Update remaining HDP stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<group xsi:type="cluster" name="FINALIZE_PRE_CHECK" title="Finalize {{direction.text.proper}} Pre-Check">
<direction>UPGRADE</direction>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml
index 048a634..aa0b24b 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml
@@ -486,16 +486,6 @@
</service>
</group>
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
- <scope>COMPLETE</scope>
- <execute-stage title="Update remaining HDP stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<group xsi:type="cluster" name="FINALIZE_PRE_CHECK" title="Finalize {{direction.text.proper}} Pre-Check">
<direction>UPGRADE</direction>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/host-upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/host-upgrade-2.5.xml
index dda3ee6..1cc3f42 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/host-upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/host-upgrade-2.5.xml
@@ -80,9 +80,10 @@
<group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
<scope>COMPLETE</scope>
+ <direction>UPGRADE</direction>
<execute-stage title="Update remaining HDP stack to {{version}}">
<task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
+ <script>scripts/stack_select_set_all.py</script>
<function>actionexecute</function>
</task>
</execute-stage>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.5.xml
index 1042795..4f804c4 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.5.xml
@@ -358,23 +358,6 @@
</execute-stage>
</group>
- <!--
- Invoke "hdp-select set all" to change any components we may have missed
- that are installed on the hosts but not known by Ambari.
- -->
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All Hosts">
- <scope>COMPLETE</scope>
- <skippable>true</skippable>
- <supports-auto-skip-failure>false</supports-auto-skip-failure>
-
- <execute-stage title="Update stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<!-- Now, restart all of the services. -->
<group xsi:type="restart" name="ZOOKEEPER" title="ZooKeeper">
<service-check>false</service-check>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
index a3961ea..8b8d6f5 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
@@ -722,23 +722,6 @@
</execute-stage>
</group>
- <!--
- Invoke "hdp-select set all" to change any components we may have missed
- that are installed on the hosts but not known by Ambari.
- -->
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All Hosts">
- <scope>COMPLETE</scope>
- <skippable>true</skippable>
- <supports-auto-skip-failure>false</supports-auto-skip-failure>
-
- <execute-stage title="Update stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<!-- Now, restart all of the services. -->
<group xsi:type="restart" name="ZOOKEEPER" title="ZooKeeper">
<service-check>false</service-check>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml
index 5a2a72a..e4ea566 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml
@@ -421,16 +421,6 @@
</service>
</group>
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
- <scope>COMPLETE</scope>
- <execute-stage title="Update remaining HDP stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<group xsi:type="cluster" name="FINALIZE_PRE_CHECK" title="Finalize {{direction.text.proper}} Pre-Check">
<direction>UPGRADE</direction>
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.6.xml
index 5437370..22f5260 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.6.xml
@@ -446,16 +446,6 @@
</service>
</group>
- <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
- <scope>COMPLETE</scope>
- <execute-stage title="Update remaining HDP stack to {{version}}">
- <task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
- <function>actionexecute</function>
- </task>
- </execute-stage>
- </group>
-
<group xsi:type="cluster" name="FINALIZE_PRE_CHECK" title="Finalize {{direction.text.proper}} Pre-Check">
<direction>UPGRADE</direction>
diff --git a/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/nonrolling-upgrade-2.0.xml b/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/nonrolling-upgrade-2.0.xml
index 5d24ff8..9d32906 100644
--- a/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/nonrolling-upgrade-2.0.xml
+++ b/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/nonrolling-upgrade-2.0.xml
@@ -101,7 +101,7 @@
<execute-stage title="Update stack to {{version}}">
<task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
+ <script>scripts/stack_select_set_all.py</script>
<function>actionexecute</function>
</task>
</execute-stage>
diff --git a/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/upgrade-2.0.xml b/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/upgrade-2.0.xml
index 9c9cebb..62fcc54 100644
--- a/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/upgrade-2.0.xml
+++ b/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/upgrade-2.0.xml
@@ -147,7 +147,7 @@
<group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
<execute-stage title="Update remaining HDP stack to {{version}}">
<task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
+ <script>scripts/stack_select_set_all.py</script>
<function>actionexecute</function>
</task>
</execute-stage>
diff --git a/ambari-server/src/test/python/TestStackFeature.py b/ambari-server/src/test/python/TestStackFeature.py
index 09d2d8c..8e584b1 100644
--- a/ambari-server/src/test/python/TestStackFeature.py
+++ b/ambari-server/src/test/python/TestStackFeature.py
@@ -196,6 +196,8 @@ class TestStackFeature(TestCase):
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
+ "associatedStackId":"HDP-2.5",
+ "associatedVersion":"2.5.9.9-9999",
"isDowngradeAllowed": True,
"isSwitchBits": False
}
@@ -235,6 +237,8 @@ class TestStackFeature(TestCase):
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
+ "associatedStackId":"HDP-2.5",
+ "associatedVersion":"2.5.9.9-9999",
"isDowngradeAllowed": True,
"isSwitchBits": False
}
@@ -275,6 +279,8 @@ class TestStackFeature(TestCase):
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
+ "associatedStackId":"HDP-2.5",
+ "associatedVersion":"2.5.9.9-9999",
"isDowngradeAllowed": True,
"isSwitchBits": False
}
@@ -314,7 +320,9 @@ class TestStackFeature(TestCase):
"direction":"DOWNGRADE",
"type":"rolling_upgrade",
"isRevert":False,
- "orchestration":"STANDARD"
+ "orchestration":"STANDARD",
+ "associatedStackId":"HDP-2.5",
+ "associatedVersion":"2.5.9.9-9999"
}
}
diff --git a/ambari-server/src/test/python/TestStackSelect.py b/ambari-server/src/test/python/TestStackSelect.py
index f8c5b8b..462d3a0 100644
--- a/ambari-server/src/test/python/TestStackSelect.py
+++ b/ambari-server/src/test/python/TestStackSelect.py
@@ -161,6 +161,8 @@ class TestStackSelect(TestCase):
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
+ "associatedStackId":"HDP-2.5",
+ "associatedVersion":"2.5.9.9-9999",
"isDowngradeAllowed": True,
"isSwitchBits": False
}
@@ -201,6 +203,8 @@ class TestStackSelect(TestCase):
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
+ "associatedStackId":"HDP-2.5",
+ "associatedVersion":"2.5.9.9-9999",
"isDowngradeAllowed": True,
"isSwitchBits": False
}
diff --git a/ambari-server/src/test/python/TestUpgradeSummary.py b/ambari-server/src/test/python/TestUpgradeSummary.py
index a117f1a..e2bc2c5 100644
--- a/ambari-server/src/test/python/TestUpgradeSummary.py
+++ b/ambari-server/src/test/python/TestUpgradeSummary.py
@@ -97,6 +97,8 @@ class TestUpgradeSummary(TestCase):
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
+ "associatedStackId":"HDP-2.5",
+ "associatedVersion":"2.5.9.9-9999",
"isDowngradeAllowed": True,
"isSwitchBits": False
}
@@ -135,6 +137,8 @@ class TestUpgradeSummary(TestCase):
"type":"rolling_upgrade",
"isRevert":False,
"orchestration":"STANDARD",
+ "associatedStackId":"HDP-2.5",
+ "associatedVersion":"2.5.9.9-9999",
"isDowngradeAllowed": True,
"isSwitchBits": False
}
diff --git a/ambari-server/src/test/python/custom_actions/test_ru_set_all.py b/ambari-server/src/test/python/custom_actions/test_stack_select_set_all.py
similarity index 64%
rename from ambari-server/src/test/python/custom_actions/test_ru_set_all.py
rename to ambari-server/src/test/python/custom_actions/test_stack_select_set_all.py
index 6421397..b2b10c6 100644
--- a/ambari-server/src/test/python/custom_actions/test_ru_set_all.py
+++ b/ambari-server/src/test/python/custom_actions/test_stack_select_set_all.py
@@ -46,7 +46,7 @@ def fake_call(command, **kwargs):
"""
return (0, str(command))
-class TestRUSetAll(RMFTestCase):
+class TestStackSelectSetAll(RMFTestCase):
def get_custom_actions_dir(self):
return os.path.join(self.get_src_folder(), "test/resources/custom_actions/")
@@ -58,10 +58,8 @@ class TestRUSetAll(RMFTestCase):
# Import the class under test. This is done here as opposed to the rest of the imports because the get_os_type()
# method needs to be patched first.
- from ru_set_all import UpgradeSetAll
+ from stack_select_set_all import UpgradeSetAll
global UpgradeSetAll
- from ru_set_all import link_config
- global link_config
def tearDown(self):
Logger.logger = None
@@ -80,6 +78,7 @@ class TestRUSetAll(RMFTestCase):
json_payload["configurations"]["cluster-env"]["stack_tools"] = self.get_stack_tools()
json_payload["configurations"]["cluster-env"]["stack_features"] = self.get_stack_features()
+ json_payload["upgradeSummary"] = TestStackSelectSetAll._get_upgrade_summary_no_downgrade()["upgradeSummary"]
config_dict = ConfigDictionary(json_payload)
@@ -101,62 +100,69 @@ class TestRUSetAll(RMFTestCase):
ru_execute = UpgradeSetAll()
ru_execute.actionexecute(None)
- call_mock.assert_called_with(('ambari-python-wrap', '/usr/bin/hdp-select', 'set', 'all', u'2.2.1.0-2260'), sudo=True)
+ call_mock.assert_called_with(('ambari-python-wrap', '/usr/bin/hdp-select', 'set', 'all', u'2.5.9.9-9999'), sudo=True)
+
@patch("os.path.exists")
@patch("resource_management.core.shell.call")
@patch.object(Script, 'get_config')
@patch.object(OSCheck, 'is_redhat_family')
- @patch("ru_set_all.link_config")
- def test_execution_23(self, link_mock, family_mock, get_config_mock, call_mock, exists_mock):
+ def test_skippable_hosts(self, family_mock, get_config_mock, call_mock, exists_mock):
+ """
+ Tests that hosts are skippable if they don't have stack components installed
+ :return:
+ """
# Mock the config objects
- json_file_path = os.path.join(self.get_custom_actions_dir(), "ru_execute_tasks_namenode_prepare.json")
+ json_file_path = os.path.join(self.get_custom_actions_dir(),
+ "ru_execute_tasks_namenode_prepare.json")
self.assertTrue(os.path.isfile(json_file_path))
+
with open(json_file_path, "r") as json_file:
json_payload = json.load(json_file)
- json_payload['clusterLevelParams']['stack_name'] = "HDP"
- json_payload['clusterLevelParams']['stack_version'] = "2.3"
- json_payload['commandParams']['version'] = "2.3.0.0-1234"
json_payload["configurations"]["cluster-env"]["stack_tools"] = self.get_stack_tools()
json_payload["configurations"]["cluster-env"]["stack_features"] = self.get_stack_features()
- json_payload["configurations"]["cluster-env"]["stack_packages"] = self.get_stack_packages()
+ json_payload["upgradeSummary"] = TestStackSelectSetAll._get_upgrade_summary_no_downgrade()["upgradeSummary"]
config_dict = ConfigDictionary(json_payload)
- family_mock.return_value = True
+ family_mock.return_value = False
get_config_mock.return_value = config_dict
- call_mock.side_effect = fake_call # echo the command
exists_mock.return_value = True
+ def hdp_select_call(command, **kwargs):
+ # return no versions
+ if "versions" in command:
+ return (0,"")
+
+ return (0,command)
+
+ call_mock.side_effect = hdp_select_call
+
# Ensure that the json file was actually read.
stack_name = default("/clusterLevelParams/stack_name", None)
stack_version = default("/clusterLevelParams/stack_version", None)
service_package_folder = default('/roleParams/service_package_folder', None)
self.assertEqual(stack_name, "HDP")
- self.assertEqual(stack_version, '2.3')
+ self.assertEqual(stack_version, '2.2')
self.assertEqual(service_package_folder, "common-services/HDFS/2.1.0.2.0/package")
# Begin the test
ru_execute = UpgradeSetAll()
ru_execute.actionexecute(None)
- self.assertTrue(link_mock.called)
- call_mock.assert_called_with(('ambari-python-wrap', '/usr/bin/hdp-select', 'set', 'all', '2.3.0.0-1234'), sudo=True)
+ call_mock.assert_called_with(('ambari-python-wrap', u'/usr/bin/hdp-select', 'versions'), sudo = True)
+ self.assertEqual(call_mock.call_count, 1)
+
@patch("os.path.exists")
@patch("resource_management.core.shell.call")
@patch.object(Script, 'get_config')
@patch.object(OSCheck, 'is_redhat_family')
- def test_skippable_hosts(self, family_mock, get_config_mock, call_mock, exists_mock):
- """
- Tests that hosts are skippable if they don't have stack components installed
- :return:
- """
+ def test_execution_with_downgrade_allowed(self, family_mock, get_config_mock, call_mock, exists_mock):
# Mock the config objects
- json_file_path = os.path.join(self.get_custom_actions_dir(),
- "ru_execute_tasks_namenode_prepare.json")
+ json_file_path = os.path.join(self.get_custom_actions_dir(), "ru_execute_tasks_namenode_prepare.json")
self.assertTrue(os.path.isfile(json_file_path))
with open(json_file_path, "r") as json_file:
@@ -164,21 +170,53 @@ class TestRUSetAll(RMFTestCase):
json_payload["configurations"]["cluster-env"]["stack_tools"] = self.get_stack_tools()
json_payload["configurations"]["cluster-env"]["stack_features"] = self.get_stack_features()
+ json_payload["upgradeSummary"] = TestStackSelectSetAll._get_upgrade_summary_downgrade_allowed()["upgradeSummary"]
config_dict = ConfigDictionary(json_payload)
- family_mock.return_value = False
+ family_mock.return_value = True
get_config_mock.return_value = config_dict
+ call_mock.side_effect = fake_call # echo the command
exists_mock.return_value = True
- def hdp_select_call(command, **kwargs):
- # return no versions
- if "versions" in command:
- return (0,"")
+ # Ensure that the json file was actually read.
+ stack_name = default("/clusterLevelParams/stack_name", None)
+ stack_version = default("/clusterLevelParams/stack_version", None)
+ service_package_folder = default('/roleParams/service_package_folder', None)
- return (0,command)
+ self.assertEqual(stack_name, "HDP")
+ self.assertEqual(stack_version, '2.2')
+ self.assertEqual(service_package_folder, "common-services/HDFS/2.1.0.2.0/package")
- call_mock.side_effect = hdp_select_call
+ # Begin the test
+ ru_execute = UpgradeSetAll()
+ ru_execute.actionexecute(None)
+
+ call_mock.assert_not_called()
+
+
+ @patch("os.path.exists")
+ @patch("resource_management.core.shell.call")
+ @patch.object(Script, 'get_config')
+ @patch.object(OSCheck, 'is_redhat_family')
+ def test_execution_with_patch_upgrade(self, family_mock, get_config_mock, call_mock, exists_mock):
+ # Mock the config objects
+ json_file_path = os.path.join(self.get_custom_actions_dir(), "ru_execute_tasks_namenode_prepare.json")
+ self.assertTrue(os.path.isfile(json_file_path))
+
+ with open(json_file_path, "r") as json_file:
+ json_payload = json.load(json_file)
+
+ json_payload["configurations"]["cluster-env"]["stack_tools"] = self.get_stack_tools()
+ json_payload["configurations"]["cluster-env"]["stack_features"] = self.get_stack_features()
+ json_payload["upgradeSummary"] = TestStackSelectSetAll._get_upgrade_summary_patch_upgrade()["upgradeSummary"]
+
+ config_dict = ConfigDictionary(json_payload)
+
+ family_mock.return_value = True
+ get_config_mock.return_value = config_dict
+ call_mock.side_effect = fake_call # echo the command
+ exists_mock.return_value = True
# Ensure that the json file was actually read.
stack_name = default("/clusterLevelParams/stack_name", None)
@@ -193,80 +231,55 @@ class TestRUSetAll(RMFTestCase):
ru_execute = UpgradeSetAll()
ru_execute.actionexecute(None)
- call_mock.assert_called_with(('ambari-python-wrap', u'/usr/bin/hdp-select', 'versions'), sudo = True)
- self.assertEqual(call_mock.call_count, 1)
+ call_mock.assert_not_called()
- @patch("os.path.exists")
- @patch("os.path.islink")
- @patch("os.path.isdir")
- @patch("os.path.isfile")
- @patch("os.path.realpath")
- @patch("shutil.rmtree")
- def test_link_config(self, shutil_rmtree_mock, os_path_realpath_mock, os_path_isfile_mock,
- os_path_isdir_mock, os_path_islink_mock,
- os_path_exists_mock):
- # Test normal flow
- os_path_islink_mock.return_value = False
- os_path_realpath_mock.return_value = "/some/another/path"
- os_path_exists_mock.side_effect = [True, False]
- old_config = "/old/config"
- link_conf = "/link/config"
-
- with Environment(test_mode=True) as RMFTestCase.env:
- link_config(old_config, link_conf)
- self.assertTrue(shutil_rmtree_mock.called)
- self.assertEquals(shutil_rmtree_mock.call_args_list[0][0][0], old_config)
- self.assertResourceCalled('Execute', ('cp', '-R', '-p', '/old/config', '/old/conf.backup'),
- logoutput = True,
- sudo = True,
- )
- self.assertResourceCalled('Link', '/old/config',
- to = '/link/config',
- )
- self.assertNoMoreResources()
-
- # Test case when link exists but is wrong
- shutil_rmtree_mock.reset_mock()
- os_path_islink_mock.return_value = True
- with Environment(test_mode=True) as RMFTestCase.env:
- link_config(old_config, link_conf)
- self.assertFalse(shutil_rmtree_mock.called)
- self.assertResourceCalled('Link', '/old/config',
- to = '/link/config',
- )
- self.assertNoMoreResources()
-
- # Test case when link exists and is correct
- shutil_rmtree_mock.reset_mock()
- os_path_islink_mock.return_value = True
- os_path_realpath_mock.return_value = link_conf
-
- with Environment(test_mode=True) as RMFTestCase.env:
- link_config(old_config, link_conf)
- self.assertFalse(shutil_rmtree_mock.called)
- self.assertNoMoreResources()
-
- # Test case when old link does not exist at all
- shutil_rmtree_mock.reset_mock()
- os_path_islink_mock.return_value = False
- os_path_exists_mock.side_effect = [False]
-
- with Environment(test_mode=True) as RMFTestCase.env:
- link_config(old_config, link_conf)
- self.assertFalse(shutil_rmtree_mock.called)
- self.assertNoMoreResources()
-
- # Test case when backup directory already exists
- shutil_rmtree_mock.reset_mock()
- os_path_islink_mock.return_value = False
- os_path_exists_mock.side_effect = [True, True]
-
- with Environment(test_mode=True) as RMFTestCase.env:
- link_config(old_config, link_conf)
- self.assertTrue(shutil_rmtree_mock.called)
- self.assertEquals(shutil_rmtree_mock.call_args_list[0][0][0], old_config)
- self.assertResourceCalled('Link', '/old/config',
- to = '/link/config',
- )
- self.assertNoMoreResources()
+ @staticmethod
+ def _get_upgrade_summary_no_downgrade():
+ """
+ A STANDARD UPGRADE that cannot be downgraded
+ :return:
+ """
+ return {
+ "upgradeSummary": {
+ "services":{
+ "HDFS":{
+ "sourceRepositoryId":1,
+ "sourceStackId":"HDP-2.4",
+ "sourceVersion":"2.4.0.0-1234",
+ "targetRepositoryId":2,
+ "targetStackId":"HDP-2.5",
+ "targetVersion":"2.5.9.9-9999"
+ }
+ },
+ "direction":"UPGRADE",
+ "type":"rolling_upgrade",
+ "isRevert":False,
+ "orchestration":"STANDARD",
+ "associatedStack": "HDP-2.5",
+ "associatedVersion":"2.5.9.9-9999",
+ "isDowngradeAllowed": False,
+ "isSwitchBits": False
+ }
+ }
+
+ @staticmethod
+ def _get_upgrade_summary_downgrade_allowed():
+ """
+ A STANDARD UPGRADE that can be downgraded
+ :return:
+ """
+ upgrade_summary = TestStackSelectSetAll._get_upgrade_summary_no_downgrade()
+ upgrade_summary["upgradeSummary"]["isDowngradeAllowed"] = True
+ return upgrade_summary
+
+
+ @staticmethod
+ def _get_upgrade_summary_patch_upgrade():
+ """
+ A STANDARD UPGRADE that can be downgraded
+ :return:
+ """
+ upgrade_summary = TestStackSelectSetAll._get_upgrade_summary_no_downgrade()
+ upgrade_summary["upgradeSummary"]["orchestration"] = "PATCH"
+ return upgrade_summary
\ No newline at end of file
diff --git a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
index 2a1c889..ea3da69 100644
--- a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
+++ b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
@@ -230,7 +230,7 @@
<direction>DOWNGRADE</direction>
<execute-stage title="Restore configuration directories and remove HDP 2.3 symlinks">
<task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
+ <script>scripts/stack_select_set_all.py</script>
<function>foo_function</function>
</task>
</execute-stage>
@@ -574,7 +574,7 @@
<execute-stage title="Update stack to {{version}}">
<task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
+ <script>scripts/stack_select_set_all.py</script>
<function>actionexecute</function>
</task>
</execute-stage>
diff --git a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
index 3dd4bc5..5492c5b 100644
--- a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
+++ b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
@@ -118,7 +118,7 @@
<skippable>true</skippable>
<execute-stage title="Update stack to {{version}}">
<task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
+ <script>scripts/stack_select_set_all.py</script>
<function>actionexecute</function>
</task>
</execute-stage>
diff --git a/ambari-server/src/test/resources/stacks/HDP/2.2.0/upgrades/upgrade_test.xml b/ambari-server/src/test/resources/stacks/HDP/2.2.0/upgrades/upgrade_test.xml
index c819d12..87e534b 100644
--- a/ambari-server/src/test/resources/stacks/HDP/2.2.0/upgrades/upgrade_test.xml
+++ b/ambari-server/src/test/resources/stacks/HDP/2.2.0/upgrades/upgrade_test.xml
@@ -111,7 +111,7 @@
</execute-stage>
<execute-stage title="Update remaining HDP stack to {{version}}">
<task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
+ <script>scripts/stack_select_set_all.py</script>
<function>actionexecute</function>
</task>
</execute-stage>
diff --git a/ambari-server/src/test/resources/stacks/HDP/2.2.0/upgrades/upgrade_test_15388.xml b/ambari-server/src/test/resources/stacks/HDP/2.2.0/upgrades/upgrade_test_15388.xml
index 640ea0a..e5bc420 100644
--- a/ambari-server/src/test/resources/stacks/HDP/2.2.0/upgrades/upgrade_test_15388.xml
+++ b/ambari-server/src/test/resources/stacks/HDP/2.2.0/upgrades/upgrade_test_15388.xml
@@ -122,7 +122,7 @@
</execute-stage>
<execute-stage title="Update remaining HDP stack to {{version}}">
<task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
+ <script>scripts/stack_select_set_all.py</script>
<function>actionexecute</function>
</task>
</execute-stage>
diff --git a/ambari-server/src/test/resources/stacks_with_upgrade_cycle/HDP/2.2.0/upgrades/upgrade_test_15388.xml b/ambari-server/src/test/resources/stacks_with_upgrade_cycle/HDP/2.2.0/upgrades/upgrade_test_15388.xml
index 8a02781..e093509 100644
--- a/ambari-server/src/test/resources/stacks_with_upgrade_cycle/HDP/2.2.0/upgrades/upgrade_test_15388.xml
+++ b/ambari-server/src/test/resources/stacks_with_upgrade_cycle/HDP/2.2.0/upgrades/upgrade_test_15388.xml
@@ -122,7 +122,7 @@
</execute-stage>
<execute-stage title="Update remaining HDP stack to {{version}}">
<task xsi:type="execute">
- <script>scripts/ru_set_all.py</script>
+ <script>scripts/stack_select_set_all.py</script>
<function>actionexecute</function>
</task>
</execute-stage>
--
To stop receiving notification emails like this one, please contact
jonathanhurley@apache.org.