Skip to content

Commit

Permalink
Retry on receiving the following HTTP status codes: 400, 500, 502, 50…
Browse files Browse the repository at this point in the history
…3, 504

Retrying 400 mitigates a problem with retrieving data from OBS API while the
server runs a service.
  • Loading branch information
dmach committed Apr 26, 2023
1 parent c9c3dd6 commit e25dc2d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions osc/connection.py
Expand Up @@ -230,6 +230,15 @@ def http_request(method: str, url: str, headers=None, data=None, file=None):
pool_kwargs["retries"] = urllib3.Retry(
total=int(conf.config["http_retries"]),
backoff_factor=2,
status_forcelist=(
400, # Bad Request; retry on 400: service in progress
500, # Internal Server Error
502, # Bad Gateway
503, # Service Unavailable
504, # Gateway Timeout
),
# don't raise because we want an actual response rather than a MaxRetryError with "too many <status_code> error responses" message
raise_on_status=False,
**retries_kwargs,
)

Expand Down

0 comments on commit e25dc2d

Please sign in to comment.