From a5759bf4254264a6d5d5aac877205c9fc067b408 Mon Sep 17 00:00:00 2001 From: Sergii Golovatiuk Date: Fri, 21 Sep 2018 12:22:09 +0200 Subject: [PATCH] Add 2h timeout when waiting for websocket messages on package_update This patch adds a mechanism for setting a timeout when waiting for websocket messages. The package_update workflow itself won't be interrupted. Exception will indicate that it's still running, but websocket is dead. Change-Id: I5dc7d43d816d286b1d948fa512fe656f92f9d784 --- tripleoclient/workflows/package_update.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tripleoclient/workflows/package_update.py b/tripleoclient/workflows/package_update.py index a5ff63c2b..ec2b8ad11 100644 --- a/tripleoclient/workflows/package_update.py +++ b/tripleoclient/workflows/package_update.py @@ -22,6 +22,8 @@ from tripleoclient import utils from tripleoclient.workflows import base +_WORKFLOW_TIMEOUT = 120 * 60 # 2h + def update(clients, **workflow_input): workflow_client = clients.workflow_engine @@ -35,7 +37,8 @@ def update(clients, **workflow_input): workflow_input=workflow_input ) - for payload in base.wait_for_messages(workflow_client, ws, execution): + for payload in base.wait_for_messages(workflow_client, ws, execution, + _WORKFLOW_TIMEOUT): assert payload['status'] == "SUCCESS", pprint.pformat(payload) orchestration_client = clients.orchestration @@ -65,7 +68,8 @@ def get_config(clients, **workflow_input): workflow_input=workflow_input ) - for payload in base.wait_for_messages(workflow_client, ws, execution): + for payload in base.wait_for_messages(workflow_client, ws, execution, + _WORKFLOW_TIMEOUT): assert payload['status'] == "SUCCESS", pprint.pformat(payload) if payload['status'] == 'SUCCESS': @@ -88,7 +92,8 @@ def update_ansible(clients, **workflow_input): for payload in base.wait_for_messages(workflow_client, update_ws, - execution): + execution, + _WORKFLOW_TIMEOUT): if payload.get('message'): pprint.pprint(payload['message'].splitlines()) @@ -110,7 +115,8 @@ def update_converge_nodes(clients, **workflow_input): workflow_input=workflow_input ) - for payload in base.wait_for_messages(workflow_client, ws, execution): + for payload in base.wait_for_messages(workflow_client, ws, execution, + _WORKFLOW_TIMEOUT): assert payload['status'] == "SUCCESS", pprint.pformat(payload) if payload['status'] == 'SUCCESS': @@ -131,7 +137,8 @@ def converge_nodes(clients, **workflow_input): workflow_input=workflow_input ) - for payload in base.wait_for_messages(workflow_client, ws, execution): + for payload in base.wait_for_messages(workflow_client, ws, execution, + _WORKFLOW_TIMEOUT): assert payload['status'] == "SUCCESS", pprint.pformat(payload) orchestration_client = clients.orchestration @@ -162,7 +169,8 @@ def ffwd_converge_nodes(clients, **workflow_input): workflow_input=workflow_input ) - for payload in base.wait_for_messages(workflow_client, ws, execution): + for payload in base.wait_for_messages(workflow_client, ws, execution, + _WORKFLOW_TIMEOUT): assert payload['status'] == "SUCCESS", pprint.pformat(payload) if payload['status'] == 'SUCCESS': @@ -183,7 +191,8 @@ def run_on_nodes(clients, **workflow_input): workflow_input=workflow_input ) - for payload in base.wait_for_messages(workflow_client, ws, execution): + for payload in base.wait_for_messages(workflow_client, ws, execution, + _WORKFLOW_TIMEOUT): assert payload['status'] == "SUCCESS", pprint.pformat(payload) if payload['status'] == "SUCCESS":