Dougal Matthews 5435d9d823 Use the builtin Mistral engine command 'fail' when failing workflows
In changes 12f7345, c2fb9b0, 6051a74, c7b01eb and ab946c4 Mistral
Workflows were marked as failed if they sent a Zaqar message with the
status "FAILED". This is correct, but it turns out there is an easier
way to do it.

Mistral has a engine command designed for this purpose, using it removes
some of the duplication we have incurred.

We use on-success rather than on-complete to surface the best error on
the workflow. If the Zaqar queue post fails, then the workflow will fail
with this error. If, on-complete we then manually mark the workflow as
failed it will ovrwrite the Zaqar error with a generic one.

Closes-Bug: #1664918
Related-Bug: #1651704
Change-Id: I9ef9cfef1b8740a535e005769ec0c3ad67ecb103
2017-02-15 10:05:28 +00:00

105 lines
3.1 KiB
YAML

---
version: '2.0'
name: tripleo.stack.v1
description: TripleO Stack Workflows
workflows:
wait_for_stack_complete_or_failed:
input:
- stack
- timeout: 14400 # 4 hours. Default timeout of stack deployment
tasks:
wait_for_stack_status:
action: heat.stacks_get stack_id=<% $.stack %>
timeout: <% $.timeout %>
retry:
delay: 15
count: <% $.timeout / 15 %>
continue-on: <% task(wait_for_stack_status).result.stack_status in ['CREATE_IN_PROGRESS', 'UPDATE_IN_PROGRESS', 'DELETE_IN_PROGRESS'] %>
wait_for_stack_in_progress:
input:
- stack
- timeout: 600 # 10 minutes. Should not take much longer for a stack to transition to IN_PROGRESS
tasks:
wait_for_stack_status:
action: heat.stacks_get stack_id=<% $.stack %>
timeout: <% $.timeout %>
retry:
delay: 15
count: <% $.timeout / 15 %>
continue-on: <% task(wait_for_stack_status).result.stack_status in ['CREATE_COMPLETE', 'CREATE_FAILED', 'UPDATE_COMPLETE', 'UPDATE_FAILED', 'DELETE_FAILED'] %>
wait_for_stack_does_not_exist:
input:
- stack
- timeout: 3600
tasks:
wait_for_stack_does_not_exist:
action: heat.stacks_list
timeout: <% $.timeout %>
retry:
delay: 15
count: <% $.timeout / 15 %>
continue-on: <% $.stack in task(wait_for_stack_does_not_exist).result.select($.stack_name) %>
delete_stack:
input:
- stack
- queue_name: tripleo
tasks:
delete_the_stack:
action: heat.stacks_delete stack_id=<% $.stack %>
on-success: wait_for_stack_in_progress
on-error: delete_the_stack_failed
delete_the_stack_failed:
on-success: send_message
publish:
status: FAILED
message: <% task(delete_the_stack).result %>
wait_for_stack_in_progress:
workflow: tripleo.stack.v1.wait_for_stack_in_progress stack=<% $.stack %>
on-success: wait_for_stack_does_not_exist
on-error: wait_for_stack_in_progress_failed
wait_for_stack_in_progress_failed:
on-success: send_message
publish:
status: FAILED
message: <% task(wait_for_stack_in_progress).result %>
wait_for_stack_does_not_exist:
workflow: tripleo.stack.v1.wait_for_stack_does_not_exist stack=<% $.stack %>
on-success: send_message
on-error: wait_for_stack_does_not_exist_failed
wait_for_stack_does_not_exist_failed:
on-success: send_message
publish:
status: FAILED
message: <% task(wait_for_stack_does_not_exist).result %>
send_message:
action: zaqar.queue_post
retry: count=5 delay=1
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.scale.v1.delete_stack
payload:
status: <% $.get('status', 'SUCCESS') %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>