Skip to content

test(envoy-validate): validate against the chart-pinned proxy image, not stock Envoy (#709) - #716

Merged
bpalermo merged 3 commits into
mainfrom
feat/709-validate-pinned-proxy
Sep 5, 2026
Merged

bpalermo merged 3 commits into
mainfrom
feat/709-validate-pinned-proxy

Conversation

@bpalermo

@bpalermo bpalermo commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Closes #709.

Problem

//test/envoy_validate ran envoy --mode validate over aether-generated bootstraps using the stock Envoy v1.39.0 release asset (@envoy_binary_linux_{amd64,arm64}), while the deployed proxy is a custom build of a 1.40.0-dev snapshot (//proxy workspace) with most upstream extensions compiled out (_DROPPED in proxy/bazel/build_config/extensions_build_config.bzl) and aether_stats compiled in.

Stock Envoy is strictly more permissive than what we ship, so the gate could pass a config the real proxy NACKs. The two had already drifted twice — a stale 1.38.0 comment in the BUILD file, a 1.39.0 pin in MODULE.bazel, a 1.40.0-dev proxy — and the KNOWN SKEW block said so. There is no stock release asset for an Envoy main snapshot, so "re-pin the stock binary to match" cannot work while the proxy tracks main.

Mechanism

The only binary always exactly in sync with the data plane is the proxy. New module extension //bazel/proxy_pin:extensions.bzl:

  1. Reads the pin from the chart. MODULE.bazel cannot load() a .bzl, but a module extension can mctx.read(Label("//charts/aether:values.yaml"), watch = "yes"). charts/aether/values.yaml is therefore the single source of truth — proxy-release's bump-chart job already rewrites tag: + digest: there, and needs no third sed: the extension follows the chart, so there is no second pin to move.
  2. Pulls by digest, per arch. Anonymous GHCR bearer token → image index (verified against the pinned digest via sha256=) → the linux/amd64 or linux/arm64 manifest → layers walked topmost-first, each blob digest-verified, extracted until usr/local/bin/envoy appears. The result is a plain File, exports_files'd as @pinned_envoy_linux_{amd64,arm64}//:envoy.
  3. Same alias shape. //test/envoy_validate:envoy_bin still select()s on @platforms//cpu:x86_64 / aarch64, and go_test still carries data = [":envoy_bin"]. The only change in validate_test.go is the repo name it resolves through _repo_mapping and the path inside the repo (<repo>/envoy instead of <repo>/file/envoy); the runfiles/repo-mapping lookup itself is untouched.

Rejected rules_img's pull: it is a shallow pull that materializes blobs keyed by digest with no per-platform layer view, so picking "the amd64 layer that holds /usr/local/bin/envoy" would still need bespoke logic on top — and rules_oci would mean a new bazel_dep for the same. A ~200-line repository rule that produces exactly the File we want, with every blob hash-verified, is smaller than either.

Parsing contract

Deliberately strict — it fails the build naming what it expected, rather than silently validating against the wrong binary:

  • Find the first line repository: <ref> whose <ref>'s last path segment is exactly aether-proxy.
  • From the next line, scan forward while still inside that mapping (indentation ≥ the repository: key's; blank and comment-only lines do not end the block) for digest: "sha256:<64 hex>".
  • No such repository: / no digest: in its block / malformed digest → fail().

All three failure paths were exercised locally (renamed repository, deleted digest, sha256:nothex) and each produced its intended message. Editing values.yaml re-triggers the extension, confirming the watch.

Auth case: public — no credentials needed

$ curl -s "https://ghcr.io/token?scope=repository:bpalermo/aether/aether-proxy:pull"   # 68-char token
$ curl -o /dev/null -w '%{http_code}' -H "Authorization: Bearer $TOKEN" \
    https://ghcr.io/v2/bpalermo/aether/aether-proxy/manifests/sha256:9e401334...   → 200

ghcr.io/bpalermo/aether/aether-proxy is publicly readable, so no docker login ghcr.io locally and no docker/login-action@v3 step in CI — .github/workflows/ci.yaml is unchanged. Tests stay local on the runner (--strategy=TestRunner=local in .bazelrc); only the repo fetch touches the network, which already happens locally. If the package is ever made private, the _fetch_manifest failure path prints both remedies (docker login ghcr.io, or a docker/login-action@v3 step with permissions: packages: read before the bazel step in the test job).

Also removed

@envoy_binary_linux_{amd64,arm64}, the KNOWN SKEW comment block, and the stale 1.38.0 comment in test/envoy_validate/BUILD.bazel and validate_test.go. http_file is now declared next to its only remaining user (mermaid_js). No bazel_dep added, so MODULE.bazel.lock is untouched (the extension is reproducible = True, so a chart-pin bump produces no lockfile churn either).

Validation

check result
bazel test --repo_env=GOPROXY=… //test/envoy_validate/... PASS, 22.8 s wall (cold, incl. the 28 MB layer pull), test itself 0.5 s, 6/6 bootstraps
extracted binary envoy --version 51ba12979d545bcde021d81ef9151355db7c6a07/1.40.0-dev/Clean/RELEASE/BoringSSL — the chart's tag: verbatim
bazel build --repo_env=GOPROXY=… //... 359 targets, clean
make gazelle no changes
bazel mod tidy no changes
make format-check clean
bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //... clean (buildifier clean on the new .bzl)

The verbose run shows the real proxy's own log lines (external/envoy+/source/common/protobuf/...), confirming it is the custom binary and not a release asset.

No changes under proxy/; no chart changes (so no Chart.yaml bump needed).

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 3 commits September 5, 2026 18:30
…not stock Envoy (#709)

`//test/envoy_validate` ran `envoy --mode validate` with the stock Envoy
v1.39.0 release asset while the deployed proxy is a custom build of a
1.40.0-dev snapshot (`//proxy` workspace) that compiles most upstream
extensions out and `aether_stats` in. Stock Envoy is strictly more
permissive than what we ship, so the gate passed configs the real proxy
would NACK, and the two pins had already drifted twice (a stale 1.38.0
comment, a 1.39.0 pin, a 1.40.0-dev proxy).

There is no stock release asset for an Envoy `main` snapshot, so the only
binary always in sync with the data plane is the proxy itself. The new
`//bazel/proxy_pin` module extension reads `charts/aether/values.yaml`
(MODULE.bazel cannot `load()` a .bzl, but an extension can `mctx.read` a
source file), pulls the aether-proxy image by the digest the chart pins,
and lifts `/usr/local/bin/envoy` out of the topmost layer that carries it
— one repo per arch, selected by the existing `envoy_bin` alias. The chart
pin is now the single source of truth: `proxy-release`'s `bump-chart` job
needs no extra sed, and the `KNOWN SKEW` block is gone.

The parse is deliberately strict and fails the build with a message naming
what was expected rather than silently validating against the wrong binary:
a `repository:` whose last path segment is `aether-proxy`, then a
`digest: sha256:<64 hex>` inside the same mapping.

`ghcr.io/bpalermo/aether/aether-proxy` is public — an anonymous GHCR bearer
token suffices, so no `docker login` locally and no `docker/login-action`
step in CI. Tests stay local on the runner (`--strategy=TestRunner=local`).

Verified: `bazel test //test/envoy_validate/...` passes (0.5 s, 6/6
bootstraps) against `51ba1297.../1.40.0-dev/Clean/RELEASE/BoringSSL`;
`bazel build //...`, `make gazelle`, `make format-check`, `bazel mod tidy`
and `--config=lint` all clean.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 43e4882 into main Sep 5, 2026
16 checks passed
@bpalermo
bpalermo deleted the feat/709-validate-pinned-proxy branch September 5, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant