Repository navigation
[ci] Make release pipeline bootstrap survive transient PyPI/GitHub errors - #65538
Closed
elliot-barn wants to merge 2 commits into
Closed
elliot-barn wants to merge 2 commits into
elliot-barn wants to merge 2 commits into
Conversation
…rors The release pipeline's init step generates and uploads every release test step, so a single unretried network failure there means zero release tests run for that nightly. Three consecutive nightly init failures were caused by one transient files.pythonhosted.org 502 each, on a different wheel every time (oauth2client, python-dateutil, cachetools). - .bazelrc: --experimental_repository_downloader_retries was scoped to --config=ci, but the release init step invokes bazel directly without it, so http_archive fetches there had no retries at all. Make it unconditional and raise 3 -> 6. This also covers the rules_python tarball, which is fetched unmirrored from github.com and returned 429 during today's GitHub incident. - .buildkite/release/custom-image-build-and-test-init.sh: retry the bazelisk and uv installer downloads. Archive and release downloads from github.com run at a heavily degraded error rate during an incident. - release/ray_release/byod/byod.Dockerfile: set PIP_RETRIES and UV_HTTP_RETRIES so both the image build and the byod_*.sh scripts that pip install at cluster startup retry, and retry the Microsoft apt key download. curl's --retry already treats HTTP 408/429/500/502/503/504 as transient, so --retry-all-errors is deliberately not used: it needs curl >= 7.71 and would be an unknown-option failure on older agents. Only retry counts are changed, not socket timeouts. Every failure observed was an immediate 502 response or uv exhausting its 3 retries, never a hang, so raising pip's or uv's request timeout would only lengthen the worst-case time to fail. Signed-off-by: elliot-barn <[email protected]>
Premerge failures today were spread across four different pip surfaces, and three of them are ordinary pip/uv invocations inside CI image builds that had no retry configuration at all: - lint: clang_format -- `pip install -c python/requirements_compiled.txt clang-format` in the forge container, OSError / max retries exceeded. - wanda: wheel py3.11 -- `pip install cython setuptools` under the manylinux interpreters, retried and exhausted. - wanda: corebuild-py3.12, llm cpu tests -- uv, "Failed to download everett==3.1.0 / Request failed after 3 retries / 502 Bad Gateway". Set PIP_RETRIES and UV_HTTP_RETRIES on the five roots of the image graph so all 23 descendant images inherit them, at build time and at test time: - base.test.Dockerfile (ubuntu:jammy) -- root of oss-ci-base_test, and via base.build / base.ml the ancestor of most test images. - base.gpu.Dockerfile (nvidia/cuda) -- separate root for the gpu images. - forge.Dockerfile (ubuntu:22.04) -- runs the CI job commands themselves, so it also covers ad hoc pip installs in ci/ scripts. - manylinux.Dockerfile (quay.io/pypa/manylinux2014) -- the wheel builds. - windows.build.Dockerfile (rayproject/buildenv:windows). uv is included because its default is only 3 retries, which was observed being exhausted on a 502. Older uv releases ignore UV_HTTP_RETRIES rather than erroring, and pip needs >= 24.0 for 502 itself to be retryable. The Bazel whl_library surface is deliberately not addressed here: it runs pip with --isolated, so PIP_* never reaches it, and rules_python 0.9.0's vendored pip 22.0.4 omits 502 from urllib3's status_forcelist regardless of retry count. That needs the pip 24.0 pin in #65518. Signed-off-by: elliot-barn <[email protected]>
elliot-barn
force-pushed
the
elliot-barn-release-ci-network-retries
branch
from
August 17, 2026 18:40
dabe629 to
816ba6f
Compare
This was referenced Aug 18, 2026
Closed
elliot-barn
added a commit
that referenced
this pull request
Aug 19, 2026
## Description `files.pythonhosted.org` returns intermittent 502s (pypi/support#11895). Ray CI is hit disproportionately because a single job cold-fetches ~50 wheels concurrently, so it samples the fault dozens of times per job, and `rules_python` shells out to pip inside `whl_library`, where one 502 fails the repository rule and the build with it. **Retries do not fix this, which is why this PR contains none.** Measured on premerge build 72083: pip with `--retries=50` and a jittered 6-12s backoff exhausted on a single wheel with `too many 502 error responses`, while 47 of 62 *job-level* retries in the same build passed. urllib3 retries reuse the pooled connection and the already-resolved address, and anycast keeps every attempt on the same bad Fastly edge, so fifty in-process attempts are not fifty independent attempts. What fixes it is not asking that edge — i.e. a cache in front of PyPI, which fetches each `(package, version)` once and serves it from S3 afterwards. Four commits, in dependency order: 1. **Make the index an environment property.** Valueless `--repo_env` for `PIP_INDEX_URL`, `PIP_EXTRA_INDEX_URL`, `PIP_TRUSTED_HOST` and `RULES_PYTHON_PIP_ISOLATED` in `.bazelrc`, and those plus the `UV_*` equivalents forwarded into nested containers by `ci/ray_ci/container.py`. `RULES_PYTHON_PIP_ISOLATED` is load-bearing: `whl_library` runs pip with `--isolated`, which otherwise makes it ignore every `PIP_*` variable. The passthrough lives in the repo's `.bazelrc` rather than a generated one because every bazel invocation reads it, including the nested ones `ci/ray_ci:test_in_docker` spawns, which a `--config` flag on a step's command line never reaches. 2. **Stop the lock files overriding it.** 97 of the 99 files under `python/deplocks` opened with `--index-url https://pypi.org/simple`, and a requirements file's index URL beats both the environment and the command line. The `--extra-index-url` and `--find-links` entries for PyTorch, libtpu and PyG stay: those are not PyPI, so nothing else supplies them at install time. 3. **Resolve through the mirror when the job can reach it.** The forge image carries `ci/pypi_index_proxy.py` and a `profile.d` script that probes the mirror and picks a mode. ### Why a proxy and not just an index URL One `pip install` is two requests: the project page, governed by `--index-url`, and the artifact, governed by the URL written in that page's body. PyPI's simple index hands out **absolute** `files.pythonhosted.org` URLs, so pointing `--index-url` at a path-prefix byte cache mirrors the metadata request and leaves the multi-megabyte download on the origin that is returning the 502s. The proxy rewrites those file URLs so both hops transit the mirror. Wheels do not stream through the proxy process — clients fetch them straight from the mirror at the rewritten URLs — and the `#sha256=` fragments hash artifact content, not URLs, so hash verification is unaffected. ### Fail-open, deliberately The probe accepts a mode only after a real index fetch succeeds through it, and exports nothing otherwise, leaving pip and uv on public PyPI. That check hits the mirror rather than only the local process because `/healthz` never touches the mirror: a healthy proxy in front of an unreachable mirror answers every request with a 502, which is strictly worse than no proxy. Build 72083 exercised exactly that path — `mirror unreachable from this agent` — and the build continued. ## Related issues Upstream cause: pypi/support#11895. Not a duplicate: commits 1-2 are #65562 and commit 3 is #65563, opened as standalone reviewable units before the mirror existed. If reviewers prefer, land those two first and this rebases down to the single mirror commit. #65518 and #65538 raise pip/uv retry tolerance; they are complementary and deliberately excluded here, per the measurement above. ## Additional information **Depends on infrastructure:** the mirror is a per-VPC deployment in the Ray CI account, so `https://mirror.ci.ray.io` only resolves inside the Buildkite stack VPCs. `RAYCI_PYPI_MIRROR_URL` overrides the default for a fleet that runs its own. **Deliberately out of scope:** image builds still resolve from PyPI. The `pip` and `uv` invocations in `ci/docker/*.Dockerfile` run in a separate BuildKit context that cannot reach a proxy bound on the forge container's loopback, and a per-job address would change wanda's content-addressed cache key on every build and rebuild every image. That needs a build-reachable index, which is a follow-up. `ci/pypi_index_proxy.py` is vendored from a public gist, recorded at the top of the file along with the one local edit (the default mirror URL). ## Testing - `PYTHONPATH=.:release python -m pytest -q ci/ray_ci/test_linux_tester_container.py ci/ray_ci/test_container.py ci/ray_ci/test_tester.py ci/ray_ci/test_linux_container.py ci/ray_ci/test_windows_container.py` — 24 passed. - `bazel test //ci/raydepsets:test_cli` — passed, including `test_diff_lock_files_up_to_date`, the generated-equals-committed invariant for the deplock change. - Bazel 7.5.0: verified that a valueless `common --repo_env=NAME` reaches `rctx.os.environ` in a repository rule and reads unset when the variable is unset, and that `bazel info`/`query`/`version` do not reject the `common` lines. - `docker run --env NAME` with NAME unset leaves it absent in the container, not empty — which is what keeps the default path unchanged. - The mechanism as a whole ran on premerge 72083 (on a superset branch): the probe logged its verdict, fell back to PyPI because that fleet has no route to the mirror at the time, and the build proceeded. - `pre-commit run --files` over every changed file, shellcheck included. AI assistance (Claude Code) was used for this change. --------- Signed-off-by: elliot-barn <[email protected]> Signed-off-by: Elliot Barnwell <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
This pull request has been automatically closed because there has been no more activity in the 14 days Please feel free to reopen or open a new pull request if you'd still like this to be addressed. Again, you can always ask for help on our discussion forum or Ray's public slack channel. Thanks again for your contribution! |
nadongjun
pushed a commit
to nadongjun/ray
that referenced
this pull request
Oct 6, 2026
## Description `files.pythonhosted.org` returns intermittent 502s (pypi/support#11895). Ray CI is hit disproportionately because a single job cold-fetches ~50 wheels concurrently, so it samples the fault dozens of times per job, and `rules_python` shells out to pip inside `whl_library`, where one 502 fails the repository rule and the build with it. **Retries do not fix this, which is why this PR contains none.** Measured on premerge build 72083: pip with `--retries=50` and a jittered 6-12s backoff exhausted on a single wheel with `too many 502 error responses`, while 47 of 62 *job-level* retries in the same build passed. urllib3 retries reuse the pooled connection and the already-resolved address, and anycast keeps every attempt on the same bad Fastly edge, so fifty in-process attempts are not fifty independent attempts. What fixes it is not asking that edge — i.e. a cache in front of PyPI, which fetches each `(package, version)` once and serves it from S3 afterwards. Four commits, in dependency order: 1. **Make the index an environment property.** Valueless `--repo_env` for `PIP_INDEX_URL`, `PIP_EXTRA_INDEX_URL`, `PIP_TRUSTED_HOST` and `RULES_PYTHON_PIP_ISOLATED` in `.bazelrc`, and those plus the `UV_*` equivalents forwarded into nested containers by `ci/ray_ci/container.py`. `RULES_PYTHON_PIP_ISOLATED` is load-bearing: `whl_library` runs pip with `--isolated`, which otherwise makes it ignore every `PIP_*` variable. The passthrough lives in the repo's `.bazelrc` rather than a generated one because every bazel invocation reads it, including the nested ones `ci/ray_ci:test_in_docker` spawns, which a `--config` flag on a step's command line never reaches. 2. **Stop the lock files overriding it.** 97 of the 99 files under `python/deplocks` opened with `--index-url https://pypi.org/simple`, and a requirements file's index URL beats both the environment and the command line. The `--extra-index-url` and `--find-links` entries for PyTorch, libtpu and PyG stay: those are not PyPI, so nothing else supplies them at install time. 3. **Resolve through the mirror when the job can reach it.** The forge image carries `ci/pypi_index_proxy.py` and a `profile.d` script that probes the mirror and picks a mode. ### Why a proxy and not just an index URL One `pip install` is two requests: the project page, governed by `--index-url`, and the artifact, governed by the URL written in that page's body. PyPI's simple index hands out **absolute** `files.pythonhosted.org` URLs, so pointing `--index-url` at a path-prefix byte cache mirrors the metadata request and leaves the multi-megabyte download on the origin that is returning the 502s. The proxy rewrites those file URLs so both hops transit the mirror. Wheels do not stream through the proxy process — clients fetch them straight from the mirror at the rewritten URLs — and the `#sha256=` fragments hash artifact content, not URLs, so hash verification is unaffected. ### Fail-open, deliberately The probe accepts a mode only after a real index fetch succeeds through it, and exports nothing otherwise, leaving pip and uv on public PyPI. That check hits the mirror rather than only the local process because `/healthz` never touches the mirror: a healthy proxy in front of an unreachable mirror answers every request with a 502, which is strictly worse than no proxy. Build 72083 exercised exactly that path — `mirror unreachable from this agent` — and the build continued. ## Related issues Upstream cause: pypi/support#11895. Not a duplicate: commits 1-2 are ray-project#65562 and commit 3 is ray-project#65563, opened as standalone reviewable units before the mirror existed. If reviewers prefer, land those two first and this rebases down to the single mirror commit. ray-project#65518 and ray-project#65538 raise pip/uv retry tolerance; they are complementary and deliberately excluded here, per the measurement above. ## Additional information **Depends on infrastructure:** the mirror is a per-VPC deployment in the Ray CI account, so `https://mirror.ci.ray.io` only resolves inside the Buildkite stack VPCs. `RAYCI_PYPI_MIRROR_URL` overrides the default for a fleet that runs its own. **Deliberately out of scope:** image builds still resolve from PyPI. The `pip` and `uv` invocations in `ci/docker/*.Dockerfile` run in a separate BuildKit context that cannot reach a proxy bound on the forge container's loopback, and a per-job address would change wanda's content-addressed cache key on every build and rebuild every image. That needs a build-reachable index, which is a follow-up. `ci/pypi_index_proxy.py` is vendored from a public gist, recorded at the top of the file along with the one local edit (the default mirror URL). ## Testing - `PYTHONPATH=.:release python -m pytest -q ci/ray_ci/test_linux_tester_container.py ci/ray_ci/test_container.py ci/ray_ci/test_tester.py ci/ray_ci/test_linux_container.py ci/ray_ci/test_windows_container.py` — 24 passed. - `bazel test //ci/raydepsets:test_cli` — passed, including `test_diff_lock_files_up_to_date`, the generated-equals-committed invariant for the deplock change. - Bazel 7.5.0: verified that a valueless `common --repo_env=NAME` reaches `rctx.os.environ` in a repository rule and reads unset when the variable is unset, and that `bazel info`/`query`/`version` do not reject the `common` lines. - `docker run --env NAME` with NAME unset leaves it absent in the container, not empty — which is what keeps the default path unchanged. - The mechanism as a whole ran on premerge 72083 (on a superset branch): the probe logged its verdict, fell back to PyPI because that fleet has no route to the mirror at the time, and the build proceeded. - `pre-commit run --files` over every changed file, shellcheck included. AI assistance (Claude Code) was used for this change. --------- Signed-off-by: elliot-barn <[email protected]> Signed-off-by: Elliot Barnwell <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A transient
files.pythonhosted.org502 currently fails a CI or release build outright, because almost nothing on the PyPI fetch path retries. Today that produced red across both pipelines all day, including three consecutive nightly release failures that ran zero release tests.This PR adds retries on every PyPI/GitHub fetch surface in the repo. It is intentionally broad so CI can be taken green in one shot; it is straightforward to split along the commit boundaries (release bootstrap vs. CI images) afterwards.
Why one 502 is fatal
Nightly release build 104422 failed three times, each on a single 502 on a different wheel:
oauth2client-4.1.3python_dateutil-2.9.0.post0cachetools-5.3.3Each cascaded identically:
whl_library py_deps_py310_<pkg> failed→Analysis of target '//release:custom_image_build_and_test_init' failed→ exit 1, no pipeline uploaded. Theinitstep generates and uploads every release test step, so losing it loses the whole nightly.Confirmed 502s at 02:13, 05:04, 06:59, 16:29, 16:41 and 17:13 UTC — a sustained >15-hour condition that
status.python.orgnever posted an incident for. A job cold-fetching 47-55 wheel repositories is unlikely to survive that without retries anywhere.The four pip surfaces
Failures were spread across four independent surfaces. Sampling premerge 71970 and 71973, every failure traced to a 502, but on different pips:
whl_librarycore: python tests,data: arrow v17— rawHTTP error 502onpy_deps_py310_*timeouthere)lint: clang_format—pip install -c python/requirements_compiled.txt clang-formatwanda: wheel py3.11—pip install cython setuptools, retried and exhaustedwanda: corebuild-py3.12,llm cpu tests—Failed to download everett==3.1.0 / Request failed after 3 retries / 502 Bad GatewayChanges
.bazelrc— downloader retries were--config=cionly--experimental_repository_downloader_retrieswas scoped tobuild:ci, but.buildkite/release/custom-image-build-and-test-init.shinvokes bazel directly with no--config=ci, sohttp_archivefetches in the step that builds the entire release pipeline had no retries at all. Made unconditional, raised 3 → 6. This also covers therules_python0.9.0 tarball, fetched unmirrored fromgithub.com, which returned429 Too Many Requestsduring today's GitHub incident (premerge 71978).WORKSPACE—pip_parsetimeout headroomwhl_libraryshells out to pip, so Bazel's downloader retries never apply to wheel fetches and pip must retry itself. Retrying costs wall clock, and rules_python defaults the per-whl_librarysubprocess ceiling to 600s. Verified the attribute reaches every generatedwhl_library:pip_repositoryforwards it as--timeout(pip_repository.bzl:156-160) →whl_library_args = dict(vars(args))(parse_requirements_to_bzl/__init__.py:60) →_config→**_configsplatted byinstall_deps()→rctx.execute(timeout = rctx.attr.timeout). Without the headroom, #65518's retries can be cut off mid-flight and surface as an opaque Bazel timeout instead of the underlying HTTP error.custom-image-build-and-test-init.sh— bootstrap downloadsThe bazelisk binary and uv installer are fetched with no retry. GitHub's incident today reported "Archive downloads and raw repository content downloads are experiencing an approximate 50% error rate" — a coin flip on the step that gates all release testing.
--retry-all-errorsis deliberately not used: it requires curl >= 7.71 and would be an unknown-option hard failure on older agents. Plain--retryalready treats HTTP 408/429/500/502/503/504 as transient, which is exactly this failure mode.CI image roots —
PIP_RETRIES/PIP_DEFAULT_TIMEOUT/UV_HTTP_RETRIES/UV_HTTP_TIMEOUTSet on the five roots of the image graph so all 23 descendant images inherit them, at build time and test time:
base.test.Dockerfileubuntu:jammyoss-ci-base_test; viabase.build/base.mlthe ancestor of most test imagesbase.gpu.Dockerfilenvidia/cudaforge.Dockerfileubuntu:22.04pip installs inci/scriptsmanylinux.Dockerfilequay.io/pypa/manylinux2014windows.build.Dockerfilerayproject/buildenv:windowsbyod.Dockerfilegets the same block, declared before itsRUNso the build picks it up and kept in the image so thebyod_*.shscripts thatpip installat cluster startup inherit it. Its Microsoft apt key download gets--retrytoo.uv is included because its default is only 3 retries, observed being exhausted on a 502. Older uv ignores
UV_HTTP_RETRIESrather than erroring;PIP_*is read because none of these pip invocations use--isolated.Related issues
None tracked. Complements #65518, which pins pip 24.0 so
whl_libraryretries 502 at all — without it the Bazel surface stays broken, since rules_python 0.9.0's vendored pip 22.0.4 omits 502 from urllib3'sstatus_forcelist. The only file overlap isWORKSPACE, where #65518 addsenvironment/extra_pip_argsto the samepip_parsecall and this addstimeout; whichever lands second needs a trivial conflict resolution.Additional information
Scope
Mitigation, not a structural fix. Retries make transient failures survivable, but a sustained outage still fails — #65518's own premerge shows nine retries being exhausted. The structural fixes are a pre-populated Bazel
--repository_cachein the forge image, or an internal PyPI pull-through mirror (there is noPIP_INDEX_URLor proxy configured anywhere in the repo today). Both are out of scope.Known remaining gap, deliberately not addressed:
git clone https://github.com/wg/wrk.gitinbyod.Dockerfilehas no retry, andgit clonehas no equivalent flag — it would need a wrapper loop.Tests run
buildifier --mode=check --lint=warn WORKSPACEbash -n .buildkite/release/custom-image-build-and-test-init.shshellcheck -S warning .buildkite/release/custom-image-build-and-test-init.shpre-commit run --files <all 9 changed files>UV_HTTP_RETRIES=<bad> uv pip install --dry-run requests--retrytransient-code coverage--retry-all-errorsavoided as curl >= 7.71 onlyNot run: a full
bazel fetchof the release init target, and the image builds themselves, which need CI infrastructure and a healthy PyPI. Premerge on this PR is the real test.AI assistance
This change was developed with AI assistance (Claude Code). The investigation — correlating the three nightly init failures to one 502 each on a different wheel, tracing the
pip_parsetimeoutpropagation through rules_python 0.9.0, finding that the release init step never passes--config=ci, classifying premerge failures by which pip surface they occur on, and auditing the image graph for its roots — was AI-assisted and then verified with the commands above.