Repository navigation
chore(bazel): upgrade rules_distroless from 0.8.0 to 0.9.4 - #12153
Conversation
rules_distroless 0.9.0 replaced the `apt` extension's API: packages are declared in MODULE.bazel instead of a YAML manifest, and on Bazel 9 the extension resolves them against the snapshot's package indices whenever it is evaluated instead of reading a checked-in lock file. Move the package set from //bazel:resolute.yaml into `apt.sources_list` and `apt.install` calls in MODULE.bazel, and delete the manifest and the lock file, which 0.9.x doesn't read on Bazel 9 (and whose version 1 format it no longer accepts). The resolved package set is unchanged (same 165 packages, versions, sha256s and URLs), and the built package layers are byte-identical. `cacerts` now writes its files with mode 0644 instead of 0555. Since we run with --lockfile_mode=off, the extension can't cache the indices' checksums (it keeps them as MODULE.bazel.lock facts), so every new Bazel server that evaluates it downloads (~40 MB) and parses the indices again: ~30-35 s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Maintainer judgment is needed because, with lockfiles disabled, the upgrade replaces reviewed package hashes with hashes from unpinned indices and adds a snapshot.ubuntu.com availability dependency plus 30–35 seconds to fresh-server analysis.
No open issues 🎉
What changed in this PR
Upgrades rules_distroless from 0.8.0 to 0.9.4 and migrates the Ubuntu package configuration used by system-test runtime images to the new API.
Changes:
- Moves the same 22 requested packages and four snapshot channels into
MODULE.bazel. - Removes the legacy YAML manifest and package lock file, and updates related comments.
- Documents repeated index downloads with lockfiles disabled. Reported verification preserves package resolution; image differences are limited to two certificate-related file modes.
| File | Description |
|---|---|
rs/tests/BUILD.bazel |
Updates a comment to point to the package set in MODULE.bazel. |
MODULE.bazel |
Bumps the dependency, migrates the apt configuration, and documents evaluation behavior. |
bazel/resolute.yaml |
Deletes the manifest now represented in MODULE.bazel. |
bazel/resolute.lock.json |
Deletes the legacy lock file unused by the new extension on Bazel 9. |
Review effort: Balanced
The packages the `apt` extension resolves depend on the rules_distroless version (its resolver) as well as on the snapshot timestamp, and no checked-in file records them, so say what to compare when bumping either. `coreutils` and `libvirt0` are real packages, not virtual ones: rules_distroless prefers the packages that provide those names. The previous commit message gives the extension's cost on a new Bazel server as ~30-35 s. That came from two earlier runs; in later runs the evaluation took 6.5-7.8 s (15.6 s at most), adding 6-7 s to `bazel query '@resolute//...'`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Build-infrastructure owners need to explicitly accept replacing reviewed package hashes with live unsigned-index resolution while lockfiles are disabled, introducing supply-chain risk, a snapshot.ubuntu.com availability dependency, and fresh-server latency.
No open issues 🎉
Review effort: Balanced
Brings in the committed MODULE.bazel.lock (#12175), which records the apt extension's facts and generated repositories, and the other bazel_dep upgrades of this batch. No conflicts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Generated with `bazel mod deps` in the dev container. It now records the apt extension's result (the resolved package set as the `@resolute` hub's lock content, and the 165 packages' .deb URLs and sha256s) and its facts (the checksums of the snapshot's package indices), so Bazel evaluates the extension again only when its inputs change. The registry hashes move from rules_distroless 0.8.0 to 0.9.4. Of the yq extension's entry only the usages digest changes: rules_distroless uses that extension with the same calls in both versions, and its generated repositories stay the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ents The comment above the `apt.sources_list` calls still described running with `--lockfile_mode=off`. It now says that MODULE.bazel.lock records the extension's result, so Bazel evaluates it again only when one of its inputs changes, that `bazel mod deps` updates it, and what to review in its diff when bumping the snapshot or rules_distroless. The two OVMF comments get master's wording back: now that MODULE.bazel.lock records the package set, avoiding bloat in the lockfile is again the reason to download those .debs directly. With this change `bazel mod deps` leaves MODULE.bazel.lock unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Infra confirmation is needed because integrity hashes move from infra-owned /bazel/ to approval-exempt *.lock files, while CI trusts recorded index checksums and the resolver lacks Release-signature verification.
No open issues 🎉
Review effort: Balanced
…finity#12175) Commits `MODULE.bazel.lock` again (it was removed in dfinity#1990) and adds CI that keeps it current. ## Why With `--lockfile_mode=off`, every new Bazel server: - re-evaluates every module extension; - fetches registry files without checksums; - fetches `metadata.json` for every module, so an upstream yank can break the build; - refetches what the extensions look up on the network: the PyPI index for pip (dfinity#12041), go.dev for go_sdk, and for rules_distroless 0.9.x about 84 MB of apt indices (this blocks dfinity#12153). ## What changes - **The lockfile.** `MODULE.bazel.lock` (Bazel 9.3.2, lockFileVersion 28, 0.39 MB) is committed, and `common --lockfile_mode=off` is gone, so Bazel's default `update` mode applies everywhere. - **New reusable workflow `.github/workflows/bazel-lockfile.yml`.** It runs on Namespace (`namespace-profile-rbe-driver-amd64-linux-16x32`, or its `-no-cache` copy for reviewed fork code) and has two modes: - **update**, called from CI PR Only: when a PR changes an input of the lockfile, regenerate it with `bazel mod deps`. If it changed, a separate push job commits "Automatically updated MODULE.bazel.lock" onto the head branch. Fork PRs get the diff and an artifact instead. The push job is the only job that holds the bot's key, and it runs no Bazel. - **check**, called from CI Main: fail when the lockfile isn't what Bazel generates. This keeps an outdated lockfile out of the merge queue, where `ci-pr-only-status` is always green. - On PRs and merge groups that touch an input, it re-derives the module extension results, which catches bad merges. - On pushes it does a plain update. - **Generated on amd64-linux only.** Every module extension records a platform-independent (`general`) result today. A new last step of Bazel Test arm64-{linux,darwin} fails when Bazel rewrites the file on those platforms. On pushes that step only reports, so it can't block artifact uploads. - **Small adjustments.** - `bazel/workspace_status.sh` ignores `MODULE.bazel.lock` in its dirty check, so a stale lockfile on a release branch can't produce `-dirty` artifacts. - Autofix doesn't stage the file, and Lock Generate tolerates a malformed one. - The cargo jobs no longer trigger on it, and `targets.py` treats it like `MODULE.bazel`. - The buildifier pre-commit regex no longer matches it. - **Docs.** A new "MODULE.bazel.lock" section in `bazel/README.md`, and the check-bazel-files skill. ## For developers - After changing `MODULE.bazel`, `bazel/*.MODULE.bazel`, a module override patch, `.bazelversion` or `requirements.txt`, run `bazel mod deps >/dev/null` and commit the lockfile. On a PR from a branch in this repository the bot also does it. - Before pulling this change, delete any untracked `MODULE.bazel.lock` left over from earlier experiments. - Parallel `bazel_dep` bumps will often conflict in the lockfile. The recipe is in `bazel/README.md`. ## Notes for review - **CODEOWNERS is unchanged.** `MODULE.bazel.lock` falls under the `*.lock` No-Approvals rule. What CI does with each part of the file: - it re-derives the module extension results on every PR that touches an input; - registry hashes are checked against what Bazel downloads; - facts (go_sdk, pip, msvc_runtime) are used as recorded. Requiring infra approval would take a `/MODULE.bazel.lock @dfinity/infra` line after the No-Approvals block. - **Exercised in CI so far:** - This PR: the update job found nothing to push, CI Main's check passed, and the new step of Bazel Test arm64-linux and arm64-darwin passed. The darwin leg builds all of `//rs/...` and `//packages/...`. - Throwaway dfinity#12176 hand-edited a recorded extension result. The update job re-derived it, the push job committed the repaired file byte for byte, and the run for the bot's commit was green. - Pushes to `dev-gh-bazel-lockfile`: the plain check passed for this commit. For a commit with one registry hash deleted, it failed with the expected annotation and uploaded the repaired file as `bazel-lockfile-check`. - **Not exercised yet:** the fork path through CI Kickoff Manual, to be tried after merge. ## Verified locally These all produced identical bytes in the dev container: - two from-scratch generations; - a generation with CI's rc set; - the check job's strip and regeneration; - a plain update. `bazel build //... --nobuild` leaves the file unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>

Upgrades
rules_distrolessfrom 0.8.0 to 0.9.4, its latest version on the BCR. GitHub has releases up to v0.11.2 that aren't on the BCR yet. 0.9.4 doesn't fix anything we hit.0.9.0 replaced the
aptextension's API (bazel-contrib/rules_distroless#222). Packages are now declared in MODULE.bazel withapt.sources_listandapt.install(dependency_set, packages)instead of in a YAML manifest. The extension resolves them against the snapshot's package indices, andMODULE.bazel.lockrecords the result instead ofbazel/resolute.lock.json. The resolved package set doesn't change. Neither does anything built from it, except the mode of two files in the system-test runtime image. The IC-OS and publish bundles don't depend on rules_distroless. The released Rosetta images use itspasswdrule and are byte-identical.An evaluation of the extension fetches the snapshot's
Packages.xzindices (18 MB) and parses the 84 MB of text in them. That takes 4.8 s with the indices in the repository cache, and took 6.5-8 s when it downloaded them from snapshot.ubuntu.com. Without a lockfile, every new Bazel server that needed@resolutedid that again and needed snapshot.ubuntu.com to be up, which was this PR's main cost. Since #12175 committedMODULE.bazel.lock, Bazel reuses the recorded result and evaluates the extension only when its inputs change, and in CI's Bazel Lockfile jobs (see below). Since the last review, this branch merged that master, added the extension's result toMODULE.bazel.lockand updated the comments in MODULE.bazel to match. It also no longer rewords the OVMF comments.MODULE.bazel.lockbazel mod depsadds theaptextension toMODULE.bazel.lock, which grows from 0.39 MB (2,947 lines) to 0.96 MB (9,436 lines):@resolutehub, whoselock_contentholds the resolved package set (one 163 KB line), and two repositories per resolved package (165deb_import, 165deb_filemap). Eachdeb_importentry lists the package's.debURL, sha256 anddepends_on. A snapshot bump rewrites all 165 URLs, since they contain the timestamp; the entries whose name or sha256 changes show which packages changed.Packages.xz, and which variant of each index to fetch (.xzforPackages, "unavailable" forContents).resolute-securityandresolute-updateshave the same sha256 because both indices are empty in this snapshot.yqextension's entry changes only in its usages digest, which changes with rules_distroless's version: rules_distroless makes the sameyqcalls in both versions, and the generated repositories stay the same.The package list is the manifest's, unchanged. Four of the requested packages (
apt,dpkg,perlandlibvirt0) are in no image://rs/tests:PACKAGESdoesn't list them, and none of the packages it lists depends on them. 57 of the 165 resolved packages are there only for these four. 41 are there only forlibvirt0, which has been unused since #10642. Dropping them is left for a follow-up, so that the resolved set stays the same here.Bazel reuses the recorded result as long as the extension's usages (the
apttags), the.bzlfiles it loads (its own and a few ofbazel_libandbazel_tools), its recorded repository mappings and the lockfile format stay the same. So a new Bazel server evaluates no module extension and downloads nothing to load@resolute. Measured in the dev container, three runs each:bazel query '@resolute//...'bazel query //rs/tests:BUILD.bazel(doesn't load@resolute)None of these profiles evaluates a module extension. With 0.9.4 they show one lockfile check, of
aptagainstMODULE.bazel.lock. 0.8.0'saptis reproducible, so Bazel keeps its result only in the output base's hidden lockfile. With snapshot.ubuntu.com blocked (a downloader config, and no remote downloader),bazel query '@resolute//...'still succeeds. It also does in a new output base, where Bazel has no hidden lockfile to fall back on. In CI run 44369580800 (on cd02db0), the arm64-darwin job prints none of the 24404 NOT FOUNDwarnings, 24Remote Cache: NOT_FOUNDwarnings and 4Could not fetch Contents indexlines that the evaluation printed in that job before the merge.Bazel evaluates the extension again when one of those inputs changes, for example on a snapshot bump or a rules_distroless upgrade. CI's two Bazel Lockfile jobs, CI PR Only's update and CI Main's check (which also runs in the merge queue), do it on every pull request that changes an input of
MODULE.bazel.lock, even when theaptinputs don't change: they remove the recorded results first, but keep the facts. With the facts, the extension downloads only the fourPackages.xzfiles, by checksum, so the repository cache and the remote downloader can serve them; only when neither has them does it need snapshot.ubuntu.com. It also doesn't try the index variants that don't exist.I ran what those jobs do in a new output base: remove the results, then
bazel mod depswith onlybazel/conf/.bazelrc.build(without CI's Namespace cache). The shared repository cache served the four indices. It took 8.0 s and wrote the same bytes, without download warnings or DEBUG lines. The other 62 module extensions were done after 4.2 s;apttook 4.8 s and finished 3.5 s later, so it makes each of those jobs about 3.5 s slower. In CI run 44362279786,bazel mod depstook 24 s and 22 s in the two jobs. After a snapshot bump, the facts don't cover the new indices: that evaluation downloads them without checksums, tries every index variant (24 of them return 404 and print warnings), and records new facts.What remains:
Releasefiles arrives in 0.11.0 (bazel-contrib/rules_distroless#255), which isn't on the BCR.MODULE.bazel.lockfalls under the*.lockNo-Approvals rule in.github/CODEOWNERS, while the deletedbazel/resolute.lock.jsonwas owned by@dfinity/infrathrough/bazel/. CI re-derives theaptresult on every pull request that touches the lockfile. As for go_sdk and pip (see chore(bazel): commit MODULE.bazel.lock and keep it up to date in CI #12175), it uses the recorded facts, the index checksums, as they are.//rs/tests:ubuntu_test_runtime_image_srcin one creates 199 repository directories (46 MB), where 0.8.0 links 108 from the contents cache (3.8 MB). It took the same time, 6.9-7.2 s against 7.0 s; the.debdownloads come from the repository cache either way.aptentry ofMODULE.bazel.lockwhen bumping the snapshot or rules_distroless.Changes
MODULE.bazel: version bump. Theapt.install(name, lock, manifest)call becomes twoapt.sources_listcalls and oneapt.install(dependency_set = "resolute", ...). Theapt.sources_listcalls carry the old manifest's four channels:resolutemain and universe,resolute-securitymain andresolute-updatesmain, all from snapshot20260422T000000Z, amd64 only. Theapt.installcall lists the manifest's 22 packages with their comments, unchanged. New comments explain:MODULE.bazel.lockrecords them, so Bazel evaluates the extension again only when its inputs change;apt.sources_listcalls and runbazel mod deps, which replacesbazel run @resolute//:lock), and what to review in the diff ofMODULE.bazel.lockwhen bumping the snapshot or rules_distroless;@resolute//<package>/<arch>targets now exist only for the listed packages, under the provider's name when another packageProvides:a listed name.MODULE.bazel.lock: regenerated withbazel mod deps, see above.bazel/resolute.yaml,bazel/resolute.lock.json: deleted. 0.9.4 has no manifest input. It reads a lock file (through anapt.locktag) only on Bazel versions withoutmodule_ctx.facts, and it rejects the version 1 format thatbazel/resolute.lock.jsonuses.rs/tests/BUILD.bazel: the comment abovePACKAGESpointed at the manifest; it now points at theresolutepackage set in MODULE.bazel.Upstream changes that touch our setup
@resolutehub now has//<package>/<arch>targets only for the requested packages, not for all 165 resolved ones. The 18 in//rs/tests:PACKAGESare all requested packages, exceptcoreutils-from-uutils, which is what the requestedcoreutilsresolves to.coreutilsandlibvirt0are real packages, but when another packageProvides:a requested name, rules_distroless prefers that provider (apt would install the real package). Socoreutilsresolves tocoreutils-from-uutilsandlibvirt0tolibvirt0-hwe, as with 0.8.0.deb_import(chore(IDX): bump actions/upload-artifact version #222). In 0.8.0 a macro aroundhttp_archive, it is now a repository rule of its own, which doesn't mark its repositories reproducible (see above). The BUILD file it generates also declares C++ targets (so_library,cc_deb_libraryandcc_library, andcc_importfor packages with pkg-config files). It always loads@rules_cc//cc/private/rules_impl:cc_import.bzl,@rules_cc//cc:cc_library.bzland@bazel_skylib//rules/directory:directory.bzl, and itsdeb_exportrule loads@aspect_bazel_lib//lib:tar.bzl. All of them exist in our rules_cc 0.2.28, bazel_skylib 1.9.2 and aspect_bazel_lib 2.22.5. The C++ targets have no headers or libraries for any of the 108 packages we fetch, and nothing here uses them:deb_importonly lists the files of adata.tar.xz, and 107 of them shipdata.tar.zst(the other one,passwd, has no libraries or headers). The package's data layer is renamed fromlayer.tar.gztocontent.tar.gz, with the same bytes.aspect_bazel_lib2.14.0 andrules_cc0.2.8. Both are below our versions, so the module graph doesn't change otherwise.Priority: required, 0.9.x picks the provider with the highest version, where 0.8.0 fell back to a real package of that name. It also expandsArchitecture: allpackages per architecture (bazel-contrib/rules_distroless#235) and leaves foreign-architecture dependencies out (bazel-contrib/rules_distroless#241). Our package set resolves the same (see Verification).cacertsfile modes (bazel-contrib/rules_distroless#225, 0.9.0).cacertsnow writes/etc/ssl/certs/ca-certificates.crtand/usr/share/doc/ca-certificates/copyrightwith mode 0644 instead of 0555; directories stay 0755. This is the only difference in//rs/tests:ca_certificates. It is therefore also the only difference in the system-test runtime image//rs/tests:ubuntu_test_runtime_image_srcand in the httpbin image built from it.//rs/tests:colocate_uvm_config_imagecontains the runtime image's tarball and also records that file's mtime (see Verification). The bundle stays world-readable.flatten(bazel-contrib/rules_distroless#228, 0.9.1).flattennow takesrmfrombazel_lib's coreutils toolchain.//rs/tests:ubuntu_packages_taris byte-identical.Verification
All of this ran in the dev container on this branch, which has master at 195b444 merged in. 0.8.0 is that master commit, built in the same output base.
MODULE.bazel.lock:bazel mod depsgenerates it. A second run on a new server leaves it unchanged, and so doesbazel build //... --nobuild.Check MODULE.bazel.locksteps of Bazel Test arm64-linux and arm64-darwin.bazel mod graph: onlyrules_distrolesschanges. All other modules resolve to the same versions, and there are no new warnings.MODULE.bazel.lock(bazel mod show_repo @resolute) has the same 165 packages, versions, sha256s and URLs as the deleted lock file. Each of the 22 requested packages has the same dependency closure, in the same order.bazel build //... --nobuild: all 3375 targets analyze.passwd,cacerts,dpkg_status,flatten), and the 18@resolutepackages we use with their:controltargets.//rs/tests:ubuntu_test_runtime_image_src,//rs/tests:ubuntu_test_runtime.tar,//rs/tests:colocate_uvm_config_image,//rs/tests/httpbin-rs:httpbin.tar,//rs/rosetta-api/icp:rosetta_image.tarand//rs/rosetta-api/icrc1:icrc_rosetta_image.tar.//rs/tests:ubuntu_packages_tar(163 MB),:dpkg_status, the fourpasswdlayers and both Rosetta images.//rs/tests:ca_certificatesand the images and tarballs that contain it. 7 of the 142 distinct files these targets output differ:ca_certificatesdiffers only in the file modes above; the file contents are the same.//rs/tests:colocate_uvm_config_imageholds the runtime tarball and also records that file's time, becausemcopy -mkeeps the tarball's mtime, which is when Bazel wrote it.bazel query 'deps(...)'of the IC-OS bundles,//publish/binaries:bundleand//publish/canisters:bundlehas 57,438 labels. It contains norules_distrolessor@resolutelabel, and none of the targets above. The Rosetta images, whichrosetta-release.ymlpushes, are among the byte-identical builds above.shfmt-check,ruff-check,buf-check,DFINITY-capitalization-check,do-not-merge-check,buildifier-check,gazelle-checkandbuf-breaking-check. The autofixes (buildifier, shfmt, ruff and gazelle) change nothing. These andbazel build //... --nobuildran on the final MODULE.bazel. CI's Autofix job, which also runs rustfmt, passed on cd02db0.//rs/tests/...: 413 Farm variants and 39_localvariants.//rs/tests/networking:canister_http_non_replicated_test_localand//rs/tests/node:root_tests_local. Both reach//rs/tests:ca_certificatesthrough the runtime image, and both passed in CI run 44369580800 (on cd02db0)._localdependents, which are taggedlong_test; so does a PR with theCI_ALL_BAZEL_TARGETSlabel. The other 5_localdependents have tags that CI Main excludes.release-testing.ymland the nightly workflows run those ofsystem_test_largetests and of nightly- or benchmark-tagged tests. They also run twomanualones by name://rs/tests/dre:guest_os_qualification_farm_colocateand//rs/tests/nested/nns_recovery:nr_large_with_mainnet_state_farm_colocate.🤖 Generated with Claude Code