Repository navigation
fix(agent): treat a registrar drain GOAWAY as a handoff, not a watch failure (#718) - #720
Merged
Merged
Conversation
…failure (#718) On every registrar Deployment roll the draining replica sends a graceful HTTP/2 GOAWAY (NO_ERROR) and the agent's watch stream dies with rpc error: code = Unavailable desc = closing transport due to: connection error: desc = "error reading from server: EOF", received prior goaway: code: NO_ERROR, debug data: "graceful_stop" The agent reconnects to the surviving replica immediately, so this is a handoff, not a failure — but it was the only ERROR an agent emitted in a healthy deploy (after #712 quieted the startup case), tripping every "zero ERROR lines" gate. Classify it: status code Unavailable plus the `received prior goaway: code: NO_ERROR` detail grpc-go renders into the status message (the code is exposed nowhere structurally; internal/transport is not importable). That case now logs INFO "watch stream closed by server drain; reconnecting" with server_drain=true and the same error attr, counts no watch_errors, and reconnects with no backoff. Every other established-stream loss keeps the failure path, which the established path never had: ERROR, watch_errors, and the jittered backoff, now shared with the stream-open path via failStream. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
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 #718.
The line that had to be explained away
On every registrar Deployment roll (helm rev199/200/201 on 2026-09-05) one or two agents logged, at ERROR:
The draining registrar sent a graceful GOAWAY, the agent reconnected to the surviving replica immediately, nothing was lost. But after #712 quieted the startup case this was the only ERROR an agent emits in a healthy deploy, so it tripped every "zero ERROR lines" gate (deploy validation, the pressure harness's informational list, soak grading).
Classification rule
isServerDrainGoaway(err)is true when both:status.Code(err) == codes.Unavailable, andreceived prior goaway: code: NO_ERROR.grpc-go exposes the GOAWAY code nowhere structurally — the status carries no
Details, andgoogle.golang.org/grpc/internal/transportis not importable — so the substring match on the rendered message is the discriminator. It comes frominternal/transport/http2_client.go:grpc-go's own
test/goaway_test.goasserts against the same literal, and the unit test here pins it against real grpc-go output rather than a hand-written string. The exact status the test observed from a realGracefulStop()on grpc-go v1.83.0:What changes
For a server drain the agent now logs, at INFO:
{"level":"INFO","logger":"registrar-registry","msg":"watch stream closed by server drain; reconnecting","server_drain":true,"error":"rpc error: code = Unavailable desc = closing transport due to: connection error: desc = \"error reading from server: EOF\", received prior goaway: code: NO_ERROR, debug data: \"graceful_stop\""}— no
watch_errors, no backoff; it re-dials the survivor straight away.What still logs ERROR
Everything that is a real failure.
handleStreamErrornow returns the error to fail on (nil for every expected end), and the loop runs the failure path on it:Stop()without GOAWAY) — ERRORwatch stream disconnected, retrying+watch_errors+ jittered backoff;failed to start watch stream, retrying(agent: first registrar watch-stream attempt logs ERROR 'context canceled' on a clean startup, then retries fine #700/fix(agent): stop logging the startup watch-stream handoff as an ERROR (#700) #712);NO_ERROR, or any non-Unavailablestatus.Still quiet, as before:
io.EOF, the parent-context-cancelled shutdown, a local filter re-assert (Canceled), and aDataLossforced resync.Two behaviour notes:
failStreamwith the open path, so a genuinely failing established stream is counted and paced (~1s + jitter) instead of spinning., retrying(watch stream disconnected→watch stream disconnected, retrying), matching the open-path wording. Nothing in the repo, charts or dashboards greps the old string.Validation
registry/internal/registrar/watch_drain_test.go, reusing fix(agent): stop logging the startup watch-stream handoff as an ERROR (#700) #712's bufconn + locked-JSON-slog harness. Two in-process registrars behind a swappable dial target (the Service VIP): the client streams from replica 1, replica 2 comes up, then replica 1 is drained (GracefulStop()in a goroutine writes the GOAWAY;Stop()then tears the transport down with the stream open — that is what turns the GOAWAY into the client-sideUnavailablestatus). Asserts zero"level":"ERROR"records, one INFO carryingserver_drain=trueand the real grpc-go error string,aether.agent.registry.watch_errorsnever recorded, and that the client reconnects and applies the survivor's snapshot.TestWatchLoop_NonGoawayDisconnectStillErrorsis the negative half:Stop()with no GOAWAY still yields the ERROR line (with abackoffattr, and no GOAWAY detail in the error) and incrementswatch_errors.isServerDrainGoawayto return false reproducesShould not be: "ERROR" … a registrar drain must not log at ERROR.bazel test --test_arg=-test.short //registry/... //agent/...— 39/39 pass;make gazelle,make format-check, and the gocognit lint aspect with--@aspect_rules_lint//lint:fail_on_violationclean.No chart change.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr