Repository navigation
ci: persist Bazel's repository cache across runs and retry the first fetch, so proxy.golang.org flakes stop failing jobs (#1001) - #1016
Merged
Conversation
…fetch, so proxy.golang.org flakes stop failing jobs (#1001) The repository cache was already restored (setup-bazel repository-cache: true) but keyed on the root MODULE.bazel alone, shared with the proxy workspace's jobs, and saved by whichever job finished first. A job that fetched little -- or a proxy job -- could write the entry every later job restored as an exact hit and never re-saved, which is how #995's netns job fetched googleapis/api from proxy.golang.org with a 1.9 GB cache freshly restored. - Key on MODULE.bazel + MODULE.bazel.lock + go.mod + go.sum (root) and proxy/MODULE.bazel + proxy/MODULE.bazel.lock (proxy), in separate cache-version namespaces (root-1 / proxy-1). - One saver per workflow (ci/main `diff`, the proxy build matrix per arch), whose warm-up fetches for all of //...; every other job cache-save: false. - scripts/ci-bazel-warmup.sh: `bazel build --nobuild` as each job's first Bazel step, retried 3x with 20s/40s backoff only on a repository-fetch error, never talking to BuildBuddy. scripts/check-ci-bazel-warmup.sh pins the contract with a stub bazel in the `shell` job. - docs/runbook.md: "CI: external repository fetches". Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
#1001) Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 27, 2026
Brings in #1016 (repository-cache keys, cache-save: false, ci-bazel-warmup first steps), #1019 and #1012. publish.yaml keeps both sides: the #1016 setup-bazel cache settings and warm-up step, then the release-environment Quay robot login. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
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.
The two flakes
On 2026-09-27 two unrelated PRs went red the same way and passed on a plain re-run:
test:gazelle++go_deps+com_github_go_openapi_swag: fetch_repo: … proxy.golang.org/…/@v/v0.29.2.info: net/http: TLS handshake timeoutnetns(job 108649813512):gazelle++go_deps+org_golang_google_genproto_googleapis_api: fetch_repo: … TLS handshake timeoutThe #995 log is the useful one. The repository cache was already restored, as an exact hit, 1.9 GB:
and that module has been in
go.modsince #749 (2026-09-12). So "persist the repository cache" was half-done; what was wrong is what got persisted:repository-cache: truehashesMODULE.bazelonly. Ago.sumbump keeps the key, so the entry is an exact hit and is never re-saved with the new modules.deps-audit/format/shell(a handful of repositories each) finish beforetest, and every later job then restores their entry as an exact hit and never re-saves.proxy.yml/proxy-release.ymlrun setup-bazel from the repo root, so they hashed the rootMODULE.bazeland wrote Envoy's repositories under the root key (the 1.4 GBlinux-arm64entry is theirs).Go modules are cacheable this way:
go_repositoryin module mode isreproducible = True, so Bazel 9's repo contents cache (<repository_cache>/contents) holds the fetched repo. Measured locally: a coldbazel build --nobuild //...into an empty--repository_cache, thenclean --expunge, then the same with--repo_env=GOPROXY=https://127.0.0.1:9→Build completed successfully, zerofetch_repolines. A warm cache needs no network for a known module. (This is the issue's "GOPROXY=off after the cache is warm" gate.)The fix
(1) The cache (still
bazel-contrib/[email protected]; I read itsconfig.js/index.js/post.jsat the tag: it restoreskeythen falls back to thesetup-bazel-<cache-version>-<os>-<arch>-repository-prefix, which is the restore-keys behaviour we want, and itsrepository-cacheinput takes a file list andcache-versionnamespaces the key):cache-version: root-1,repository-cache: '["MODULE.bazel", "MODULE.bazel.lock", "go.mod", "go.sum"]'.cache-version: proxy-1,repository-cache: '["proxy/MODULE.bazel", "proxy/MODULE.bazel.lock"]'. (proxy.yml'sshelljob runs in the root workspace, so it is a root job.)diffinci.yamlandmain.yaml(main.yaml's writes themainentry every PR falls back to), and the per-arch build matrix inproxy.yml/proxy-release.yml. Each saver warms all of//..., so what it saves covers every other job's fetches. Every other job hascache-save: false. Knock-on: fewer ~2 GB entries against the 10 GB repo budget (it was at 9.87 GB when I looked).(2) The retry.
scripts/ci-bazel-warmup.sh <flags> <targets>is each Bazel job's first Bazel step:bazel build --nobuild(loading + analysis, which is where fetches happen), 3 attempts, 20 s / 40 s backoff, retried only when the output shows a repository-fetch error (An error occurred during the fetch of repository,fetch_repo:,Error downloading, …). A broken BUILD file fails on attempt 1 and does not sit through the backoff. The warm-up clears--remote_executor= --remote_cache= --bes_backend=after the caller's flags, so it can take--config=cias-is (its platforms/toolchains decide which repos get fetched) without a BuildBuddy key and without creating a BuildBuddy invocation..bazelrcis untouched: no remote setting changed, RBE/test-local/DownloadBlob rules as before. No--experimental_remote_downloader(I did not verify BuildBuddy's remote asset API for this org, so it stays out).scripts/check-ci-bazel-warmup.sh(new step inci.yaml'sshelljob) runs the script against a stub bazel and checks that a fetch blip recovers on attempt 2, a fetch outage stops at exactly 3, a non-fetch failure stops at 1, and the remote endpoints are cleared after the caller's flags. It does catch regressions: withWARMUP_ATTEMPTS=1two of its cases fail.Evidence
Retry seen red (a real Bazel run, not the stub)
Cold, empty
--repository_cache, fresh output base,--repo_env=GOPROXY=https://127.0.0.1:9,WARMUP_BACKOFF_SECONDS=5, target//cni/internal/plugin:capture_netns_test(the #995 target). Exit 1:Cache restored on the second run
Run 1 (cbd96d4, run 36349170687).
root-1is a new namespace, sodiffstarts cold, fetches everything with the retrying warm-up, and saves:In the same run,
test/netns/race/integration/e2estart afterdiff, so they already restore its entry as an exact hit and do not save:Run 2 (empty commit c2a5863, run 36349842108 + proxy run 36349842212). Every job restores as an exact hit, including the jobs that were cold in run 1 because they run in parallel with
diff:No
fetch_repoline appears in any of those run-2 job logs. The root entry is ~1.0 GB, against the ~1.9 GB of the old shared, never-pruned one.Cost: warm-ups on a warm cache took 30-61s. Where the next step keeps the analysis (netns: 3.9s build after warm-up), the real step gets most of that back.
Run 2's
racewent red once on//agent/internal/spire:spire_test, which this PR does not touch:TestNodeSVIDRedeliveryCountsUnchangedfailed in run 3 of 3 (an unchanged node SVID must not push, 2 pushes instead of 1). That is a flaky test. Nothing was fetched, and the warm-up succeeded on attempt 1. I re-ran the failed job.Docs
docs/runbook.md§3, new "CI: external repository fetches (#1001)": both mechanisms, a table for reading a red job (retry absorbed / all 3 attempts failed → re-run / a fetch in a later step → re-run and extend that warm-up / a non-fetch failure → fix it), and where a plain re-run is still the answer. That coversdeps-audit'sgo list -m all, which reaches proxy.golang.org through the Go tool outside Bazel, image pulls, and a cold namespace after acache-versionbump or an eviction.Checks
actionlint: nothing new. Its only findings are the existinggithub.head_ref-in-inline-script warnings.//:format.checkran all 4 languages clean,//website:site_testpassed (the runbook feeds it), and the--config=lintshellcheck of//scripts:allpassed (the new scripts are in its glob).charts/untouched.Closes #1001
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr