Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create_singularities: Retry Docker Hub API requests on connection failures/timeouts #109

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

jwodder
Copy link
Collaborator

@jwodder jwodder commented Feb 16, 2024

Closes #108.

@jwodder jwodder requested a review from yarikoptic February 16, 2024 14:56
try:
return requests.get(url)
except (requests.ConnectionError, requests.Timeout) as e:
if (wait := next(sleepiter, None)) is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note 2 myself: first use of := in the script, but was added in 3.8 and this script for internal use so should be totally fine

@@ -78,7 +79,7 @@ class Builder:

@staticmethod
def get_last_docker_version_tag(dh: str, only_good_versions: bool=False) -> Optional[tuple[str, str]]:
r = requests.get(f"https://registry.hub.docker.com/v2/repositories/{dh}/tags")
r = retry_get(f"https://registry.hub.docker.com/v2/repositories/{dh}/tags")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that there is a "standard" way to get retries done with requests: https://requests.readthedocs.io/en/latest/user/advanced/?highlight=Retry#example-automatic-retries but it seems to be also not that straightforward... so I am ok with this "ad-hoc" solution for now. Thank you!

@yarikoptic
Copy link
Member

will be tested in battle ;-)

@yarikoptic yarikoptic merged commit 14cfb23 into master Feb 16, 2024
5 checks passed
@jwodder jwodder deleted the gh-108 branch July 12, 2024 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add retries for docker hub connections
2 participants