You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/09/14 18:32:50 UTC
[30/35] ambari git commit: AMBARI-18370. Do not execute
stack-selector-tool after HDP component install on sysprepped hosts.
(stoader)
AMBARI-18370. Do not execute stack-selector-tool after HDP component install on sysprepped hosts. (stoader)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a54d6091
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a54d6091
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a54d6091
Branch: refs/heads/branch-dev-patch-upgrade
Commit: a54d60918b9df11cd0046d2d96203f60b1ecd546
Parents: 02256c3
Author: Toader, Sebastian <st...@hortonworks.com>
Authored: Wed Sep 14 13:52:52 2016 +0200
Committer: Toader, Sebastian <st...@hortonworks.com>
Committed: Wed Sep 14 13:52:52 2016 +0200
----------------------------------------------------------------------
.../main/resources/scripts/Ambaripreupload.py | 11 +++++-
.../2.0.6/hooks/after-INSTALL/scripts/params.py | 1 +
.../scripts/shared_initialization.py | 3 ++
.../hooks/after-INSTALL/test_after_install.py | 35 ++++++++++++++++++++
4 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/a54d6091/ambari-server/src/main/resources/scripts/Ambaripreupload.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/scripts/Ambaripreupload.py b/ambari-server/src/main/resources/scripts/Ambaripreupload.py
index 9492e17..09dcd7e 100644
--- a/ambari-server/src/main/resources/scripts/Ambaripreupload.py
+++ b/ambari-server/src/main/resources/scripts/Ambaripreupload.py
@@ -417,4 +417,13 @@ with Environment() as env:
except:
os.remove("/var/lib/ambari-agent/data/.hdfs_resource_ignore")
raise
- print "Completed tarball copy. Ambari preupload script completed."
+ print "Completed tarball copy."
+
+ if not options.upgrade:
+ print "Executing stack-selector-tool for stack {0} ...".format(stack_version)
+ Execute(
+ ('/usr/bin/hdp-select', 'set', 'all', stack_version),
+ sudo = True
+ )
+
+ print "Ambari preupload script completed."
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/a54d6091/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/params.py
index 819d8f7..ed34217 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/params.py
@@ -33,6 +33,7 @@ tmp_dir = Script.get_tmp_dir()
dfs_type = default("/commandParams/dfs_type", "")
is_parallel_execution_enabled = int(default("/agentConfigParams/agent/parallel_execution", 0)) == 1
+host_sys_prepped = default("/hostLevelParams/host_sys_prepped", False)
sudo = AMBARI_SUDO_BINARY
http://git-wip-us.apache.org/repos/asf/ambari/blob/a54d6091/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/shared_initialization.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/shared_initialization.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/shared_initialization.py
index 9982dc6..e9f2283 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/shared_initialization.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/shared_initialization.py
@@ -44,6 +44,9 @@ def setup_stack_symlinks():
version = params.current_version if params.current_version is not None else params.stack_version_unformatted
if not params.upgrade_suspended:
+ if params.host_sys_prepped:
+ Logger.warning("Skipping running stack-selector-tool for stack {0} as its a sys_prepped host. This may cause symlink pointers not to be created for HDP componets installed later on top of an already sys_prepped host.".format(version))
+ return
# On parallel command execution this should be executed by a single process at a time.
with FcntlBasedProcessLock(params.stack_select_lock_file, enabled = params.is_parallel_execution_enabled, skip_fcntl_failures = True):
stack_select.select_all(version)
http://git-wip-us.apache.org/repos/asf/ambari/blob/a54d6091/ambari-server/src/test/python/stacks/2.0.6/hooks/after-INSTALL/test_after_install.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/hooks/after-INSTALL/test_after_install.py b/ambari-server/src/test/python/stacks/2.0.6/hooks/after-INSTALL/test_after_install.py
index 06a366e..434ef51 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/hooks/after-INSTALL/test_after_install.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/hooks/after-INSTALL/test_after_install.py
@@ -253,3 +253,38 @@ class TestHookAfterInstall(RMFTestCase):
to = current_dir,)
self.assertNoMoreResources()
+
+
+ @patch("resource_management.core.Logger.warning")
+ @patch("shared_initialization.load_version", new = MagicMock(return_value="2.3.0.0-1243"))
+ @patch("resource_management.libraries.functions.conf_select.create")
+ @patch("resource_management.libraries.functions.conf_select.select")
+ @patch("os.symlink")
+ @patch("shutil.rmtree")
+ def test_hook_setup_stack_symlinks_skipped(self, rmtree_mock, symlink_mock, conf_select_select_mock, conf_select_create_mock, logger_warning_mock):
+ """
+ Tests that <stack-selector-tool> set all is not called on sys_prepped hosts
+ :return:
+ """
+
+ def mocked_conf_select(arg1, arg2, arg3, dry_run = False):
+ return "/etc/{0}/{1}/0".format(arg2, arg3)
+
+ conf_select_create_mock.side_effect = mocked_conf_select
+
+ config_file = self.get_src_folder() + "/test/python/stacks/2.0.6/configs/default.json"
+ with open(config_file, "r") as f:
+ json_content = json.load(f)
+
+ version = '2.3.0.0-1234'
+ json_content['commandParams']['version'] = version
+ json_content['hostLevelParams']['stack_version'] = "2.3"
+ json_content['hostLevelParams']['current_version'] = "2.3.0.0-1234"
+ json_content['hostLevelParams']['host_sys_prepped'] = "true"
+
+ self.executeScript("2.0.6/hooks/after-INSTALL/scripts/hook.py",
+ classname="AfterInstallHook",
+ command="hook",
+ config_dict = json_content)
+
+ logger_warning_mock.assert_any_call('Skipping running stack-selector-tool for stack 2.3.0.0-1234 as its a sys_prepped host. This may cause symlink pointers not to be created for HDP componets installed later on top of an already sys_prepped host.')