Skip to content

fix(agent): remaining concurrency-audit findings (R2, R4–R8) - #110

Merged
bpalermo merged 1 commit into
mainfrom
fix/concurrency-audit-remaining
Jun 10, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/concurrency-audit-remaining

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Summary

Implements the rest of the concurrency audit (docs/proposals/002, #108); complements #109 (R1+R3).

# Fix
R2 (HIGH, data race) RemoveEndpoint now builds a new load assignment instead of mutating the proto aliased into already-set snapshots (xDS goroutines marshal those without clusterMu). LocalityLbEndpoints values are immutable post-creation, so sharing them across assignments is safe.
R4 (MEDIUM) New lifecycleMu serializes RemovePod (unregister → storage delete) against the liveness loop, which now re-checks storage under the lock before re-registering — a deleted pod's endpoint can no longer be resurrected in the registry.
R5 (LOW) SubscribePod/UnsubscribePod gate on the started channel (whose close happens-after the client/ctx assignments) instead of a racy nil-check.
R6 (LOW) The SVID resubscriber re-checks storage after subscribing and undoes the subscription if the pod's CNI DEL ran in between (was a lifetime leak).
R7 (LOW) The supervisor defers hot-restart triggers while the current epoch is not admin-LIVE (forking against an initializing epoch is a fatal Envoy exit → container restart). Debounce re-arms until LIVE; skipped when no admin address is configured.
R8 (LOW) Best-effort flock around the epoch state-file read-check-write (brief epoch regression during surge overlap).

Tests

  • TestRemoveEndpointDoesNotMutateAliasedLoadAssignment (R2)
  • TestReconcileLivenessSkipsRemovedPod — both the removed-pod skip and the healthy→unhealthy re-register path (R4)
  • TestSubscribePodNoopBeforeStart (R5)
  • TestHotRestartDeferredWhileEpochNotLive (R7)
  • All affected packages pass, including with --@rules_go//go/config:race ✅

Note

R7 touches the supervisor's restart path; recommend the usual talos re-pin + a surge-roll sanity check after merge (happy to run it).

🤖 Generated with Claude Code

From docs/proposals/002:

R2: RemoveEndpoint builds a NEW load assignment instead of mutating the proto
aliased into snapshots already set on go-control-plane (data race with xDS
marshaling goroutines).

R4: a lifecycleMu serializes RemovePod's unregister+storage-delete against the
liveness loop's health re-registrations, and liveness re-checks storage under
the lock before registering — closing the window where a deleted pod's
endpoint was resurrected in the registry permanently.

R5: SubscribePod/UnsubscribePod gate on the started channel instead of a bare
b.client nil-check; close(started) happens-after the client/ctx assignments,
so the gate also synchronizes their reads.

R6: the SVID resubscriber re-checks storage after subscribing and unsubscribes
if the pod's CNI DEL ran in between (the subscription would otherwise leak for
the agent's lifetime).

R7: the supervisor defers a hot-restart trigger while the current epoch is not
yet admin-LIVE (forking N+1 against an initializing N exits Envoy fatally and
restarts the container); the debounce re-arms until LIVE.

R8: best-effort flock around the epoch state-file read-check-write so a
draining pod's heartbeat and a successor's first write cannot interleave into
a brief epoch regression.

Regression tests for R2/R4/R5/R7; all affected packages pass with -race.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@bpalermo
bpalermo merged commit 0449054 into main Jun 10, 2026
10 checks passed
@bpalermo
bpalermo deleted the fix/concurrency-audit-remaining branch June 10, 2026 11:48
bpalermo added a commit that referenced this pull request Jun 10, 2026
…#120)

- docs/workload-requirements.md: how a workload joins the mesh (SA-derived
  service name, managed label, annotations), the outbound listener calling
  convention, the two workload-side settings required for hitless rolls
  (minReadySeconds, native preStop sleep) with the validated termination
  sequence, and the exact retry semantics clients get for free.
- 002 audit doc: status header was stale ("no fixes applied"); all findings
  landed in #109/#110/#111.

Co-authored-by: Claude Opus 4.8 <[email protected]>
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.

1 participant