[App] Extend retry to 4xx except 400, 401, 403, 404 (#19842)

* Extend retry to 4xx except 400, 401, 403, 404

* Remove unused intersphinx mapping for app

---------

Co-authored-by: awaelchli <aedu.waelchli@gmail.com>
This commit is contained in:
Luca Antiga 2024-05-18 22:03:16 -04:00 committed by GitHub
parent c8059d7bfd
commit d5bf4b9ed3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View File

@ -96,10 +96,14 @@ def create_retry_strategy():
# are going to be alive for a very long time (~ 4 days) but retries every 120 seconds
total=_CONNECTION_RETRY_TOTAL,
backoff_factor=_CONNECTION_RETRY_BACKOFF_FACTOR,
# Any 4xx and 5xx statuses except
# 400 Bad Request
# 401 Unauthorized
# 403 Forbidden
# 404 Not Found
status_forcelist={
408, # Request Timeout
429, # Too Many Requests
*range(500, 600), # Any 5xx Server Error status
402,
*range(405, 600),
},
allowed_methods={
"POST", # Default methods are idempotent, add POST here

View File

@ -49,7 +49,8 @@ def test_find_free_network_port_cloudspace(_, patch_constants):
def test_http_client_retry_post(getconn_mock):
getconn_mock.return_value.getresponse.side_effect = [
mock.Mock(status=500, msg=HTTPMessage()),
mock.Mock(status=429, msg=HTTPMessage()),
mock.Mock(status=599, msg=HTTPMessage()),
mock.Mock(status=405, msg=HTTPMessage()),
mock.Mock(status=200, msg=HTTPMessage()),
]
@ -61,6 +62,7 @@ def test_http_client_retry_post(getconn_mock):
mock.call("POST", "/test", body=None, headers=mock.ANY),
mock.call("POST", "/test", body=None, headers=mock.ANY),
mock.call("POST", "/test", body=None, headers=mock.ANY),
mock.call("POST", "/test", body=None, headers=mock.ANY),
]
@ -68,7 +70,8 @@ def test_http_client_retry_post(getconn_mock):
def test_http_client_retry_get(getconn_mock):
getconn_mock.return_value.getresponse.side_effect = [
mock.Mock(status=500, msg=HTTPMessage()),
mock.Mock(status=429, msg=HTTPMessage()),
mock.Mock(status=599, msg=HTTPMessage()),
mock.Mock(status=405, msg=HTTPMessage()),
mock.Mock(status=200, msg=HTTPMessage()),
]
@ -80,4 +83,5 @@ def test_http_client_retry_get(getconn_mock):
mock.call("GET", "/test", body=None, headers=mock.ANY),
mock.call("GET", "/test", body=None, headers=mock.ANY),
mock.call("GET", "/test", body=None, headers=mock.ANY),
mock.call("GET", "/test", body=None, headers=mock.ANY),
]