fix(ci): isolate cel-go celmatcher patch from the shared module cache - #1326
Merged
Merged
Conversation
The toolchain image's caddy-inline stage patched Caddy v2.11.4's
modules/caddyhttp/celmatcher.go directly in the BuildKit module cache
(${GOMODCACHE}) to swap []interpreter.Interpretable -> InterpretableV2
for the pinned cel-go v0.29.2 (GHSA-gcjh-h69q-9w9g).
BuildKit builds linux/amd64 + linux/arm64 concurrently over a shared
`--mount=type=cache,target=/go/pkg/mod`. When amd64 reached Stage 3 and
sed-patched the shared celmatcher.go while arm64 was still in xcaddy
Stage 1 compiling Caddy against its native cel-go v0.28.1, arm64's build
broke with `undefined: interpreter.InterpretableV2` (celmatcher.go:506,
:529). Latent on both main and development; it started firing on
development because coraza-caddy 2.6.1 enlarged arm64's Stage 1 graph
enough for amd64 to race ahead.
Fix: apply the celmatcher.go patch to a local copy of the Caddy module
plus `go mod edit -replace github.com/caddyserver/caddy/v2@vX=/tmp/caddy-patched`,
mirroring the existing caddy-crowdsec-bouncer / go-cs-bouncer pattern in
the same stage. The shared module cache is never mutated, so the patch is
order-independent and arch-isolated (/tmp is per-arch). The now-obsolete
Stage 1 _CELM_RESTORE reverse-patch is removed; the bouncer IPEquals
restore is guarded so steady-state builds never write the shared cache
there either. Determinism (SOURCE_DATE_EPOCH + rewrite-timestamp + the
-trimpath'd build) is unaffected.
Claude-Session: https://claude.ai/code/session_01Jz4LgwfkxaF8E7TdAgk94y
Contributor
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
✅ Supply Chain Verification Results✅ PASSED 📦 SBOM Summary
🔍 Vulnerability Scan
📎 Artifacts
Generated by Supply Chain Verification workflow • View Details |
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.
Problem
development's toolchain image build (toolchain-image.yml→caddy-inlinestage) fails on linux/arm64 with:Evidence: run
34352152425, job102467808367.main's equivalent build passes.Root cause
The
caddy-inlinestage patched Caddy v2.11.4'smodules/caddyhttp/celmatcher.godirectly in the shared BuildKit module cache (${GOMODCACHE}), swapping[]interpreter.Interpretable{reqAttr}→[]interpreter.InterpretableV2{reqAttr}for the pinned cel-go v0.29.2 (GHSA-gcjh-h69q-9w9g).BuildKit builds
linux/amd64+linux/arm64concurrently over a shared--mount=type=cache,target=/go/pkg/mod. amd64 reaches Stage 3,go get cel-go@v0.29.2, and seds the sharedcelmatcher.goto theInterpretableV2form while arm64 is still in xcaddy Stage 1 compiling Caddy against its native cel-go v0.28.1 →undefined: interpreter.InterpretableV2.Latent on both
mainanddevelopment. It only fires ondevelopmentbecausef4a56896 chore(deps): bump coraza-caddy to 2.6.1enlarges arm64's Stage 1 module graph enough for amd64 to race ahead of it.mainstill carries coraza-caddy 2.6.0 (smaller graph, arches stay ~lockstep).Fix — approach 1 (local copy +
go mod edit -replace)Chosen because it removes the shared-cache mutation entirely rather than papering over the timing, and it mirrors a pattern already proven in this same stage:
cp -r ${GOMODCACHE}/github.com/caddyserver/caddy/v2@vX/. /tmp/caddy-patched), followed bygo mod edit -replace github.com/caddyserver/caddy/v2@vX=/tmp/caddy-patchedin$BUILDDIR— the identical mechanism the stage already uses forcaddy-crowdsec-bouncerandgo-cs-bouncer./tmpis per-arch; the cache is read-only).go build .honours a filesystemreplaceof the xcaddy build-target module: it is a direct import of the generatedmain.go, at the same version, with a byte-identicalgo.mod(only a.gofile is edited) — structurally the same as the bouncer replaces that already pass onmain. Nogo mod tidyafter the replace (same as the bouncer block)._CELM_RESTOREreverse-patch is removed (nothing forward-patches the cache any more).IPEqualscache-restore is guarded on the stale form actually being present, so steady-state builds don't write the shared cache there either (defensive cleanup for a pre-2026-09 cache only).Determinism preserved:
SOURCE_DATE_EPOCH+rewrite-timestampstabilise the shippedtoolchain-runtimeimage (binaries only); the finalgo buildis-trimpath, so/tmp/caddy-patchednever leaks into the binary or its build info.Scope check
caddy-inline— fixed (only stage that mutatedcelmatcher.go/ the shared cache).crowdsec-inline— shares/go/pkg/modbut only reads/downloads; it builds the CrowdSec binaries (no Caddy, nocelmatcher.go, no in-place cachesed). Itscrowdsecurity/coraza/v3graph has no cel-go/celmatcher exposure. No change needed.Validation
docker build --checkclean;hadolintclean (no new findings);tools/dockerfile_check.shpass;scripts/toolchain-key.shruns and yields a stable key. Pre-commit (dockerfile-check,semgrep) green.toolchain-image.yml'spull_requestrun on this PR must build bothlinux/amd64andlinux/arm64againstdevelopment's recipe, and the shipped/usr/bin/caddymust still assert cel-go v0.29.x + grpc-go v${GRPC_VERSION}.Toolchain key / pin
This edits the
caddy-inlinestage body, so the toolchain key moves (expected). NoCHARON_TOOLCHAIN_TAG/DIGESTbump in this PR — once merged, the (now-fixed) daily bot / aworkflow_dispatchpublishes the image for the new key and opens the pin-bump PR againstdevelopment.Also needs to land on
mainmaincarries the same latent race (it just hasn't fired because its module graph keeps the two arches in lockstep). This fix is generic and will flow tomainon the nextdevelopment → mainpromotion — no separatemainPR required, but the promotion should not be skipped.Unblocks PR #1322 (GHSA-3gc6-295r-xm5m propagation into
development).https://claude.ai/code/session_01Jz4LgwfkxaF8E7TdAgk94y