Skip to content

Retry URL downloads in runqemu.py#185

Merged
richm merged 1 commit intomainfrom
retry-image-download
Apr 15, 2025
Merged

Retry URL downloads in runqemu.py#185
richm merged 1 commit intomainfrom
retry-image-download

Conversation

@martinpitt
Copy link
Copy Markdown
Contributor

@martinpitt martinpitt commented Apr 15, 2025

Introduce a urlopen_retry() wrapper that retries up to 4 times with exponential back-off. This avoids failing tests due to short network glitches on the Fedora/CentOS image servers.

Replace the two non-context urlopen() calls with contexts.


Avoids failures like this and this. I tested this locally by temporarily damaging the download URL in ~/.config/linux-system-roles.json :

WARNING:root:Opening https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericClouxd-9-latest.x86_64.qcow2 failed, retry #1: HTTP Error 502: Bad Gateway
WARNING:root:Opening https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericClouxd-9-latest.x86_64.qcow2 failed, retry #2: HTTP Error 502: Bad Gateway
[...]

also tested with Fedora, and of course the passing cases. I sent a draft PR against sudo to validate this against CI, as this is a bit difficult to test locally with Python 2.7: linux-system-roles/sudo#49

martinpitt added a commit to martinpitt/lsr-sudo that referenced this pull request Apr 15, 2025
@martinpitt martinpitt force-pushed the retry-image-download branch from 30779ef to 2c45b0a Compare April 15, 2025 08:04
martinpitt added a commit to martinpitt/lsr-sudo that referenced this pull request Apr 15, 2025
@martinpitt martinpitt force-pushed the retry-image-download branch 2 times, most recently from b3818f6 to ecd6cca Compare April 15, 2025 08:16
@martinpitt
Copy link
Copy Markdown
Contributor Author

Meh, flake8 is really being annoying here..

Introduce a `urlopen_retry()` wrapper that retries up to 4 times with
exponential back-off. This avoids failing tests due to short network
glitches on the Fedora/CentOS image servers.

Replace the two non-context urlopen() calls with contexts.
@martinpitt martinpitt force-pushed the retry-image-download branch from ecd6cca to b1c2120 Compare April 15, 2025 08:19
martinpitt added a commit to martinpitt/lsr-sudo that referenced this pull request Apr 15, 2025
@martinpitt martinpitt requested review from richm and spetrosi April 15, 2025 08:21
@richm richm merged commit b1659b5 into main Apr 15, 2025
7 checks passed
@richm richm deleted the retry-image-download branch April 15, 2025 12:47
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.

2 participants