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 426f4aa6d8)
This commit is contained in:
Mathieu Bultel 2018-03-13 14:05:19 +01:00 committed by Marios Andreou
parent a5141ea08c
commit 3ea974f4a7
3 changed files with 48 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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: