-
Notifications
You must be signed in to change notification settings - Fork 61
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 all commits
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,65 @@ | |||||
| 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: | ||||||
| subprocess.run( | ||||||
| ["docker", "pull", full_image_name], | ||||||
| check=True, | ||||||
| capture_output=True, | ||||||
| text=True, | ||||||
| ) | ||||||
| break # Success, exit retry loop | ||||||
| except subprocess.CalledProcessError as e: | ||||||
| stderr_output = e.stderr.lower() | ||||||
|
||||||
|
|
||||||
| # Check if it's a 429 rate limit error | ||||||
| if "toomanyrequests" in stderr_output or "429" in stderr_output: | ||||||
| if attempt < MAX_RETRIES - 1: | ||||||
| # Parse retry-after hint if available | ||||||
| retry_after = None | ||||||
| match = re.search( | ||||||
| r"retry-after:\s*([\d.]+)\s*ms", e.stderr, re.IGNORECASE | ||||||
|
||||||
| r"retry-after:\s*([\d.]+)\s*ms", e.stderr, re.IGNORECASE | |
| r"retry-after:\s*([\d.]+)\s*ms", stderr_output, re.IGNORECASE |
Copilot
AI
Feb 18, 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 exponential backoff calculation uses 2attempt, which for attempt=0 results in 1 second (2^0 = 1), for attempt=1 results in 2 seconds (2^1 = 2), etc. However, the delay is BASE_DELAY * (2attempt), so for attempt=0, it's 1.0 * 1 = 1 second, and for attempt=4 (the last retry), it's 1.0 * 16 = 16 seconds. This is a reasonable backoff strategy, but could result in long delays. Consider documenting the expected backoff sequence in a comment or adjusting BASE_DELAY if needed.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add 429 support for pulling images |
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 success message from docker pull is not printed, which makes the output silent on success. The original code allowed docker pull to print to stdout/stderr directly. With capture_output=True, successful pulls produce no output, making it harder to debug CI issues. Consider printing a success message or the stdout output on successful pulls to maintain visibility into what's happening during CI runs.