-
Notifications
You must be signed in to change notification settings - Fork 67
ci: add 429 support for pulling images #4940
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
f115aa5
a42b2d3
afe753a
08fc151
ab0f5a8
ebaa65f
64bcae4
aa2f13f
f96318d
2d3070b
1388a39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,19 +2,66 @@ | |||||||||||||||||||||||||||||||
| Pull a Fluent Docker image based on the FLUENT_IMAGE_TAG environment variable. | ||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import re | ||||||||||||||||||||||||||||||||
| import subprocess | ||||||||||||||||||||||||||||||||
| import time | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| from ansys.fluent.core import config | ||||||||||||||||||||||||||||||||
| from ansys.fluent.core.docker.utils import get_ghcr_fluent_image_name | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| MAX_RETRIES = 5 | ||||||||||||||||||||||||||||||||
| BASE_DELAY = 1.0 # seconds | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| def pull_fluent_image(): | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| def pull_fluent_image(): # pylint: disable=missing-raises-doc | ||||||||||||||||||||||||||||||||
| """Pull Fluent Docker image and clean up dangling images.""" | ||||||||||||||||||||||||||||||||
| fluent_image_tag = config.fluent_image_tag | ||||||||||||||||||||||||||||||||
| image_name = get_ghcr_fluent_image_name(fluent_image_tag) | ||||||||||||||||||||||||||||||||
| separator = "@" if fluent_image_tag.startswith("sha256") else ":" | ||||||||||||||||||||||||||||||||
| full_image_name = f"{image_name}{separator}{fluent_image_tag}" | ||||||||||||||||||||||||||||||||
| subprocess.run(["docker", "pull", full_image_name], check=True) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Retry logic for handling rate limits (429 errors) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| for attempt in range(MAX_RETRIES): | ||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||
| result = subprocess.run( | ||||||||||||||||||||||||||||||||
| ["docker", "pull", full_image_name], | ||||||||||||||||||||||||||||||||
| check=True, | ||||||||||||||||||||||||||||||||
| stderr=subprocess.PIPE, | ||||||||||||||||||||||||||||||||
| text=True, | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
|
Comment on lines
+27
to
+32
|
||||||||||||||||||||||||||||||||
| subprocess.run( | |
| ["docker", "pull", full_image_name], | |
| check=True, | |
| capture_output=True, | |
| text=True, | |
| ) | |
| result = subprocess.run( | |
| ["docker", "pull", full_image_name], | |
| check=True, | |
| capture_output=True, | |
| text=True, | |
| ) | |
| if result.stdout: | |
| print(result.stdout, end="") | |
| print(f"Successfully pulled Docker image: {full_image_name}") |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result is assigned from subprocess.run(...) but never used. Remove the assignment (or use the value) to avoid dead code and keep the retry logic minimal.
Copilot
AI
Apr 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The retry-after parsing only matches values expressed in milliseconds (... ms). If Docker/registry emits Retry-After in seconds (a common format) this hint will be ignored and the script will always fall back to exponential backoff. Consider supporting both s and ms (and/or bare integer seconds) so the backoff respects the server-provided delay when available.
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because stderr is captured (stderr=subprocess.PIPE), Docker error output won’t be streamed to CI logs. When the exception is re-raised (non-429 path, or after max retries), the captured stderr likely won’t be visible, making failures hard to diagnose. Consider printing/logging e.stderr before re-raising (and/or including it in a new exception message) so CI logs retain the original docker pull error details.
| ) | |
| raise | |
| else: | |
| # Not a rate limit error, re-raise immediately | |
| ) | |
| print("docker pull stderr output:\n" + (e.stderr or "")) | |
| raise | |
| else: | |
| # Not a rate limit error, re-raise immediately | |
| print("docker pull stderr output:\n" + (e.stderr or "")) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add 429 support for pulling images |
Uh oh!
There was an error while loading. Please reload this page.