Skip to content

test(ci): CI fails when an image digest depends on the commit (#1378) - #1467

Merged
bpalermo merged 3 commits into
upgrade/1378-image-no-revisionfrom
upgrade/1378-digest-stability-check
Oct 8, 2026
Merged

bpalermo merged 3 commits into
upgrade/1378-image-no-revisionfrom
upgrade/1378-digest-stability-check

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Top of a three-PR stack for #1378. The two PRs below remove the two stamps that gave every image a new digest with every commit. This one keeps them from coming back.

Part of #1378

What

scripts/check-image-digest-stability.sh holds the Go images of the root workspace (every image_index target: agent, mesh-dns, proxy-supervisor, uds-csi, cni-install, registrar, controller, prober and the two e2e fixtures) to "the digest does not depend on the commit", in two lines of defence.

Out of scope: the aether-proxy image. It is built in the nested proxy/ workspace by its own release workflow and carries the aether commit on purpose (its revision label and Envoy's own version linkstamp). The chart pins it statically, so it changes only when the pin is bumped.

First, the action graph, with no build:

  1. bazel aquery over the dependencies of every index fails if any action there takes stable-status.txt or volatile-status.txt as an input (or the two headers Bazel derives from them), and names the action. Both files are asserted: nothing under an image takes either. One target is allowed, Bazel's own @bazel_tools//tools/build_defs/build_info:cc_build_info, which is in every toolchain's dependencies. The image_push targets are not dependencies of an index and stay free to read the status; they are added to the query as its control (each must appear, or the query saw no status input at all).

Then the build, twice under --stamp, each time with a workspace-status script that reports a different made-up commit:

  1. an index digest that differs between the two builds fails (it names the image);
  2. a push's per-commit tag (dev-<sha>) must name the first commit after the first build and the second after the second. This is the control: it proves the made-up status reached the build;
  3. the real bazel/workspace_status.sh must report STABLE_GIT_COMMIT = HEAD. Without a STABLE_ key that changes with the commit, a warm Bazel server keeps the previous commit's tag.

It runs as a step of the test job in ci.yaml and as make check-image-digests. The images are found with a query, not a list, so a new image is covered without an edit. The exit status of the query, the action query and the status script is read before their output is used.

//scripts:check_image_digest_stability_test runs the script against a fake bazel, twelve cases: stable digests pass; a digest that follows the commit; a tag that does not; a status that never reaches the build; an action under an image that takes a status file while both builds agree; a query or action query that fails or comes back empty; a build that writes no digest; a status script that fails or has no STABLE_GIT_COMMIT.

Why a CI step and not a Bazel test

The check has to run Bazel under two different workspace statuses. A test cannot do that: the status is one global input of a build, not something a rule or a transition can vary. So the script is a step, like the linkage guards next to it, and its logic is what the Bazel test covers.

It sits in the test job, not a job of its own, because it is cheap there by construction: nothing in an image reads the workspace status, so the first build is a cache hit on images the job's build step (or main) already built, and the second re-runs the tag expansions only. Warm, on a developer machine: 6 s for the whole script; the second build ran 21 actions, no compile and no link. If a regression makes it expensive, that is the same regression check 1 reports.

Red, then green

On the real build, each mutation applied and then reverted:

Mutation Result
the x_defs version back on mesh-dns alone exit 1: //agent/cmd/mesh-dns:image_index differs; the other nine ok
the revision label, the annotations and stamp = "force" back in the image macro exit 1: all 10 digests differ
the revision label back on the volatile GIT_COMMIT exit 1: the action query names the ExpandTemplate action of each image_manifest and image_index (20 failures)
none (this stack) exit 0, 10 of 10

The third row is the one the builds alone cannot see. Measured with that mutation and two statuses that differ only in the volatile key: the mesh-dns index digest was the same for both commits, with the first commit baked into it.

Seen red in the hermetic test, against the script before each fix: a fake query that printed one image and exited 3 ended in OK: 1 of 1, exit 0.

Cost: 4 s for the whole script warm, 14 s with a cold Bazel server, on a developer machine; the action query itself took 1 to 5 s. On the runner the step took 69 s before the action query was added.

Also clean: make format-check, the lint build with fail_on_violation (ShellCheck included), scripts/check-shell-lint.sh, //bazel/actionlint:actionlint_test.

Not verified

  • On a runner the step was timed once under --config=ci, before the action query was added: it passed in 69 s. The action query under --config=ci (remote configuration, lint aspects) has only run locally with the lint half of that configuration; this head's CI run is its first on a runner, and its cost there is not measured. The step has not been seen red on a runner, only locally and in the Bazel test.
  • A commit that reaches an image without going through the workspace status (a rule that reads the repository itself) is seen by neither line of defence.
  • The allow-listed cc_build_info target is a Bazel internal: a Bazel upgrade that renames it would turn the step red, loudly, and the script would need the new name.
  • main.yaml mirrors the linkage guards for pushes to main; this step is in ci.yaml only.

Merge order

No constraint of its own beyond the stack: it fails without the two PRs below it. For the order against the publish PR, see the PR below this one.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

@bpalermo
bpalermo added this pull request to stack #1468 October 8, 2026 20:11
Copilot AI balanced review requested due to automatic review settings October 8, 2026 20:59
@bpalermo
bpalermo force-pushed the upgrade/1378-digest-stability-check branch from 48c7f98 to f24a813 Compare October 8, 2026 20:59

Copilot AI 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.

🟡 Changes recommended

The image query can fail after partial output while the guard continues and silently omits images.

1 open finding
What changed in this PR

Adds a CI guard preventing image digests from changing solely due to commit metadata.

Changes:

  • Builds all image indexes under two synthetic commits and compares digests/tags.
  • Adds hermetic failure-path tests and CI/Make integration.
  • Documents the digest-stability requirement.
File Description
scripts/​check-image-digest-stability.sh Implements the digest guard.
scripts/​check_image_digest_stability_test.sh Tests guard behavior with fake tools.
scripts/​BUILD.bazel Registers the shell test.
Makefile Adds the local check target.
.github/​workflows/​ci.yaml Runs the guard in CI.
bazel/​workspace_status.sh Documents the stable commit requirement.
bazel/​img/​go_multi_arch_image.bzl Documents commit-independent images.
docs/​runbook.md Describes digest stability enforcement.
AGENTS.md Adds contributor verification guidance.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/check-image-digest-stability.sh Resolved

Copilot AI 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.

🟡 Changes recommended

The guard omits the nested proxy image and can silently accept a partially failed Bazel query.

2 open findings

🧠 Review effort: Balanced

Comment thread scripts/check-image-digest-stability.sh Resolved
Copilot AI balanced review requested due to automatic review settings October 8, 2026 22:01
@bpalermo
bpalermo force-pushed the upgrade/1378-digest-stability-check branch from 930d8bf to a855c35 Compare October 8, 2026 22:01

Copilot AI 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.

🟡 Changes recommended

The guard misses commit-dependent values sourced from volatile workspace status, allowing affected cold-build digests to pass.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

Comment thread scripts/check-image-digest-stability.sh Resolved
Copilot AI balanced review requested due to automatic review settings October 8, 2026 22:15

Copilot AI 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.

🔵 Needs a closer look

The digest invariant is not checked by the repository’s post-merge workflow.

0 open findings

2 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Add commit-dependent digest guard to post-merge workflow

.github/​workflows/​ci.yaml:655

This guard is only added to the PR workflow. The repository’s post-merge workflow explicitly revalidates combined PR state and mirrors every adjacent linkage guard (.github/workflows/main.yaml:3-24, 172-198), but it does not run this check. As a result, a commit-dependent digest introduced by the merged tree has no post-merge detector. Add the same guarded step to main.yaml’s test job.

🧠 Review effort: Balanced

bpalermo and others added 3 commits October 8, 2026 19:50
The charts pin every image by index digest, so a digest that moves with the
commit rolls every workload on every deploy. Two stamps did that (a version
linked into seven binaries, and the commit as an image label and annotation);
both are gone, and nothing stopped either from coming back.

`scripts/check-image-digest-stability.sh` builds every `image_index` twice
under `--stamp`, each time with a workspace-status script of its own that
reports a different made-up commit, and fails when:

1. an index digest differs between the two (it names the image);
2. a push's per-commit tag (`dev-<sha>`) does not name the first commit after
   the first build and the second after the second. This is the control: it
   proves the made-up status reached the build, so check 1 did not compare a
   thing with itself;
3. the real `bazel/workspace_status.sh` does not report
   `STABLE_GIT_COMMIT` = HEAD. With no STABLE_ key that changes with the
   commit, a warm Bazel server keeps the previous commit's tag (measured).

It is a step of the `test` job in ci.yaml and `make check-image-digests`
locally. It cannot be a Bazel test: it has to run Bazel under two workspace
statuses. Its failure paths are a Bazel test,
`//scripts:check_image_digest_stability_test`, against a fake `bazel`.

Seen red with each stamp put back, on the real build:

- the `x_defs` version back on mesh-dns alone: 1 check failed, naming
  //agent/cmd/mesh-dns:image_index, the other nine ok;
- the `revision` label, annotations and `stamp = "force"` back in the image
  macro: 10 checks failed, one per image.

Green on this stack: 10 of 10. Warm, the whole run took 6 s here: the second
build re-ran 21 actions (the tag expansions), no compile and no link.

It does not see a value taken from a volatile status key: Bazel does not
re-run an action for one, so two warm builds agree.

Part of #1378

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
… that failed (#1378)

Review of the digest check. The image list came from
`mapfile < <(bazel query … | sort)`, where the query's exit status is lost
twice, in the pipe and in the process substitution. A query that printed some
images and then failed left the script checking those and reporting success.
The query's status is now read before its output is used.

The same shape was in the read of the real workspace status
(`x="$(script | sed)"`): a failing script ended the check with the script's own
status and no line saying why. It now fails with a message.

The two builds are plain commands under `set -e`, the cquery already had its
status checked, and a digest that was not written is caught by the digest's
shape; none of those changed.

`//scripts:check_image_digest_stability_test` has both cases. Seen red against
the previous script: a fake query that printed one image and exited 3 ended in
"OK: 1 of 1 image digests", exit 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…s key in an image is caught too (#1378)

Review of the digest check, two points.

Scope. The script, its messages and the comments around it said "every image
this repository builds". It checks the `image_index` targets of the root
workspace, the Go images. The aether-proxy image is built in the nested proxy/
workspace by its own workflow and carries the commit on purpose; it is named as
out of scope.

The volatile blind spot. Bazel does not re-run an action when only a volatile
status key changed, so the two warm builds agree on an image that embeds one.
Measured with the revision label put back on the volatile `GIT_COMMIT` and two
statuses that differ only in that key: the mesh-dns index digest was the same
for both commits (sha256:2b900348…) with the first commit baked in.

The check now has a first line of defence that does not depend on a rebuild:
`bazel aquery` for actions with `stable-status.txt` or `volatile-status.txt`
(or the two headers Bazel derives from them) among their inputs, over the
dependencies of every image index. Any hit fails and names the action. Both
files are asserted: after the image change nothing under an image takes
either. One target is allowed, Bazel's own
`@bazel_tools//tools/build_defs/build_info:cc_build_info`, which is in every
toolchain's dependencies. The `image_push` targets are not dependencies of an
index; they are added to the query as its control, because each must read the
status, and are the only other targets allowed to.

Seen red on the real build with that mutation: twenty failures naming the
ExpandTemplate action of each `image_manifest` and `image_index`. The hermetic
test has three new cases (an action under an image that takes a status file
while both builds agree; an action query that fails; one that reports no
push); twelve in all.

Cost: the whole script took 4 s warm and 14 s with a cold Bazel server here;
the aquery itself 1 to 5 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 8, 2026 22:51
@bpalermo
bpalermo force-pushed the upgrade/1378-digest-stability-check branch from eb041e7 to 6df1399 Compare October 8, 2026 22:51

Copilot AI 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.

🟢 Approval recommended

The guard fails closed and its key success and failure paths are comprehensively tested.

0 open findings

🧠 Review effort: Balanced

@bpalermo
bpalermo merged commit 0afa2c1 into main Oct 8, 2026
31 checks passed
@bpalermo
bpalermo deleted the upgrade/1378-digest-stability-check branch October 8, 2026 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants