Repository navigation
ci(k8s-e2e): shard execution qualification and cut provisioning time - #2432
Merged
Merged
Conversation
The production execution job ran ~25 minutes of tests serially on one cluster after ~10 minutes of provisioning, making it the PR long pole. - Split the job into a 3-way matrix, each shard on its own Kind cluster. deploy/mecatl-execution-kind/shards.txt assigns every TestKindExecution* test (and the renewal phases) to one shard, balanced by measured main durations. run.sh selects a shard via MECATL_EXECUTION_QUAL_SHARD by skipping tests owned by other shards, so an unlisted test still runs. - shards_test.go fails when a cluster test matches no shard or more than one, or when shard ids drift from the workflow matrix. - Build the four ko images concurrently, overlapped with the container builds. - Skip both jobs on release/* PRs; drop Taskfile.yml and the untracked go.work.sum from the PR paths filter (push to main unchanged). - Correct the job timeout comment (in-flight renewal has a 10m ceiling, not 30m) and size the per-shard budget at 75 minutes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Measured on run 39389618485: with the cold Go build cache this job always starts from, concurrent ko builds compile shared packages twice and the images phase took 399-446s against 366s serial on main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 20, 2026
When setup is fast (warm Go cache), the first cluster test's EnsureTemplate can run before the quota controller has computed the chart's ResourceQuota status. The API server then rejects the ExecutionEnvironment create as Forbidden, which the client surfaces as "internal: execution provider request failed". Reproduced on a debug run (backend_failure reason=forbidden with count/executionenvironments missing from quota status); it cleared within seconds. The same failure hit unsharded run 38883705359. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous wait matched status.hard to spec.hard, but #2434's warm-cache run still hit Forbidden on the first create: the API server also requires status.used for every listed resource, and the ExecutionEnvironment count is only computed once the quota controller discovers the newly installed CRD. Wait until every spec.hard key has a matching status.hard value and a status.used entry (the same condition failure-evidence.jq reports), and log how long the wait took. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A shard previously skipped every test listed under another shard, so a test listed under two shards ran on neither. Skip only listed tests the shard does not own, so duplicates run twice instead. The partition test still rejects duplicates, missing tests, and matrix drift; the selection and preflight tests it made redundant are removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
TestKindExecutionQualification reads the agent's prompt stream to the end
and immediately calls AcquireRun on the same environment. The agent
(mecak8s) releases its own run claim only in teardownExecution after that
stream ends, so the test can win the race and get Conflict ("environment
has an active run"). Seen on unsharded run 38732150492 and twice on shard 2,
where the test now runs earlier on a fresh cluster.
Wait until the environment's status.activeRun is gone or expired (the
provider's own admission rule) before acquiring, bounded at 45s.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Give the execution shards a job-owned Go module and build cache, saved once per go.sum by shard 1 outside pull requests. The shared setup-go entry never warmed ko's -trimpath compiles and lost its save race to the sibling job. Compile the host-side templates tool and qualification test binary with ko's CGO_ENABLED=0 -trimpath configuration so they reuse ko's packages, and start the test compile right after the ko builds. Load the workload and its two derivatives, which share the Go base layers, from one archive. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
2 tasks
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.
Summary
k8s-e2e.ymlis the long pole for PR wall-clock. Theexecution provider production profile (kind)job took ~38 min: ~10–12 min of provisioning plus ~25.5 min of tests run serially against one Kind cluster. This PR cuts the workflow from 37.9 min to 17.9 min on a cold Go cache, and to about 13 min on a warm one, with the same tests. It folds in the provisioning work from #2434.Sharding
shards.txtassigns everyTestKindExecution*test to a shard, balanced by measured durations (~500s each).run.shreadsMECATL_EXECUTION_QUAL_SHARDand skips only the listed tests the shard doesn't own. An unlisted test runs on every shard, and a test listed under two shards runs on both, so nothing silently drops out.shards_test.goruns intask test. It fails if a cluster test is in no shard or in more than one, if a row names a missing test, or if the shard ids and the workflow matrix differ.shards.txt:ProductionHelmLifetimeuninstalls the release, so it must be the last cluster test in its shard. Itszz_file name guarantees that.SecurityRotationshares that release, so the two stay together.run.shrefuses sharding in handoff mode, becausee2e-live.ymlneeds the whole suite on one retained cluster.Faster provisioning (from #2434)
setup-gokey is also used by ci.yml and never matched ko's-trimpathcompiles. The execution job now restores its own~/go/pkg/mod+~/.cache/go-buildentry, keyed on Go version + go.sum. Only shard 1 saves it, only outside pull requests, and only once per go.sum. PR runs read main's entry and add nothing to the cache budget.go test -cbuild with ko'sCGO_ENABLED=0 -trimpathsettings. The test binary starts compiling right after the ko builds, so it overlaps image work.Race fixes exposed by faster setup
Both bugs predate this PR. Faster setup and the shard order made them hit more often.
EnsureTemplatecould arrive before the quota controller had computed the chart's ResourceQuota. Kubernetes then refuses the create asForbidden, and the client surfaces it as "internal: execution provider request failed". This was seen on unsharded run 38883705359 and reproduced on a debug branch. For the ExecutionEnvironment count, usage only appears after the quota controller discovers the new resource type.run.shnow waits, for at most 180s, until every key in the quota has both its limit and its usage computed. It logs how long that took (17–31s observed).TestKindExecutionQualificationread mecak8s's prompt stream to the end and then immediately calledAcquireRun. mecak8s releases its own run claim only after that stream ends, so the test could win the race and get Conflict ("environment has an active run"). This was seen on unsharded main run 38732150492 (15 Oct) and twice on shard 2. The test now waits, for at most 45s, until the environment shows no unexpired active run claim before acquiring. That's the provider's own admission rule, not a retry on Conflict.Triggers and budget
release/*PRs, which only bump version strings on a commit main has already qualified.Taskfile.yml(7 of 45 triggering PRs touched only that file) andgo.work.sum, which git doesn't track.go.mod/go.sumstay, because dependency bumps can change in-cluster behaviour. Push-to-main triggers are unchanged.Measurements
PRs see the warm numbers once a push to main has saved the job's cache entry.
Cache pressure: the repo's Actions cache is at about 10.4 GB against a 10 GB limit. Every entry belongs to an open PR, and
maincurrently has no entries. Least-recently-used eviction means the warm entry may not survive long until that eases. Saving Go caches only on pushes to main (restore-only on PRs) everywhere would fix that, as a separate PR.I also tried building the ko images in parallel. With a cold cache, the concurrent builds compile the shared packages twice and were slower, so they stay serial.
Test plan
go test ./deploy/mecatl-execution-kind/... ./deploy/execution-templates/...on Linux (golang:1.27.2 with jq). On macOS, a few existing run.sh tests fail identically on unmodified main (no GNUtimeout,/private/varpaths).e2e/k8s_execution(-tags kind_execution_e2e).actionlint .github/workflows/k8s-e2e.yml,task docs.task lint: clean apart from a pre-existing darwin-only gosec finding inenvironment/microvm, which this PR doesn't touch.160f18463.🤖 Generated with Claude Code