Add new undeploy_plan workflow

This wraps the stack delete and handles the message updates to
correctly reflect the deployment status in the clients.

Co-Authored-By: Jiri Tomasek <jtomasek@redhat.com>
Implements: blueprint config-download-workflows
Change-Id: Ibd1da1aee8415712b9a418c6738f6ea9a2828a55
This commit is contained in:
Martin André 2018-05-04 10:54:28 +02:00 committed by Jiri Tomasek
parent ad4d9f8d6d
commit 4704d56993
2 changed files with 73 additions and 18 deletions

View File

@ -512,6 +512,58 @@ workflows:
plan_name: <% $.plan_name %>
deployment_status: <% $.deployment_status %>
undeploy_plan:
description: >
Undeploy a plan.
input:
- container
- timeout: 240
- queue_name: tripleo
tags:
- tripleo-common-managed
tasks:
send_start_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: RUNNING
deployment_status: UNDEPLOYING
message: "Deleting <% $.container %> deployment"
execution: <% execution() %>
plan_name: <% $.container %>
on-complete: delete_stack
delete_stack:
workflow: tripleo.stack.v1.delete_stack
input:
stack: <% $.container %>
queue_name: <% $.queue_name %>
on-complete: send_undeployed_message
publish-on-error:
status: FAILED
deployment_status: UNDEPLOY_FAILED
message: "Failed to delete <% $.container %> deployment: <% task().result %>"
publish:
status: SUCCESS
deployment_status: UNDEPLOYED
message: "Deleted <% $.container %> deployment"
send_undeployed_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.status %>
deployment_status: <% $.deployment_status %>
message: <% $.message %>
execution: <% execution() %>
plan_name: <% $.container %>
create_overcloudrc:
description: >
Given the name of a container and optionally a comma-separated string

View File

@ -5,20 +5,18 @@ description: TripleO Stack Workflows
workflows:
_heat_stacks_get:
_heat_stacks_list:
tags:
- tripleo-common-managed
input:
- stack
- queue_name: null
tasks:
heat_stacks_get:
action: heat.stacks_get stack_id=<% $.stack %> resolve_outputs=false
heat_stacks_list:
action: heat.stacks_list
publish:
stack: <% task().result.delete("outputs") %>
stacks: <% task().result %>
on-success:
- send_message: <% bool($.queue_name) %>
send_message:
@ -29,7 +27,7 @@ workflows:
status: "RUNNING" # This should never be the end of a workflow
execution: <% execution() %>
payload:
stack: <% $.stack %>
stacks: <% $.stacks %>
wait_for_stack_complete_or_failed:
input:
@ -43,17 +41,16 @@ workflows:
tasks:
wait_for_stack_status:
workflow: _heat_stacks_get
workflow: _heat_stacks_list
input:
stack: <% $.stack %>
queue_name: <% $.queue_name %>
timeout: <% $.timeout %>
publish:
stack_status: <% task().result.stack.stack_status %>
stack_status: <% let(stack => $.stack) -> task().result.stacks.where($.stack_name = $stack).first().stack_status %>
retry:
delay: 15
count: <% $.timeout / 15 %>
continue-on: <% task().result.stack.stack_status in ['CREATE_IN_PROGRESS', 'UPDATE_IN_PROGRESS', 'DELETE_IN_PROGRESS'] %>
continue-on: <% $.stack_status in ['CREATE_IN_PROGRESS', 'UPDATE_IN_PROGRESS', 'DELETE_IN_PROGRESS'] %>
wait_for_stack_in_progress:
input:
@ -67,34 +64,37 @@ workflows:
tasks:
wait_for_stack_status:
workflow: _heat_stacks_get
workflow: _heat_stacks_list
input:
stack: <% $.stack %>
queue_name: <% $.queue_name %>
timeout: <% $.timeout %>
publish:
stack_status: <% task().result.stack.stack_status %>
stack_status: <% let(stack => $.stack) -> task().result.stacks.where($.stack_name = $stack).first().stack_status %>
retry:
delay: 15
count: <% $.timeout / 15 %>
continue-on: <% task().result.stack.stack_status in ['CREATE_COMPLETE', 'CREATE_FAILED', 'UPDATE_COMPLETE', 'UPDATE_FAILED', 'DELETE_FAILED'] %>
continue-on: <% $.stack_status in ['CREATE_COMPLETE', 'CREATE_FAILED', 'UPDATE_COMPLETE', 'UPDATE_FAILED', 'DELETE_FAILED'] %>
wait_for_stack_does_not_exist:
input:
- stack
- timeout: 3600
- queue_name: null
tags:
- tripleo-common-managed
tasks:
wait_for_stack_does_not_exist:
action: heat.stacks_list
wait_for_stack_status:
workflow: _heat_stacks_list
input:
queue_name: <% $.queue_name %>
timeout: <% $.timeout %>
retry:
delay: 15
count: <% $.timeout / 15 %>
continue-on: <% $.stack in task().result.select([$.stack_name, $.id]).flatten() %>
continue-on: <% $.stack in task().result.stacks.select([$.stack_name, $.id]).flatten() %>
delete_stack:
input:
@ -117,7 +117,10 @@ workflows:
message: <% task(delete_the_stack).result %>
wait_for_stack_does_not_exist:
workflow: tripleo.stack.v1.wait_for_stack_does_not_exist stack=<% $.stack %>
workflow: tripleo.stack.v1.wait_for_stack_does_not_exist
input:
stack: <% $.stack %>
queue_name: <% $.queue_name %>
on-success: send_message
on-error: wait_for_stack_does_not_exist_failed