summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorClayton Walker <cwalker@sofi.org>2022-03-02 11:34:05 -0700
committerNejc Habjan <nejc.habjan@siemens.com>2022-04-04 23:30:14 +0200
commitc3ef1b5c1eaf1348a18d753dbf7bda3c129e3262 (patch)
treefeba26855cc7d26751415b96da1a17cdcbf09839 /gitlab
parent3b49e4d61e6f360f1c787aa048edf584aec55278 (diff)
downloadgitlab-c3ef1b5c1eaf1348a18d753dbf7bda3c129e3262.tar.gz
fix: add 52x range to retry transient failures and tests
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/client.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/gitlab/client.py b/gitlab/client.py
index 75765f7..c6e9b96 100644
--- a/gitlab/client.py
+++ b/gitlab/client.py
@@ -35,6 +35,8 @@ REDIRECT_MSG = (
"{source!r} to {target!r}"
)
+RETRYABLE_TRANSIENT_ERROR_CODES = [500, 502, 503, 504] + list(range(520, 531))
+
class Gitlab:
"""Represents a GitLab server connection.
@@ -694,9 +696,9 @@ class Gitlab:
)
except requests.ConnectionError:
if retry_transient_errors and (
- max_retries == -1 or cur_retries < max_retries
+ max_retries == -1 or cur_retries < max_retries
):
- wait_time = 2 ** cur_retries * 0.1
+ wait_time = 2**cur_retries * 0.1
cur_retries += 1
time.sleep(wait_time)
continue
@@ -712,7 +714,8 @@ class Gitlab:
"retry_transient_errors", self.retry_transient_errors
)
if (429 == result.status_code and obey_rate_limit) or (
- result.status_code in [500, 502, 503, 504] and retry_transient_errors
+ result.status_code in RETRYABLE_TRANSIENT_ERROR_CODES
+ and retry_transient_errors
):
# Response headers documentation:
# https://docs.gitlab.com/ee/user/admin_area/settings/user_and_ip_rate_limits.html#response-headers