Repository navigation
fix(registrar): kubernetes backend releases an agent's write at the next sync, so every replica serves the Pod-derived endpoint (#1145) - #1152
Merged
Conversation
…ext sync, so every replica serves the Pod-derived endpoint (#1145) The kubernetes backend ignores writes, and the write-behind overlay released a flushed register only once a listing returned the agent's endpoint proto.Equal. The Pod-derived listing never reproduces the CNI path's view field for field (the health-check mode, for one), so the receiving replica served the agent's version for the pod's lifetime while every other replica served the Pod's. A backend that implements the new registry.DerivedEndpoints capability now releases an intent at the first sync whose listing started after the intent was received; a listing that may predate it still gets the overlay, so the snapshot-first apply is never regressed by a sync already in flight. The etcd backend keeps its observed-back rule (pinned by a test). Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Oct 4, 2026
Merged
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.
Fixes #1145
What was wrong
On the kubernetes registry backend (the chart default)
RegisterEndpoint/UnregisterEndpointare no-ops. The write-behind queue still "flushed" each agent intent and kept it to shield the snapshot until a sync listing reflected it. For a register,Overlayreleased the op only when the listed endpoint wasproto.Equalto the agent's.On this backend the listing is built by
podToEndpointand the agent's endpoint by the CNI registration path. Those two never agree field for field. For example, the CNI path defaults an unsethealth-check-modeto EDS and this backend defaults it to UNSPECIFIED. So the op was never released. The receiving replica served the agent's version of the endpoint for the pod's whole lifetime, and every other replica served the Pod's.collectDueOpsskips flushed ops before its max-age check, so nothing expired it either.Fix: the Pod is the single source of truth on a derived backend
registry.DerivedEndpoints. The kubernetes backend implements it: writes are ignored and every endpoint is derived at listing time.WriteBehindQueue.Overlay(state, listedAt)releases an intent at the first sync whose listing started after the intent was received. That listing is taken as it is, so every replica serves the same Pod-derived endpoint.proto.Equalis the right check there. A test pins this.Why this shape and not the alternatives
wbMaxAge(5 min)."Released by the first listing newer than the intent" is the earliest point at which the shared state is guaranteed to include what the agent reacted to. It is also never earlier than that.
Interaction with #1144 (the next PR in this stack)
The overlay was the only thing holding the agent's phase-2 UNHEALTHY on the receiving replica. With this PR alone, the receiving replica lists the Pod's view again at its next sync, which is DRAINING while the pod is still Ready.
This is harmless for routing:
The stacked PR for #1144 removes the gap: the Pod-derived view itself turns UNHEALTHY at the phase-2 moment on every replica.
Tests (red on main, green here)
//registrar/internal/serverTestReplicasAgreeOnAnEndpointAnAgentRegisteredOnOne: two replicas overbackend.New("kubernetes")and one fake API server, with a 50 ms poll. The agent registers on replica A an endpoint that differs from the pod-derived view only inHealthCheckMode(EDS, as the CNI path builds it). The test asserts both snapshots agree and equal the Pod view.Condition never satisfied: replica A still serves the agent's version of the endpoint, replica B the pod's). Green here, 15/15 runs under--config=race.TestWriteBehindEtcdBackendStillShieldsUntilObserved: on the etcd backend (backend.New("etcd")), a flushed intent stays overlaid against a listing an hour newer that still differs. It is released only when the listing returns exactly what was written. The etcd path is unchanged.TestWriteBehindDerivedBackendReleasesAtTheFirstNewerListing:TestPeerReplicaLearnsADrainWithoutWaitingForThePoll(registrar (kubernetes backend): a DRAINING mark reaches only the replica that received it — cross-replica propagation not measured #1124) still passes.Checks
bazel test --config=raceon//registrar/internal/server:all,//registrar/internal/cmd:all,//registry/...: pass.make gazelle,make format-check, andbazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: clean.Overlayneeded a helper (overlayOp) to stay under the gocognit threshold.Runbook: one paragraph in the #1124 section.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr