Handle a deployment that was manually cancelled.

When doing a deployment or update, if the end-user uses CTRL+c
(SIGINT) to end it early, it will fail complaining that there is
no passwords key in the plan. We will now handle this and cleanup
the existing plan.

Change-Id: Ie7f1a4269936f98ad86db4993992e0b9a27edf73
Closes-Bug: #1819672
Resolves: rhbz#1753251
Signed-off-by: ekultails <ekultails@gmail.com>
(cherry picked from commit 72850060e0)
This commit is contained in:
ekultails 2019-10-02 10:26:30 -04:00
parent 128cc56a33
commit fa98192ac4
2 changed files with 29 additions and 1 deletions

View File

@ -356,6 +356,29 @@ class TestPlanUpdateWorkflows(base.TestCommand):
'generate_passwords': True, 'source_url': None,
'validate_stack': False})
@mock.patch('tripleoclient.workflows.plan_management._update_passwords',
autospec=True)
@mock.patch('yaml.safe_load',
autospec=True)
@mock.patch('tripleoclient.workflows.plan_management.tarball',
autospec=True)
@mock.patch('tripleo_common.utils.swift.empty_container',
autospec=True)
def test_update_plan_from_templates_recreate_env_missing_passwords(
self, mock_empty_container, mock_tarball, mock_yaml_safe_load,
mock_update_passwords):
plan_management.update_plan_from_templates(
self.app.client_manager,
'test-overcloud',
'/tht-root/',
validate_stack=False)
# A dictionary without the "passwords" key is provided in
# the _load_passwords method.
mock_yaml_safe_load.return_value = {}
# Ensure that the passwords variable is passed with a value of None.
mock_update_passwords.assert_called_with(
mock.ANY, 'test-overcloud', None)
class TestUpdatePasswords(base.TestCase):

View File

@ -259,7 +259,12 @@ def _upload_file_content(swift_client, container, filename, content):
def _load_passwords(swift_client, name):
plan_env = yaml.safe_load(swift_client.get_object(
name, constants.PLAN_ENVIRONMENT)[1])
return plan_env['passwords']
if "passwords" in plan_env:
return plan_env['passwords']
else:
LOG.warn("No passwords found in existing plan {}. "
"Updating plan with passwords.".format(name))
def _update_passwords(swift_client, name, passwords):