Repository navigation
check readiness for scheduling and fix TestActorIdentity_AfterRestore_IsOwnID_NotGolden flake - #1107
Steven Jin (Stevenjin8) wants to merge 3 commits into
Conversation
Aditya Shantanu (aditya-shantanu)
left a comment
There was a problem hiding this comment.
The direction is right (gating scheduling on ateom readiness closes a real gap), but as-is this breaks a large part of the controlapi test suite — run-tests is red on the PR.
Blocking: existing tests create worker pods that never satisfy the new gate. isWorkerEligible now requires PodReady=True, but the fake pods in cmd/ateapi/internal/controlapi/functionaltest/common_test.go (worker pod creation around line 499) and several syncer tests (TestSyncer_DeleteBoundWorker_ClearsActor, TestSyncer_OmittedFields, TestSyncer_UpdateWorker_RetryOnVersionConflict, TestSyncer_SoftDelete_ViaInformer, TestSyncer_PodRecreatedWithNewUID, ...) only set PodIP/Phase, so workers never register and dozens of tests time out with failed to wait for worker to be registered. Those helpers need the PodReady=True condition added (only the one pod in TestSyncer_Lifecycle was updated).
Minor:
- The comment at the
isWorkerEligiblecall site inreconcilestill says "No IP yet" — worth updating to cover not-Ready too. - The TCP probe on the
httpsport shows up in ateom's logs as aTLS handshake error ... EOFevery 10s (visible in the e2e job log). Fine for now, but it's another nudge toward the/readyzHTTP endpoint you mentioned in the description.
One thing I checked that is not a problem: the gate only guards worker creation/update — once the Worker row exists, a later readiness flap just makes reconcile return nil, so it won't deregister a worker with a bound actor.
The e2e-test job is also red (TestActorIdentity_AfterRestore_IsOwnID_NotGolden, SuspendActor failing to dial ateom's socket); I couldn't conclusively tie that to this change vs. a flake, but it should be green before merge either way.
Aditya Shantanu (aditya-shantanu)
left a comment
There was a problem hiding this comment.
Inline notes for the blocking test breakage (details in my earlier review).
…relay) (#1160) Fixes #675, fixes #1100, fixes #1146; addresses the CI flake in #1106. ## Why this PR Flaky tests are the single biggest drag on this repo's velocity right now: the three flakes fixed here account for the majority of red CI runs over the last 7 days (identity: 35 failures, parking: 32, relay: 9 — from the flake dashboard's cross-PR analysis of ~630 runs). Every red run costs a contributor a rebase-and-rerun cycle and costs reviewers signal. **This PR consolidates the three root-caused, in-flight fixes into one change to get CI green now and unblock the community — the goal is velocity, not authorship.** ## Credit where it's due All three fixes were root-caused and written by others; this PR adopts them onto latest main with their tests, unchanged in substance. Each commit carries a `Co-authored-by` trailer: | Commit | Original PR | Author | Root cause | |---|---|---|---| | e2e: give each probe fixture its own worker pool | #1147 | @orangeCatDeveloper | identity/egressmitm/imagevolume suites share one `workload: probe` pool label; cross-suite selection under concurrent suite processes dials workers that are not there | | atenet: never cancel an in-flight resume at the park budget | #991 | @omeryahud | the park budget doubled as the ResumeActor RPC deadline; a mid-restore cancel strands a RESUMING actor on a live worker | | atunnel: close the relay's both ends before returning | #1101 | @orangeCatDeveloper | the relay closed both ends from a `context.AfterFunc` goroutine the test never waits for | @Stevenjin8's #1107 correctly diagnosed the ateom readiness race in #1106; the control-plane readiness gap it targets remains real and open — this PR only removes the e2e-fixture contention that makes it fire constantly in CI. If maintainers prefer to land the original PRs individually instead, closing this one is completely fine — the point is that the fixes land somewhere, soon. ## Evidence the flakes are actually fixed **TestRelayIngressCancellationClosesBothSides (unit, `-race`):** - Unpatched main, `-count=3000`: **83 failures (2.8%)** — matches the 2.9% observed across 308 CI runs this week - This branch, `-count=10000`: **0 failures** **TestRequestParking (park-budget cancellation):** - The new `InFlightAttemptRunsToCompletion` and `LateRetryableErrorIsBudgetExhaustion` unit tests (from #991) encode the exact failure mode from #675 and pass under `go test -race -count=100 ./cmd/atenet/internal/router/ingress/` - The pre-fix behavior (budget cancelling the in-flight RPC) is deterministically reproduced by the old test it replaces **TestActorIdentity_AfterRestore_IsOwnID_NotGolden (probe pool isolation):** - Not reproducible outside CI (needs concurrent suite processes on a contended kind node), so verified statically: `${FIXTURE_SUFFIX}` is always `-<suite>` (internal/e2e/sandbox.go:189,201 — never empty), `probe-sized` already uses its own label, and no other manifest or selector references `workload: probe`. #1147's CI data shows all three failure signatures (missing `ateom.sock`, `runsc restore` killed, router 502/503) trace to cross-suite pool sharing; per-suite labels make the selector suite-local by construction - The definitive check is this PR's own CI plus the flake dashboard's 7-day window after merge — I will report the post-merge rates on #1106 Also run: `go build ./...`, `go vet` and the full `-race` suites of both touched packages — all green. ## What this PR deliberately does NOT fix `TestActorEgressHTTPS` (#1050, 4.6% this week, below the 5% flake threshold) has no root-caused fix yet — the 503 `upstream connect error` path needs investigation in a live cluster. #1103 (@orangeCatDeveloper) tightens the related `TestActorArbitraryPortAccess` assertion so those 503s stop passing silently; it should land after #1050's cause is fixed, or it converts hidden flakiness into visible red. ## Update (post-CI investigation) The first e2e runs failed on `TestRequestParking/ParkThenServed` (micro-VM lane). Investigation showed this is the **pre-existing dominant mode** of #675 — identical failures in main-era runs 32305728993 / 32397291519 / 32487958077 — not a regression: on micro-VM, `SuspendActor` returns before the snapshot upload completes, so the worker legitimately isn't free within the 5s park budget and the router's 503 is correct behavior. #991 fixes the *other* (mid-restore cancellation/stranding) mode. Commit d637690 makes the subtest retry while the worker is still freeing; a stranded worker still fails every attempt, so the regression stays pinned. **Additional validation:** - CI e2e-test now **passes both lanes** (run 32754691017) - Local kind cluster built from this branch: parking suite **10/10 consecutive passes**; identity + egressmitm + imagevolume run **concurrently** (the exact contention behind the identity flake) × 3 iterations — **9/9 suite passes** --------- Co-authored-by: Aditya Shantanu <[email protected]> Co-authored-by: NekoPunch <[email protected]> Co-authored-by: Omer Yahud <[email protected]>
|
/retest |
585b63a to
83a771a
Compare
56aaa69 to
9938b65
Compare
Aditya Shantanu (aditya-shantanu)
left a comment
There was a problem hiding this comment.
Re-reviewed at 9938b65. The design is now right and my main v1 concerns are addressed: a real HTTP /readyz on a dedicated port replaces the TCP probe against the TLS listener (no more handshake-error log spam), it's wired into graceful shutdown (MarkNotReady on SIGTERM), both ateom variants get it, the stale "No IP yet" comment is fixed, and the functionaltest fake pods now set PodReady. Readiness-as-ready-by-default (Readiness{} zero value) gives the intended semantics here: the probe turns 200 once the process is up and serving, which is exactly the startup window #1106's scheduling race needs closed.
But the PR doesn't build and its target package's tests fail — same class of issue as last round, relocated by the syncer migration that landed on main in the meantime:
cmd/ateapi/internal/controlapi/syncer_test.gois a resurrected pre-migration file:go vetfails withundefined: WorkerPoolSyncer(the syncer now lives incmd/atecontroller/internal/workersync/). It looks like the v1 test fixes were applied to the old path during rebase.- The tests that actually exist on main —
cmd/atecontroller/internal/workersync/syncer_test.go— were not updated, and 7 of them fail (TestSyncer_Lifecycle,_OmittedFields,_UpdateWorker_RetryOnVersionConflict,_RequeueOnMissingWorkerPool,_SoftDelete_ViaInformer,_PodRecreatedWithNewUID,_ReconcileErrorsAreClassified): their pod fixtures set only IP/Phase, so nothing is eligible under the new gate. Ran locally to confirm;serverbootandcontrollerspackages pass.
One scope note, not a blocker: the identity flake's only two post-merge (#1160) failures show a resume-side signature — the restored actor's own container readyz timing out (readyz for "probe" never returned 200 within 1m0s, actor stuck RESUMING) — which worker-registration gating doesn't obviously cover. Worth checking against #1106's race analysis whether this PR closes that path too or whether a second fix is still needed; if the latter, the issue should stay open after this merges.
Fix the two test items and I'm happy to approve — the production change itself looks correct.
| @@ -0,0 +1,1575 @@ | |||
| // Copyright 2026 Google LLC | |||
There was a problem hiding this comment.
Blocking — doesn't compile. This file is the pre-migration copy: the syncer moved to cmd/atecontroller/internal/workersync/ on main, so go vet fails here with undefined: WorkerPoolSyncer at line 56. Delete this file and move its PodReady fixture fixes into workersync/syncer_test.go, which is where the 7 currently-failing tests live.
| @@ -316,7 +316,15 @@ func (s *WorkerPoolSyncer) createOrUpdateWorker(ctx context.Context, key workerK | |||
| } | |||
|
|
|||
| func isWorkerEligible(pod *corev1.Pod) bool { | |||
There was a problem hiding this comment.
Blocking — this package's own tests weren't updated for the new gate. workersync/syncer_test.go fixtures set only PodIP/Phase, never a PodReady=True condition, so 7 tests fail locally (TestSyncer_Lifecycle, _OmittedFields, _UpdateWorker_RetryOnVersionConflict, _RequeueOnMissingWorkerPool, _SoftDelete_ViaInformer, _PodRecreatedWithNewUID, _ReconcileErrorsAreClassified). Same fix as you made in functionaltest/common_test.go — add the Ready condition wherever the fixture marks a pod Running.
|
|
||
| // StartReadinessServer runs an HTTP server exposing only /readyz. Blocks until | ||
| // http.ListenAndServe returns; designed to be `go`-launched. | ||
| func StartReadinessServer(ctx context.Context, addr string, readiness *Readiness) { |
There was a problem hiding this comment.
Nit: if ListenAndServe fails here (port taken, bad flag value), the error is logged once and the pod then just never becomes Ready — a quiet failure mode that presents as "worker never registers." Since a worker that can't serve its readiness endpoint is useless anyway, exiting non-zero (or plumbing the error to the caller like the gRPC serve path does) would make the failure loud and let the kubelet restart it.
|
Heads-up Steven Jin (@Stevenjin8): to get #1106 closed faster we've adopted this PR's approach into #1243 (your commits credited with Co-authored-by), plus the review items: the pre-migration syncer_test copy is dropped, the workersync fixtures/tests are updated for the #1203 move, and the readiness server now fails loudly. If you'd rather land this PR instead, #1243 can yield — whichever is ready first wins. |
Workers were registered as soon as their pod had an IP, which is long before ateom's gRPC server can accept a ResumeActor - the scheduling half of the ateom startup race in agent-substrate#1106. Registration now additionally requires PodReady=True, backed by a real readiness signal: ateom serves HTTP /readyz on a dedicated port (8080) once its gRPC server is up, and flips it to 503 on SIGTERM so a draining worker stops receiving work before the sandbox teardown begins. The worker Deployment probes that endpoint instead of TCP-probing the TLS port, which also removes the handshake-error log spam every probe period. Eligibility only gates registration: an already-registered worker is not deregistered by a readiness flap, so bound actors ride out probe blips; pinned by TestSyncer_ReadinessFlapDoesNotDeregister. A readiness server that cannot come up exits the process: the pod would otherwise look alive while never turning Ready and never receiving work. Takes over agent-substrate#1107; test fixtures updated for the syncer's move to cmd/atecontroller/internal/workersync (agent-substrate#1203).
|
Aditya Shantanu (@aditya-shantanu) Yeah I don't super care, Ill leaveit up to you |
Fixes #1106. Takes over #1107 (adopting @Stevenjin8's approach and commits from that PR — credit to him for the design; trailer omitted only for CLA) and incorporates the review feedback it accumulated. Workers were registered as schedulable the moment their pod had an IP — long before ateom's gRPC server was listening, which is the scheduling race in #1106 (actors dispatched to a cold ateom fail at dial time). Now: - ateom (gvisor + microvm) serves HTTP `/readyz` on a dedicated port (8080) once its gRPC listener is up, flipping to 503 on SIGTERM so draining workers stop receiving work. - The worker Deployment probes that endpoint (replaces the earlier TCP probe against the TLS port, which spammed handshake errors). - `isWorkerEligible` requires `PodReady=True` in addition to an IP. Eligibility gates **registration only** — a readiness flap never deregisters a worker with a bound actor (pinned by `TestSyncer_ReadinessFlapDoesNotDeregister`). - A readiness server that cannot come up exits the process rather than leaving a pod that looks alive but can never receive work. Beyond #1107's head: dropped the pre-migration `controlapi/syncer_test.go` copy (didn't compile after #1203 moved the syncer), fixed the `workersync` fixtures for the new gate, and added `TestSyncer_PodWithIPButNotReadyIsNotRegistered` (+ the flap test above). ## Testing - `go test ./...`: green, zero failures. - `-race -count=10` on `workersync` + `serverboot`, `-race -count=5` on `controllers`, `-race` on all of `controlapi` incl. functional tests: green. - Green under a hostile ambient env (`KUBECTL_CONTEXT`/`KO_DOCKER_REPO`/`PROJECT_ID` set to garbage). ## Scope notes - The one post-#1160 failure with a *post-restore* signature (run 32891995583: restored actor's own container `/healthz` timing out, actor stuck RESUMING) is a different layer — ateom was demonstrably serving — and is **not** claimed as fixed here. If it recurs, it deserves its own issue. (The other suspected post-merge failure, run 32911674788, turned out to be that PR's own x509 regression, not this flake.) - Mixed-version caveat: this controller pointed at pods running a pre-readyz ateom image leaves those workers unready/unregistered. The supported install flows build both from the same source, so this only matters for hand-rolled skew. - [x] Tests pass - [x] Appropriate changes to documentation are included in the PR Co-authored-by: Aditya Shantanu <[email protected]>
|
this is mostly your work. I've made sure you get the credit. |
Fixes # #1106
Add ateom readiness and require readiness to schedule actor.
Note that this readiness isn't fully correct as we start the readiness server just before the main server. The proper solution is to add a bunch of plumbing that makes the readiness server only return ready after calling
Accept. I think this will be very much good enough to fixTestActorIdentity_AfterRestore_IsOwnID_NotGolden