From fdb49b002b317a52f79347a568173f8a54c511bb Mon Sep 17 00:00:00 2001 From: ramishra Date: Thu, 11 Mar 2021 00:53:28 +0530 Subject: [PATCH] [stable-only] Fix legacy password handling We pick some of heat legacy passwords (from heat resources), while generating the passwords. However, if the plan has been deleted from some reason and does not have the old passwords as in the stack environment, this would result in change of these passwords like RabbitCookie/PcsdPassword and would lead to disruptions during deployment. This patch fixes to only use them if they are not in the stack environment. This code has been removed from master after plan removal. Closes-Bug: #1918566 Change-Id: I6b2f0ef916a950fe6f92ee4f8848bab92a7b1c85 --- tripleo_common/tests/utils/test_plan.py | 3 +++ tripleo_common/utils/plan.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tripleo_common/tests/utils/test_plan.py b/tripleo_common/tests/utils/test_plan.py index 8a6a9df9b..b90b211af 100644 --- a/tripleo_common/tests/utils/test_plan.py +++ b/tripleo_common/tests/utils/test_plan.py @@ -907,6 +907,7 @@ class PlanTest(base.TestCase): existing_passwords = _EXISTING_PASSWORDS.copy() existing_passwords.pop("AdminPassword") + existing_passwords.pop("PcsdPassword") swift = mock.MagicMock(url="http://test.com") mock_env = yaml.safe_dump({ @@ -923,6 +924,7 @@ class PlanTest(base.TestCase): mock_orchestration.stacks.environment.return_value = { 'parameter_defaults': { 'AdminPassword': 'ExistingPasswordInHeat', + 'PcsdPassword': 'MyPassword' } } @@ -938,6 +940,7 @@ class PlanTest(base.TestCase): result = plan_utils.generate_passwords(swift, mock_orchestration) existing_passwords["AdminPassword"] = "ExistingPasswordInHeat" + existing_passwords["PcsdPassword"] = "MyPassword" # ensure old passwords used and no new generation self.assertEqual(existing_passwords, result) mock_cache.assert_called_once_with( diff --git a/tripleo_common/utils/plan.py b/tripleo_common/utils/plan.py index d9b04009c..e648923f9 100644 --- a/tripleo_common/utils/plan.py +++ b/tripleo_common/utils/plan.py @@ -408,9 +408,10 @@ def generate_passwords(swift, heat, mistral=None, # We don't modify these to avoid changing defaults for pw_res in constants.LEGACY_HEAT_PASSWORD_RESOURCE_NAMES: try: - res = heat.resources.get(container, pw_res) param_defaults = stack_env.get('parameter_defaults', {}) - param_defaults[pw_res] = res.attributes['value'] + if pw_res not in param_defaults: + res = heat.resources.get(container, pw_res) + param_defaults[pw_res] = res.attributes['value'] except heat_exc.HTTPNotFound: LOG.debug('Heat resouce not found: %s' % pw_res) pass