AMBARI-18368. ADDENDUM. Atlas web UI alert after performing stack upgrade to HDP 2.5 and adding Atlas Service (alejandro)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1efc99c5 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1efc99c5 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1efc99c5 Branch: refs/heads/branch-dev-patch-upgrade Commit: 1efc99c5adc536044425b9df45b72421c5a8323c Parents: d5cca62 Author: Alejandro Fernandez <afernan...@hortonworks.com> Authored: Wed Sep 14 18:42:59 2016 -0700 Committer: Alejandro Fernandez <afernan...@hortonworks.com> Committed: Thu Sep 15 14:46:37 2016 -0700 ---------------------------------------------------------------------- .../libraries/functions/conf_select.py | 39 +++++++++++++++++--- .../hooks/after-INSTALL/test_after_install.py | 18 +++++++++ 2 files changed, 52 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/1efc99c5/ambari-common/src/main/python/resource_management/libraries/functions/conf_select.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/conf_select.py b/ambari-common/src/main/python/resource_management/libraries/functions/conf_select.py index c60b324..8d54053 100644 --- a/ambari-common/src/main/python/resource_management/libraries/functions/conf_select.py +++ b/ambari-common/src/main/python/resource_management/libraries/functions/conf_select.py @@ -343,7 +343,27 @@ def select(stack_name, package, version, try_create=True, ignore_errors=False): else: # missing entirely # /etc/<component>/conf -> <stack-root>/current/<component>/conf - Link(conf_dir, to = current_dir) + if package in ["atlas", ]: + #HACK for Atlas + ''' + In the case of Atlas, the Hive RPM installs /usr/$stack/$version/atlas with some partial packages that + contain Hive hooks, while the Atlas RPM is responsible for installing the full content. + + If the user does not have Atlas currently installed on their stack, then /usr/$stack/current/atlas-client + will be a broken symlink, and we should not create the + symlink /etc/atlas/conf -> /usr/$stack/current/atlas-client/conf . + If we mistakenly create this symlink, then when the user performs an EU/RU and then adds Atlas service + then the Atlas RPM will not be able to copy its artifacts into /etc/atlas/conf directory and therefore + prevent Ambari from by copying those unmanaged contents into /etc/atlas/$version/0 + ''' + parent_dir = os.path.dirname(current_dir) + if os.path.exists(parent_dir): + Link(conf_dir, to=current_dir) + else: + Logger.info("Will not create symlink from {0} to {1} because the destination's parent dir does not exist.".format(conf_dir, current_dir)) + else: + # Normal path for other packages + Link(conf_dir, to=current_dir) except Exception, exception: if ignore_errors is True: @@ -579,15 +599,24 @@ def convert_conf_directories_to_symlinks(package, version, dirs, skip_existing_l else: Link(new_symlink, action = "delete") + old_conf = dir_def['conf_dir'] + backup_dir = _get_backup_conf_directory(old_conf) # link /etc/[component]/conf -> /etc/[component]/conf.backup # or # link /etc/[component]/conf -> <stack-root>/current/[component]-client/conf if link_to == DIRECTORY_TYPE_BACKUP: - old_conf = dir_def['conf_dir'] - backup_dir = _get_backup_conf_directory(old_conf) - Link(new_symlink, to = backup_dir) + Link(new_symlink, to=backup_dir) else: - Link(new_symlink, to = dir_def['current_dir']) + Link(new_symlink, to=dir_def['current_dir']) + + #HACK + if package in ["atlas", ]: + Logger.info("Seeding the new conf symlink {0} from the old backup directory {1} in case any " + "unmanaged artifacts are needed.".format(new_symlink, backup_dir)) + # If /etc/[component]/conf.backup exists, then copy any artifacts not managed by Ambari to the new symlink target + # Be careful not to clobber any existing files. + Execute(as_sudo(["cp", "-R", "--no-clobber", os.path.join(backup_dir, "*"), new_symlink], auto_escape=False), + only_if=format("test -e {new_symlink}")) except Exception, e: Logger.warning("Could not change symlink for package {0} to point to {1} directory. Error: {2}".format(package, link_to, e)) http://git-wip-us.apache.org/repos/asf/ambari/blob/1efc99c5/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 434ef51..1bfa173 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 @@ -89,6 +89,7 @@ class TestHookAfterInstall(RMFTestCase): self.assertResourceCalled('Execute', ('cp', '-R', '-p', conf_dir, conf_backup_dir), not_if = 'test -e ' + conf_backup_dir, sudo = True,) + for dir_def in dir_defs: conf_dir = dir_def['conf_dir'] current_dir = dir_def['current_dir'] @@ -97,6 +98,11 @@ class TestHookAfterInstall(RMFTestCase): self.assertResourceCalled('Link', conf_dir, to = current_dir,) + #HACK for Atlas + if package in ["atlas", ]: + self.assertResourceCalled('Execute', 'ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E cp -R --no-clobber /etc/atlas/conf.backup/* /etc/atlas/conf', + only_if = 'test -e ' + "/etc/atlas/conf") + self.assertNoMoreResources() @patch("shared_initialization.load_version", new = MagicMock(return_value="2.3.0.0-1243")) @@ -150,6 +156,7 @@ class TestHookAfterInstall(RMFTestCase): self.assertResourceCalled('Execute', ('cp', '-R', '-p', conf_dir, conf_backup_dir), not_if = 'test -e ' + conf_backup_dir, sudo = True,) + for dir_def in dir_defs: conf_dir = dir_def['conf_dir'] current_dir = dir_def['current_dir'] @@ -158,6 +165,11 @@ class TestHookAfterInstall(RMFTestCase): self.assertResourceCalled('Link', conf_dir, to = current_dir,) + #HACK for Atlas + if package in ["atlas", ]: + self.assertResourceCalled('Execute', 'ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E cp -R --no-clobber /etc/atlas/conf.backup/* /etc/atlas/conf', + only_if = 'test -e ' + "/etc/atlas/conf") + self.assertNoMoreResources() @@ -244,6 +256,7 @@ class TestHookAfterInstall(RMFTestCase): self.assertResourceCalled('Execute', ('cp', '-R', '-p', conf_dir, conf_backup_dir), not_if = 'test -e ' + conf_backup_dir, sudo = True,) + for dir_def in dir_defs: conf_dir = dir_def['conf_dir'] current_dir = dir_def['current_dir'] @@ -252,6 +265,11 @@ class TestHookAfterInstall(RMFTestCase): self.assertResourceCalled('Link', conf_dir, to = current_dir,) + #HACK for Atlas + if package in ["atlas", ]: + self.assertResourceCalled('Execute', 'ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E cp -R --no-clobber /etc/atlas/conf.backup/* /etc/atlas/conf', + only_if = 'test -e ' + "/etc/atlas/conf") + self.assertNoMoreResources()