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 932fc6755a)
This commit is contained in:
Keigo Noha 2019-12-09 11:09:25 +09:00 committed by Emilien Macchi
parent 155bf6d938
commit bcb511376a
2 changed files with 2 additions and 2 deletions

View File

@ -324,7 +324,7 @@ class TestWaitForStackUtil(TestCase):
mock_get_stack.return_value = stack mock_get_stack.return_value = stack
mock_poll.side_effect = hc_exc.HTTPException(code=500) mock_poll.side_effect = hc_exc.HTTPException(code=500)
self.assertRaises(hc_exc.HTTPException, self.assertRaises(RuntimeError,
utils.wait_for_stack_ready, utils.wait_for_stack_ready,
self.mock_orchestration, 'stack') self.mock_orchestration, 'stack')

View File

@ -374,7 +374,7 @@ def wait_for_stack_ready(orchestration_client, stack_name, marker=None,
print(msg) print(msg)
return stack_status == '%s_COMPLETE' % action return stack_status == '%s_COMPLETE' % action
except hc_exc.HTTPException as e: except hc_exc.HTTPException as e:
if e.code in [503, 504]: if e.code in [500, 503, 504]:
retries += 1 retries += 1
log.warning("Server issue while waiting for stack to be ready." log.warning("Server issue while waiting for stack to be ready."
" Attempting retry {} of {}".format(retries, " Attempting retry {} of {}".format(retries,