Skip to content

Commit

Permalink
decorator: retry on 500
Browse files Browse the repository at this point in the history
Signed-off-by: Isabella do Amaral <[email protected]>
  • Loading branch information
isinyaaa committed Nov 13, 2024
1 parent 3ea4643 commit f9aeb99
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
The versions coincide with releases on pip. Only major versions will be released as tags on Github.

## [0.0.x](https://github.com/oras-project/oras-py/tree/main) (0.0.x)
- retry on 500 (0.2.25)
- align provider config_path type annotations (0.2.24)
- add missing prefix property to auth backend (0.2.23)
- allow for filepaths to include `:` (0.2.22)
Expand Down
12 changes: 11 additions & 1 deletion oras/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions oras/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion oras/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__copyright__ = "Copyright The ORAS Authors."
__license__ = "Apache-2.0"

__version__ = "0.2.24"
__version__ = "0.2.25"
AUTHOR = "Vanessa Sochat"
EMAIL = "[email protected]"
NAME = "oras"
Expand Down

0 comments on commit f9aeb99

Please sign in to comment.