Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
decorator: retry on 500
Browse files Browse the repository at this point in the history
Signed-off-by: Isabella do Amaral <[email protected]>
isinyaaa committed Nov 13, 2024
1 parent 3ea4643 commit 7a8c9d2
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 11 additions & 1 deletion oras/decorator.py
Original file line number Diff line number Diff line change
@@ -37,7 +37,17 @@ def inner(*args, **kwargs):
attempt = 0
while attempt < attempts:
try:
return func(*args, **kwargs)
res = func(*args, **kwargs)
if res.status_code == 500:
try:
msg = res.json()
for error in msg.get("errors", []):
if isinstance(error, dict) and "message" in error:
logger.error(error["message"])
except Exception:
pass
raise ValueError(f"Issue with {res.request.url}: {res.reason}")
return res
except oras.auth.AuthenticationException as e:
raise e
except Exception as e:
3 changes: 0 additions & 3 deletions oras/provider.py
Original file line number Diff line number Diff line change
@@ -840,9 +840,6 @@ def push(
response = self.upload_manifest(
manifest, container
) # make the returned response from this method, the one pertaining to the uploaded Manifest
if response.status_code == 500:
# retry once
response = self.upload_manifest(manifest, container)
self._check_200_response(response)
print(f"Successfully pushed {container}")
return response

0 comments on commit 7a8c9d2

Please sign in to comment.