From 3ea974f4a7df25669a20d6ef3631bb55aabff68f Mon Sep 17 00:00:00 2001 From: Mathieu Bultel Date: Tue, 13 Mar 2018 14:05:19 +0100 Subject: [PATCH] Remove the noop deploystep for upgrade converge step The noop deploystep is set during the prepare step for upgrade. It put in the plan_env directly, so since we are keeping the user-env / plan-env for upgrade the noop steps are never removed. This patch aim to trigger a mistral action to remove all the OS::Heat::None for the deploystep/pre/post Change-Id: If7eb342a84b530b07db513146e85916f2d5c1370 (cherry picked from commit 426f4aa6d859eda7614cd173974f5ccd32446116) --- setup.cfg | 1 + tripleo_common/actions/plan.py | 39 ++++++++++++++++++++++++++++++++++ workbooks/package_update.yaml | 8 +++++++ 3 files changed, 48 insertions(+) diff --git a/setup.cfg b/setup.cfg index 5a4d7f749..12cf2af61 100644 --- a/setup.cfg +++ b/setup.cfg @@ -116,6 +116,7 @@ mistral.actions = tripleo.plan.gather_roles = tripleo_common.actions.plan:GatherRolesAction tripleo.plan.update_roles = tripleo_common.actions.plan:UpdateRolesAction tripleo.plan.validate_roles = tripleo_common.actions.plan:ValidateRolesDataAction + tripleo.plan.remove_noop_deploystep = tripleo_common.actions.plan:RemoveNoopDeployStepAction tripleo.logging_to_swift.format_messages = tripleo_common.actions.logging_to_swift:FormatMessagesAction tripleo.logging_to_swift.publish_ui_log_to_swift = tripleo_common.actions.logging_to_swift:PublishUILogToSwiftAction tripleo.logging_to_swift.prepare_log_download = tripleo_common.actions.logging_to_swift:PrepareLogDownloadAction diff --git a/tripleo_common/actions/plan.py b/tripleo_common/actions/plan.py index 55c9cecb1..c16185ce5 100644 --- a/tripleo_common/actions/plan.py +++ b/tripleo_common/actions/plan.py @@ -463,3 +463,42 @@ class GatherRolesAction(actions.Action): return actions.Result(error="/n".join(err_msgs)) return actions.Result(data={'gathered_roles': gathered_roles}) + + +class RemoveNoopDeployStepAction(base.TripleOAction): + """Remove all the pre, post and deploy step in the plan-environment. + + :param container: name of the Swift container / plan name + """ + + def __init__(self, container=constants.DEFAULT_CONTAINER_NAME): + super(RemoveNoopDeployStepAction, self).__init__() + self.container = container + + def run(self, context): + # get the stack. Error if doesn't exist + heat = self.get_orchestration_client(context) + try: + stack = heat.stacks.get(self.container) + except heatexceptions.HTTPNotFound: + msg = "Error retrieving stack: %s" % self.container + LOG.exception(msg) + return actions.Result(error=msg) + + swift = self.get_object_client(context) + plan_env = plan_utils.get_env(swift, self.container) + + # Get output and check if DeployStep are None + steps = ['OS::TripleO::DeploymentSteps'] + for output in stack.to_dict().get('outputs', {}): + if output['output_key'] == 'RoleData': + for role in output['output_value']: + steps.append("OS::TripleO::Tasks::%sPreConfig" % role) + steps.append("OS::TripleO::Tasks::%sPostConfig" % role) + # Remove noop Steps + for step in steps: + if step in plan_env['resource_registry'].keys(): + if plan_env['resource_registry'][step] == 'OS::Heat::None': + plan_env['resource_registry'].pop(step) + # Push plan_env + plan_utils.put_env(swift, plan_env) diff --git a/workbooks/package_update.yaml b/workbooks/package_update.yaml index 24e8e54a5..3220e37d1 100644 --- a/workbooks/package_update.yaml +++ b/workbooks/package_update.yaml @@ -192,12 +192,20 @@ workflows: - tripleo-common-managed tasks: + remove_noop: + action: tripleo.plan.remove_noop_deploystep + input: + container: <% $.container %> + on-success: upgrade_converge + on-error: set_update_failed + upgrade_converge: action: tripleo.deployment.deploy input: timeout: <% $.timeout %> container: <% $.container %> skip_deploy_identifier: <% $.skip_deploy_identifier %> + on-success: send_message on-error: set_update_failed set_update_failed: