From 14c73ee0be209d868859e28883535dd2b2773369 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Mon, 18 Jun 2018 16:36:58 +0100 Subject: [PATCH] Use the standard messaging in the package_update workbook Update the package_update workbook to use the standard message sending workflow. This workflow reduces the boilerplate that is copied between workflows by defining the message structure, providing the retry logic and ensuring the task on a "FAILED" message. The workflow also offers optional persistence in Swift. If the plan name is given to the workflow it will store the messages in a Swift container named -messages. Change-Id: Icad2846b43dec8032d9692daea390bffa7486dac Related-Bug: #1757372 --- workbooks/package_update.yaml | 96 ++++++++++++----------------------- 1 file changed, 33 insertions(+), 63 deletions(-) diff --git a/workbooks/package_update.yaml b/workbooks/package_update.yaml index b7b0e2e23..639e916b9 100644 --- a/workbooks/package_update.yaml +++ b/workbooks/package_update.yaml @@ -50,18 +50,13 @@ workflows: message: <% task(update).result %> send_message: - action: zaqar.queue_post + workflow: tripleo.messaging.v1.send input: queue_name: <% $.queue_name %> - messages: - body: - type: tripleo.package_update.v1.package_update_plan - payload: - status: <% $.get('status', 'SUCCESS') %> - message: <% $.get('message', '') %> - execution: <% execution() %> - on-success: - - fail: <% $.get('status') = "FAILED" %> + type: <% execution().name %> + status: <% $.get('status', 'SUCCESS') %> + message: <% $.get('message', '') %> + execution: <% execution() %> get_config: input: @@ -83,18 +78,13 @@ workflows: on-complete: send_message send_message: - action: zaqar.queue_post + workflow: tripleo.messaging.v1.send input: queue_name: <% $.queue_name %> - messages: - body: - type: tripleo.package_update.v1.package_update_plan - payload: - status: <% $.get('status', 'SUCCESS') %> - message: <% $.get('message', '') %> - execution: <% execution() %> - on-success: - - fail: <% $.get('status') = "FAILED" %> + type: <% execution().name %> + status: <% $.get('status', 'SUCCESS') %> + message: <% $.get('message', '') %> + execution: <% execution() %> update_nodes: description: Take a container and perform an update nodes by nodes @@ -155,30 +145,25 @@ workflows: output: <% task().result %> node_update_passed: - on-success: notify_zaqar + on-success: send_message publish: status: SUCCESS message: Updated nodes - <% $.nodes %> node_update_failed: - on-success: notify_zaqar + on-success: send_message publish: status: FAILED message: Failed to update nodes - <% $.nodes %>, please see the logs. - notify_zaqar: - action: zaqar.queue_post - retry: count=5 delay=1 + send_message: + workflow: tripleo.messaging.v1.send input: queue_name: <% $.ansible_queue_name %> - messages: - body: - type: tripleo.package_update.v1.update_nodes - payload: - status: <% $.status %> - execution: <% execution() %> - on-success: - - fail: <% $.get('status') = "FAILED" %> + type: <% execution().name %> + status: <% $.get('status', 'SUCCESS') %> + message: <% $.get('message', '') %> + execution: <% execution() %> update_converge_plan: description: Take a container and perform the converge for minor update @@ -205,18 +190,13 @@ workflows: message: <% task(remove_noop).result %> send_message: - action: zaqar.queue_post + workflow: tripleo.messaging.v1.send input: queue_name: <% $.queue_name %> - messages: - body: - type: tripleo.package_update.v1.update_converge_plan - payload: - status: <% $.get('status', 'SUCCESS') %> - message: <% $.get('message', '') %> - execution: <% execution() %> - on-success: - - fail: <% $.get('status') = "FAILED" %> + type: <% execution().name %> + status: <% $.get('status', 'SUCCESS') %> + message: <% $.get('message', '') %> + execution: <% execution() %> converge_upgrade_plan: description: Take a container and perform the converge step of a major upgrade @@ -245,18 +225,13 @@ workflows: message: <% task(upgrade_converge).result %> send_message: - action: zaqar.queue_post + workflow: tripleo.messaging.v1.send input: queue_name: <% $.queue_name %> - messages: - body: - type: tripleo.major_upgrade.v1.converge_upgrade_plan - payload: - status: <% $.get('status', 'SUCCESS') %> - message: <% $.get('message', '') %> - execution: <% execution() %> - on-success: - - fail: <% $.get('status') = "FAILED" %> + type: <% execution().name %> + status: <% $.get('status', 'SUCCESS') %> + message: <% $.get('message', '') %> + execution: <% execution() %> ffwd_upgrade_converge_plan: description: ffwd-upgrade converge removes DeploymentSteps no-op from plan @@ -283,15 +258,10 @@ workflows: message: <% task(remove_noop).result %> send_message: - action: zaqar.queue_post + workflow: tripleo.messaging.v1.send input: queue_name: <% $.queue_name %> - messages: - body: - type: tripleo.package_update.v1.ffwd_upgrade_converge_plan - payload: - status: <% $.get('status', 'SUCCESS') %> - message: <% $.get('message', '') %> - execution: <% execution() %> - on-success: - - fail: <% $.get('status') = "FAILED" %> + type: <% execution().name %> + status: <% $.get('status', 'SUCCESS') %> + message: <% $.get('message', '') %> + execution: <% execution() %>