From 70b28932fda9135cb340d500d1dcf3ed2bdfc0b5 Mon Sep 17 00:00:00 2001 From: Keigo Noha Date: Mon, 9 Dec 2019 11:09:25 +0900 Subject: [PATCH] Retry the connection to heat-api when 500 code In a rare case like httpd reload by logrotate, heat-api returns 500 code. If this happens, trpleoclient can't get the status of the stack even though the process is still on-going. To handle this situation, tipleoclient should retry when it can't get the stack information by 500 code. Change-Id: I97a6825f4ff9f125eb597e5b7bd0c553c37e49e7 Closes-Bug: #1855633 (cherry picked from commit 932fc6755a8315ccde2e90848ad3224f1fe16735) --- tripleoclient/tests/test_utils.py | 2 +- tripleoclient/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tripleoclient/tests/test_utils.py b/tripleoclient/tests/test_utils.py index 74db5d1aa..c952c5616 100644 --- a/tripleoclient/tests/test_utils.py +++ b/tripleoclient/tests/test_utils.py @@ -412,7 +412,7 @@ class TestWaitForStackUtil(TestCase): mock_get_stack.return_value = stack mock_poll.side_effect = hc_exc.HTTPException(code=500) - self.assertRaises(hc_exc.HTTPException, + self.assertRaises(RuntimeError, utils.wait_for_stack_ready, self.mock_orchestration, 'stack') diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index e2f889df3..e9758cc1f 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -365,7 +365,7 @@ def wait_for_stack_ready(orchestration_client, stack_name, marker=None, print(msg) return stack_status == '%s_COMPLETE' % action except hc_exc.HTTPException as e: - if e.code in [503, 504]: + if e.code in [500, 503, 504]: retries += 1 log.warning("Server issue while waiting for stack to be ready." " Attempting retry {} of {}".format(retries,