From 5435d9d8235349c986de6fef07d347431ca243ba Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Wed, 25 Jan 2017 08:06:27 +0000 Subject: [PATCH] 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 --- workbooks/baremetal.yaml | 70 +++++++--------------------------- workbooks/deployment.yaml | 15 ++------ workbooks/package_update.yaml | 6 +++ workbooks/plan_management.yaml | 20 ++-------- workbooks/scale.yaml | 5 +-- workbooks/stack.yaml | 5 +-- workbooks/validations.yaml | 15 ++------ 7 files changed, 31 insertions(+), 105 deletions(-) diff --git a/workbooks/baremetal.yaml b/workbooks/baremetal.yaml index 3c7f0305f..457b5858c 100644 --- a/workbooks/baremetal.yaml +++ b/workbooks/baremetal.yaml @@ -89,10 +89,7 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> register_or_update: description: Take nodes JSON and create nodes in a "manageable" state @@ -177,11 +174,7 @@ workflows: execution: <% execution() %> registered_nodes: <% $.registered_nodes or [] %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail - + - fail: <% $.get('status') = "FAILED" %> provide: description: Take a list of nodes and move them to "available" @@ -272,10 +265,7 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> provide_manageable_nodes: description: Provide all nodes in a 'manageable' state. @@ -320,10 +310,7 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> manage: description: Set a list of nodes to 'manageable' state @@ -363,10 +350,7 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> introspect: description: Take a list of nodes and move them through introspection. @@ -434,11 +418,7 @@ workflows: execution: <% execution() %> introspected_nodes: <% $.get('introspected_nodes', []) %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail - + - fail: <% $.get('status') = "FAILED" %> introspect_manageable_nodes: description: Introspect all nodes in a 'manageable' state. @@ -495,10 +475,7 @@ workflows: execution: <% execution() %> introspected_nodes: <% $.get('introspected_nodes', []) %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> configure: description: Take a list of manageable nodes and update their boot configuration. @@ -555,11 +532,7 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail - + - fail: <% $.get('status') = "FAILED" %> configure_manageable_nodes: description: Update the boot configuration of all nodes in 'manageable' state. @@ -623,11 +596,7 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail - + - fail: <% $.get('status') = "FAILED" %> tag_node: description: Tag a node with a role @@ -661,11 +630,7 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail - + - fail: <% $.get('status') = "FAILED" %> tag_nodes: description: Runs the tag_node workflow in a loop @@ -720,10 +685,7 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> create_raid_configuration: description: Create and apply RAID configuration for given nodes @@ -784,10 +746,7 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> cellv2_discovery: @@ -823,7 +782,4 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> diff --git a/workbooks/deployment.yaml b/workbooks/deployment.yaml index 1e7974d35..467fca822 100644 --- a/workbooks/deployment.yaml +++ b/workbooks/deployment.yaml @@ -43,10 +43,7 @@ workflows: stderr: <% task(deploy_config).result.deploy_stderr %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> deploy_on_servers: @@ -102,10 +99,7 @@ workflows: status: FAILED message: <% task(deploy_on_servers).result %> execution: <% execution() %> - on-success: fail_workflow - - fail_workflow: - action: std.fail + on-success: fail deploy_plan: @@ -225,7 +219,4 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> diff --git a/workbooks/package_update.yaml b/workbooks/package_update.yaml index b79897499..955ca0901 100644 --- a/workbooks/package_update.yaml +++ b/workbooks/package_update.yaml @@ -37,6 +37,8 @@ workflows: status: <% $.get('status', 'SUCCESS') %> message: <% $.get('message', '') %> execution: <% execution() %> + on-success: + - fail: <% $.get('status') = "FAILED" %> # Clear an update breakpoint clear_breakpoints: @@ -70,6 +72,8 @@ workflows: status: <% $.get('status', 'SUCCESS') %> message: <% $.get('message', '') %> execution: <% execution() %> + on-success: + - fail: <% $.get('status') = "FAILED" %> cancel_stack_update: description: Cancel a currently running stack update @@ -101,3 +105,5 @@ workflows: status: <% $.get('status', 'SUCCESS') %> message: <% $.get('message', '') %> execution: <% execution() %> + on-success: + - fail: <% $.get('status') = "FAILED" %> diff --git a/workbooks/plan_management.yaml b/workbooks/plan_management.yaml index 6a759ac36..295258f7a 100644 --- a/workbooks/plan_management.yaml +++ b/workbooks/plan_management.yaml @@ -65,10 +65,7 @@ workflows: message: <% $.message or '' %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> update_deployment_plan: input: @@ -131,10 +128,7 @@ workflows: message: <% $.message or '' %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> create_default_deployment_plan: input: @@ -235,10 +229,7 @@ workflows: message: <% $.message or '' %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> get_passwords: description: Retrieves passwords for a given plan @@ -299,7 +290,4 @@ workflows: message: <% $.message or '' %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> diff --git a/workbooks/scale.yaml b/workbooks/scale.yaml index 213dbcc1b..7a5086b14 100644 --- a/workbooks/scale.yaml +++ b/workbooks/scale.yaml @@ -62,7 +62,4 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> diff --git a/workbooks/stack.yaml b/workbooks/stack.yaml index a251e46e5..ab9cab597 100644 --- a/workbooks/stack.yaml +++ b/workbooks/stack.yaml @@ -101,7 +101,4 @@ workflows: message: <% $.get('message', '') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> diff --git a/workbooks/validations.yaml b/workbooks/validations.yaml index fa838f878..0f2d54fbf 100644 --- a/workbooks/validations.yaml +++ b/workbooks/validations.yaml @@ -60,10 +60,7 @@ workflows: stderr: <% $.stderr %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> run_validations: input: @@ -115,10 +112,7 @@ workflows: status: <% $.get('status', 'SUCCESS') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> run_groups: input: @@ -178,10 +172,7 @@ workflows: status: <% $.get('status', 'SUCCESS') %> execution: <% execution() %> on-success: - - fail_workflow: <% $.get('status') = "FAILED" %> - - fail_workflow: - action: std.fail + - fail: <% $.get('status') = "FAILED" %> list: input: