telemetry/state-ingest: treat listener close as clean shutdown#3732
Merged
Conversation
9242a5e to
c3ba5de
Compare
c3ba5de to
bd4b215
Compare
On shutdown, the deferred listener Close in main races httpSrv.Shutdown, so Serve can return net.ErrClosed instead of http.ErrServerClosed and the benign shutdown was logged at ERROR level. Treat net.ErrClosed as a clean exit in both the ingest and metrics servers.
bd4b215 to
f10236b
Compare
packethog
approved these changes
May 22, 2026
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 of Changes
ERR server exited with error error="accept tcp [::]:8443: use of closed network connection"at shutdown. On SIGINT/SIGTERM the deferred listenerClose()inmainraceshttpSrv.Shutdown(), soServecan returnnet.ErrClosedinstead ofhttp.ErrServerClosed. The server now treatsnet.ErrClosedas a clean stop in both the ingest server and the metrics server.Diff Breakdown
Tiny logic change (the
net.ErrClosedguard); the bulk is reworking two tests that previously used listener-close to simulate an error.Key files (click to expand)
telemetry/state-ingest/pkg/server/server_test.go— inject a fake listener whoseAcceptreturns a real error to keep "error propagates and cancels siblings" coverage; add a test asserting listener-close is benign (cancels ctx, no error)telemetry/state-ingest/pkg/server/server.go— treatnet.ErrClosedas a clean exit inServetelemetry/state-ingest/cmd/server/main.go— same guard on the metrics serverTesting Verification
..._ListenerCloseIsBenigntest: closing the listener out from underServecancels ctx (teardown) but forwards no error...._ServeErrorPropagatesAndCancelsand..._MultiListener_OneErrorCancelsOtherto drive a genuine (non-net.ErrClosed) Accept error via a fake listener, asserting it propagates and cancels the sibling listener — coverage that the previous listener-close trigger no longer provides.go test ./telemetry/state-ingest/...passes;golangci-lintclean.