Skip to content

[ci] Resolve Windows packages through the CI mirror - #65598

Closed
elliot-barn wants to merge 1 commit into
masterfrom
elliot-barn/windows-pypi-proxy
Closed

elliot-barn wants to merge 1 commit into
masterfrom
elliot-barn/windows-pypi-proxy

Conversation

@elliot-barn

Copy link
Copy Markdown
Collaborator

Stacked on #65597 — base branch is elliot-barn/proxy-host-support, since both need the same shared-script changes. Review that one first; GitHub will retarget this to master when it merges.

Description

Windows had no mirror wiring at all, and it is the platform actively breaking release
wheels. windows_wheels carries the release_wheels tag and uploads for 3.10 through
3.14, so a 502 there leaves the published wheel set short a platform. Observed on
premerge 72138 and again on postmerge 19272, both whl_library fetching
bazel-runfiles==0.31.0.

The important detail is where it fails — a docker build, not a plain container command:

Step 17/18 : RUN bash ci/ray_ci/windows/build_ray.sh
  + pip install -v -e python
  → bazel build //:gen_ray_pkg → whl_library → HTTP error 502

Approach

The proxy runs inside that container on loopback, rather than on the agent. Two
reasons:

  • The Windows agent host carries Python 3.8, below what the proxy supports, so a
    host-side proxy would mean installing an interpreter per job. The image's conda python
    is 3.10, which is enough — the only dependency requiring 3.11 is skipped by the
    installer and guarded at import (see [ci] Resolve macOS packages through the CI mirror #65597).
  • A host-side proxy would also have to be discovered from inside the container by
    address. Loopback needs none of that, and pip and uv exempt loopback from their
    refusal to use a plain-HTTP index.

The venv is baked into the windowsbuild image by build_base.sh, so nothing is
installed at job time.

What changed

  • ci/ray_ci/windows/pypi_proxy.sh — new, sourceable. Hands off to
    ci/pypi_proxy_profile.sh for the mirror probe, mode selection, readiness wait and
    fail-open paths rather than reimplementing them.
  • build_base.sh + windows.build.wanda.yaml — install the proxy into the image
    and put the files in the build context.
  • build_ray.sh — sourced before pip install -e python, covering the tester's
    image build, which is where the observed failures are.
  • windows_builder_container.py — sourced before build-wheel-windows.sh. The
    wheel path is a docker run, not a docker build, and its commands are joined into
    one bash invocation, so the exports carry through.
  • install_pypi_proxy.sh / pypi_proxy_profile.sh — Windows venvs put the
    interpreter in Scripts/ rather than bin/, so the installer locates the script
    directory and the profile script takes RAYCI_PYPI_PROXY_PYTHON.

What this does not cover

The wanda: windowsbuild image build itself still resolves from PyPI. Those jobs are
not containerised and have no proxy in scope, which is the same gap ray#65578 is waiting
on. Also unchanged: the host-side installs in install_tools.sh (awscli, the windows
depset), which would need an interpreter on the 3.8 host.

Related issues

Upstream cause: pypi/support#11895. Not a duplicate: no open PR touches the Windows CI
scripts. #65597 changes the shared installer and profile script and is the base of this
branch; #65593 pins the index representation and does not overlap.

Testing

  • pre-commit (shellcheck, black, semgrep, ruff) clean on every changed file.
  • pytest ci/ray_ci/test_windows_container.py passes.
    test_windows_tester_container.py::test_init fails, but it fails identically on
    origin/master — it asserts a docker build argument order this branch does not
    touch.
  • The proxy itself is exercised by the tests described in [ci] Resolve macOS packages through the CI mirror #65597: it starts and serves
    on Python 3.10 with the 3.11-only dependency absent, and the index it serves has
    artifact URLs rewritten onto the mirror.

Not verified: a real Windows agent, which needs this branch in CI — specifically that
the container can reach mirror.ci.ray.io and that the loopback bind behaves the same
under Windows containers. Both failure modes are a printed warning and a job that
resolves from PyPI, which is today's behaviour rather than a new failure.

AI assistance (Claude Code) was used for this change.

@elliot-barn
elliot-barn requested review from a team as code owners August 19, 2026 18:22

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1136f79. Configure here.

Comment thread ci/ray_ci/windows/build_ray.sh Resolved

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a PyPI index proxy for Windows CI builds to resolve package installations through the CI package mirror. This is achieved by updating the Windows build configuration, adding a new pypi_proxy.sh script, and adapting the existing proxy scripts to handle Windows-specific virtual environment paths (e.g., using Scripts/ instead of bin/). Feedback was provided to make the profile script more robust by automatically detecting the Windows Scripts/python.exe path if it exists, rather than relying solely on the caller to set the environment variable.

Comment thread ci/pypi_proxy_profile.sh
if [[ ! -x "${prefix}/bin/python" ]]; then
# Windows venvs put python in Scripts/ rather than bin/, so callers on that platform
# name the interpreter instead of having it derived.
local proxy_python="${RAYCI_PYPI_PROXY_PYTHON:-${prefix}/bin/python}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To make the profile script more self-contained and robust across platforms, we can automatically detect the Windows Scripts/python.exe path if it exists, rather than strictly relying on the caller to set RAYCI_PYPI_PROXY_PYTHON.

Suggested change
local proxy_python="${RAYCI_PYPI_PROXY_PYTHON:-${prefix}/bin/python}"
local proxy_python="${RAYCI_PYPI_PROXY_PYTHON:-}"
if [[ -z "${proxy_python}" ]]; then
if [[ -x "${prefix}/Scripts/python.exe" ]]; then
proxy_python="${prefix}/Scripts/python.exe"
else
proxy_python="${prefix}/bin/python"
fi
fi

@ray-gardener ray-gardener Bot added the devprod label Aug 19, 2026
elliot-barn added a commit that referenced this pull request Aug 19, 2026
**Stacked on #65597** — base branch is `elliot-barn/proxy-host-support`,
which carries the off-image install support this depends on (an install
prefix, a skip-profile switch, and the guarded import that lets the
proxy run on 3.10). Review that one first; GitHub will retarget this to
master when it merges.

See #65600 for how this fits with the rest.

## Description

The images cover the steps that run inside them: forge and manylinux
each carry the proxy and start it from `/etc/profile.d`. What no image
can cover is anything that **never enters a container** — the release
pipeline's `init` step, and every wanda image build, both of which run
directly on the agent.

Those are the surfaces still resolving from `files.pythonhosted.org`
(pypi/support#11895), and `init` is the one that hurts: when it fails,
**zero release tests run**. It failed on the mirror-merge commit itself
(release 104738, on `c1bac99054`), and 104422 only got through after
three retries.

`.buildkite/hooks/pre-command` runs on the agent before every step,
**including wanda steps**, so it is the one place that reaches them.

## Two addresses, because they serve different consumers

```
PIP_INDEX_URL              http://127.0.0.1:35999/simple
RAYCI_IMAGE_PIP_INDEX_URL  http://<docker bridge gateway>:35999/simple
```

The first is for pip and uv running on the agent itself — loopback, so
both accept it over plain HTTP with no trusted-host handling. The second
is for docker builds, which have their own loopback and reach the agent
on the bridge gateway.

That second one is what unparks **#65578**: wanda resolves build args
from its own process environment, so exporting it is what lets an image
build use the mirror. Until now nothing set it, so the `ARG` defaulted
to empty and every image build silently fell back to PyPI.

## Reachability was measured, not assumed

On premerge 72149, a `docker build` RUN step reached a proxy outside its
network namespace on **both the BuildKit and legacy builders, with
default networking and no `--network=host`**:

```
DOCKER_BUILDKIT=1  network=default   build -> job-local proxy: REACHED (HTTP 200)
DOCKER_BUILDKIT=1  network=host      build -> job-local proxy: REACHED (HTTP 200)
DOCKER_BUILDKIT=0  network=default   build -> job-local proxy: REACHED (HTTP 200)
DOCKER_BUILDKIT=0  network=host      build -> job-local proxy: REACHED (HTTP 200)
```

## Fail-open, deliberately and everywhere

The hook runs under `set -e`, and a package mirror must never be the
reason a job fails. Every path leaves the environment untouched — an
unreachable mirror, no suitable interpreter, a failed install, a proxy
that starts but cannot serve — and a step that gets nothing exported
resolves from public PyPI exactly as it does today. Hence `source … ||
true` at the call site.

That includes the install itself, which necessarily fetches from PyPI
and so can hit the very fault being worked around. It is never worse
than not trying.

## Notes for review

- **`RAYCI_PYPI_PROXY_PYTHON`** names the interpreter for agents where
the search would not find one. The Windows host carries 3.8, below what
the proxy supports, so it needs one provisioned separately (`uv python
install`) and named here.
- **The agent-side cost differs by platform.** Linux agents terminate
per job, so the install runs each time; macOS and Windows agents are
long-lived with a persistent `HOME`, so their venv is built once per
machine. A follow-up worth considering is running the proxy *from* the
forge image rather than installing it, since the venv is already baked
in there — but the forge tag is per-build and does not exist yet for
early jobs, so it cannot be the primary mechanism.
- **The proxy is probed through, not just pinged.** `/healthz` does not
touch the mirror, so a process that is up but cannot reach its upstream
would otherwise be advertised as working.

## Related issues

Upstream cause: pypi/support#11895. Not a duplicate: no open PR adds an
agent-side proxy. #65597 and #65598 wire macOS and Windows from inside
their own scripts and this supersedes the need for that on the agent
side; #65578 is the consumer of `RAYCI_IMAGE_PIP_INDEX_URL`.

## Testing

Exercised end to end against a stub mirror on Linux:

- installs to a user-writable prefix with no sudo, starts the proxy, and
exports both addresses with the bridge gateway detected automatically
(`http://172.17.0.1:35999/simple`)
- the index it serves has artifact URLs rewritten onto the mirror
- **fail-open verified twice** — with a deliberately broken interpreter
(`ensurepip` failure) and with an unreachable mirror, both printed a
warning and exported nothing
- `pre-commit` (shellcheck) clean

Not verified: a real agent of any kind, and the interaction with a real
wanda image build. The failure mode if the gateway detection or the
install is wrong on a real agent is a printed warning and a job that
resolves from PyPI, which is the status quo rather than a new failure.

AI assistance (Claude Code) was used for this change.

Signed-off-by: elliot-barn <[email protected]>
elliot-barn added a commit that referenced this pull request Aug 19, 2026
**Stacked on #65597** — base branch is `elliot-barn/proxy-host-support`,
which carries the off-image install support this depends on (an install
prefix, a skip-profile switch, and the guarded import that lets the
proxy run on 3.10). Review that one first; GitHub will retarget this to
master when it merges.

See #65600 for how this fits with the rest.

## Description

The images cover the steps that run inside them: forge and manylinux
each carry the proxy and start it from `/etc/profile.d`. What no image
can cover is anything that **never enters a container** — the release
pipeline's `init` step, and every wanda image build, both of which run
directly on the agent.

Those are the surfaces still resolving from `files.pythonhosted.org`
(pypi/support#11895), and `init` is the one that hurts: when it fails,
**zero release tests run**. It failed on the mirror-merge commit itself
(release 104738, on `c1bac99054`), and 104422 only got through after
three retries.

`.buildkite/hooks/pre-command` runs on the agent before every step,
**including wanda steps**, so it is the one place that reaches them.

## Two addresses, because they serve different consumers

```
PIP_INDEX_URL              http://127.0.0.1:35999/simple
RAYCI_IMAGE_PIP_INDEX_URL  http://<docker bridge gateway>:35999/simple
```

The first is for pip and uv running on the agent itself — loopback, so
both accept it over plain HTTP with no trusted-host handling. The second
is for docker builds, which have their own loopback and reach the agent
on the bridge gateway.

That second one is what unparks **#65578**: wanda resolves build args
from its own process environment, so exporting it is what lets an image
build use the mirror. Until now nothing set it, so the `ARG` defaulted
to empty and every image build silently fell back to PyPI.

## Reachability was measured, not assumed

On premerge 72149, a `docker build` RUN step reached a proxy outside its
network namespace on **both the BuildKit and legacy builders, with
default networking and no `--network=host`**:

```
DOCKER_BUILDKIT=1  network=default   build -> job-local proxy: REACHED (HTTP 200)
DOCKER_BUILDKIT=1  network=host      build -> job-local proxy: REACHED (HTTP 200)
DOCKER_BUILDKIT=0  network=default   build -> job-local proxy: REACHED (HTTP 200)
DOCKER_BUILDKIT=0  network=host      build -> job-local proxy: REACHED (HTTP 200)
```

## Fail-open, deliberately and everywhere

The hook runs under `set -e`, and a package mirror must never be the
reason a job fails. Every path leaves the environment untouched — an
unreachable mirror, no suitable interpreter, a failed install, a proxy
that starts but cannot serve — and a step that gets nothing exported
resolves from public PyPI exactly as it does today. Hence `source … ||
true` at the call site.

That includes the install itself, which necessarily fetches from PyPI
and so can hit the very fault being worked around. It is never worse
than not trying.

## Notes for review

- **`RAYCI_PYPI_PROXY_PYTHON`** names the interpreter for agents where
the search would not find one. The Windows host carries 3.8, below what
the proxy supports, so it needs one provisioned separately (`uv python
install`) and named here.
- **The agent-side cost differs by platform.** Linux agents terminate
per job, so the install runs each time; macOS and Windows agents are
long-lived with a persistent `HOME`, so their venv is built once per
machine. A follow-up worth considering is running the proxy *from* the
forge image rather than installing it, since the venv is already baked
in there — but the forge tag is per-build and does not exist yet for
early jobs, so it cannot be the primary mechanism.
- **The proxy is probed through, not just pinged.** `/healthz` does not
touch the mirror, so a process that is up but cannot reach its upstream
would otherwise be advertised as working.

## Related issues

Upstream cause: pypi/support#11895. Not a duplicate: no open PR adds an
agent-side proxy. #65597 and #65598 wire macOS and Windows from inside
their own scripts and this supersedes the need for that on the agent
side; #65578 is the consumer of `RAYCI_IMAGE_PIP_INDEX_URL`.

## Testing

Exercised end to end against a stub mirror on Linux:

- installs to a user-writable prefix with no sudo, starts the proxy, and
exports both addresses with the bridge gateway detected automatically
(`http://172.17.0.1:35999/simple`)
- the index it serves has artifact URLs rewritten onto the mirror
- **fail-open verified twice** — with a deliberately broken interpreter
(`ensurepip` failure) and with an unreachable mirror, both printed a
warning and exported nothing
- `pre-commit` (shellcheck) clean

Not verified: a real agent of any kind, and the interaction with a real
wanda image build. The failure mode if the gateway detection or the
install is wrong on a real agent is a printed warning and a job that
resolves from PyPI, which is the status quo rather than a new failure.

AI assistance (Claude Code) was used for this change.

Signed-off-by: Elliot Barnwell <[email protected]>
@elliot-barn
elliot-barn changed the base branch from elliot-barn/proxy-host-support to master August 19, 2026 22:37
elliot-barn added a commit that referenced this pull request Aug 19, 2026
## Description

Bazel's downloader is a separate surface from pip's index, and nothing
was pointing it at
the mirror. `rules_python` declares its bootstrap wheels as
`http_archive` with literal
`files.pythonhosted.org` URLs, and `http_archive` never consults
`PIP_INDEX_URL` — so no
index setting we have reaches them.

That is what failed microcheck 52470 and the docs-example jobs on
postmerge 19272 —
bazel's own Java downloader, not pip:

```
WARNING: Download from https://files.pythonhosted.org/packages/…/click-8.0.1-py3-none-any.whl failed
Error in download_and_extract: java.io.IOException: Error downloading […click-8.0.1…]
ERROR: Error computing the main repository mapping: … no such package '@@py_deps_py310//'
```

It fails during repository mapping, so a single 502 takes the whole
analysis phase with
it rather than one target.

## What changed

When the mirror is reachable, the profile script now writes a bazel
downloader config and
points `~/.bazelrc` at it:

```
rewrite files\.pythonhosted\.org/(.*) mirror.ci.ray.io/files.pythonhosted.org/$1
```

```
common --experimental_downloader_config=/tmp/rayci_bazel_downloader.cfg
```

Bazel rewrites the URL before fetching, so those archives come from the
mirror. This is a
different mechanism from the index proxy: no proxy process, no content
negotiation, no
per-job address — which is also why it is set up **before** the proxy
checks. An image
that carries no proxy still gets its bazel downloads mirrored.

Written per job rather than committed to `.bazelrc` because the hostname
is VPC-internal:
a checkout outside CI would rewrite its downloads to a name that does
not resolve,
turning a working build into a broken one.

## Why this is worth having beyond the observed failure

Bazel's downloader also fetches the github.com release tarballs, and the
mirror is
host-prefixed so it already serves those. Extending the same config to
github is a
one-line follow-up, and would have covered the `rules_python` tarball
429s from the
GitHub incident on 2026-08-17. Left out here to keep the change to the
surface actually
measured.

## Related issues

Upstream cause: pypi/support#11895. Not a duplicate: no open PR touches
bazel's downloader
configuration — `grep -rn experimental_downloader_config` comes back
empty on master.
#65593, #65597 and #65598 all concern the pip/uv index path and do not
overlap with this
mechanism.

## Testing

Verified against bazel 7.5.0 locally, with a throwaway workspace whose
`http_archive`
points at the same `click-8.0.1` wheel that failed in CI:

- **The rewrite applies and the scheme is preserved.** With the target
host set to a
  deliberately nonexistent name, bazel reports
`Download from https://mirror.invalid/files.pythonhosted.org/packages/…`
— confirming
  both the URL shape and that `https` carries over.
- **The generated config is accepted by bazel**, escaping intact: the
config this script
  writes produced
`Download from
https://127.0.0.1:38120/files.pythonhosted.org/packages/…`, i.e. parsed
  and applied rather than rejected.
- **An identity rewrite does not break a working download**:
`All external dependencies for the requested targets fetched
successfully`.
- **`common` is a safe scope** for the flag — `bazel version` and `bazel
query` both run
  clean with it in `~/.bazelrc`, no unrecognized-option error.
- **Guards**: an `http://` mirror prints
`mirror is not https, leaving bazel downloads on the origin` and writes
no config,
because bazel would otherwise address an http-only host as https and
fail in a way that
looks like a broken mirror. An unreachable mirror bails at the existing
probe before any
  bazel setup. The bazelrc line is appended only once.
- `pre-commit` (shellcheck) clean.

Not verified: a real CI job against the real mirror, which is what the
first build on this
branch shows. The failure mode if the mirror cannot serve an artifact is
a bazel download
error naming `mirror.ci.ray.io`, which is distinguishable at a glance
from the origin
failing.

AI assistance (Claude Code) was used for this change.

---------

Signed-off-by: elliot-barn <[email protected]>
Windows is the last platform still resolving from files.pythonhosted.org
(pypi/support#11895), and it needs its own entry point: the two places that
install packages there are not login shells, so the profile.d hook the Linux
images use never runs. `RUN bash build_ray.sh` inside the docker build the
tester starts, and the command list the wheel builder passes to `docker run`,
both source ci/ray_ci/windows/pypi_proxy.sh explicitly.

The proxy runs inside the container on loopback rather than on the agent. The
Windows host carries Python 3.8, below what the proxy supports, while conda
in the image supplies 3.10 -- enough, since the only dependency needing 3.11
is skipped by the installer and guarded at import. Loopback also means pip and
uv accept it over plain HTTP with no trusted-host handling, and the venv is
baked into the windowsbuild image by build_base.sh, so nothing is installed at
job time.

Two shared pieces gain Windows support rather than being copied:
install_pypi_proxy.sh picks Scripts/ over bin/ for the venv, and
pypi_proxy_profile.sh takes the interpreter from RAYCI_PYPI_PROXY_PYTHON when
a caller names it, which ci/pypi_proxy_agent.sh already does for the same
reason.

Every failure path leaves the environment untouched, so a job resolves from
public PyPI exactly as it does today.

Rebased onto master: the earlier revision of this branch predated the agent
hook (#65602), the bazel downloader rewrite (#65599) and the index-shape
correction (#65603), and would have reverted all three.

Tested: bash -n over the five touched shell scripts. The Windows paths
themselves need a windowsbuild image build to exercise, which is what this
PR's premerge does.

AI assistance was used for this change.

Signed-off-by: Elliot Barnwell <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
@elliot-barn
elliot-barn force-pushed the elliot-barn/windows-pypi-proxy branch from 1136f79 to 01d00d1 Compare August 20, 2026 00:45
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

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.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Sep 3, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no more activity in the 14 days
since being marked stale.

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!

@github-actions github-actions Bot closed this Sep 17, 2026
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
## Description

Bazel's downloader is a separate surface from pip's index, and nothing
was pointing it at
the mirror. `rules_python` declares its bootstrap wheels as
`http_archive` with literal
`files.pythonhosted.org` URLs, and `http_archive` never consults
`PIP_INDEX_URL` — so no
index setting we have reaches them.

That is what failed microcheck 52470 and the docs-example jobs on
postmerge 19272 —
bazel's own Java downloader, not pip:

```
WARNING: Download from https://files.pythonhosted.org/packages/…/click-8.0.1-py3-none-any.whl failed
Error in download_and_extract: java.io.IOException: Error downloading […click-8.0.1…]
ERROR: Error computing the main repository mapping: … no such package '@@py_deps_py310//'
```

It fails during repository mapping, so a single 502 takes the whole
analysis phase with
it rather than one target.

## What changed

When the mirror is reachable, the profile script now writes a bazel
downloader config and
points `~/.bazelrc` at it:

```
rewrite files\.pythonhosted\.org/(.*) mirror.ci.ray.io/files.pythonhosted.org/$1
```

```
common --experimental_downloader_config=/tmp/rayci_bazel_downloader.cfg
```

Bazel rewrites the URL before fetching, so those archives come from the
mirror. This is a
different mechanism from the index proxy: no proxy process, no content
negotiation, no
per-job address — which is also why it is set up **before** the proxy
checks. An image
that carries no proxy still gets its bazel downloads mirrored.

Written per job rather than committed to `.bazelrc` because the hostname
is VPC-internal:
a checkout outside CI would rewrite its downloads to a name that does
not resolve,
turning a working build into a broken one.

## Why this is worth having beyond the observed failure

Bazel's downloader also fetches the github.com release tarballs, and the
mirror is
host-prefixed so it already serves those. Extending the same config to
github is a
one-line follow-up, and would have covered the `rules_python` tarball
429s from the
GitHub incident on 2026-08-17. Left out here to keep the change to the
surface actually
measured.

## Related issues

Upstream cause: pypi/support#11895. Not a duplicate: no open PR touches
bazel's downloader
configuration — `grep -rn experimental_downloader_config` comes back
empty on master.
ray-project#65593, ray-project#65597 and ray-project#65598 all concern the pip/uv index path and do not
overlap with this
mechanism.

## Testing

Verified against bazel 7.5.0 locally, with a throwaway workspace whose
`http_archive`
points at the same `click-8.0.1` wheel that failed in CI:

- **The rewrite applies and the scheme is preserved.** With the target
host set to a
  deliberately nonexistent name, bazel reports
`Download from https://mirror.invalid/files.pythonhosted.org/packages/…`
— confirming
  both the URL shape and that `https` carries over.
- **The generated config is accepted by bazel**, escaping intact: the
config this script
  writes produced
`Download from
https://127.0.0.1:38120/files.pythonhosted.org/packages/…`, i.e. parsed
  and applied rather than rejected.
- **An identity rewrite does not break a working download**:
`All external dependencies for the requested targets fetched
successfully`.
- **`common` is a safe scope** for the flag — `bazel version` and `bazel
query` both run
  clean with it in `~/.bazelrc`, no unrecognized-option error.
- **Guards**: an `http://` mirror prints
`mirror is not https, leaving bazel downloads on the origin` and writes
no config,
because bazel would otherwise address an http-only host as https and
fail in a way that
looks like a broken mirror. An unreachable mirror bails at the existing
probe before any
  bazel setup. The bazelrc line is appended only once.
- `pre-commit` (shellcheck) clean.

Not verified: a real CI job against the real mirror, which is what the
first build on this
branch shows. The failure mode if the mirror cannot serve an artifact is
a bazel download
error naming `mirror.ci.ray.io`, which is distinguishable at a glance
from the origin
failing.

AI assistance (Claude Code) was used for this change.

---------

Signed-off-by: elliot-barn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devprod stale The issue is stale. It will be closed within 7 days unless there are further conversation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant