Skip to content

telemetry/state-ingest: treat listener close as clean shutdown#3732

Merged
snormore merged 1 commit into
mainfrom
snor/state-ingest-shutdown-error
May 22, 2026
Merged

telemetry/state-ingest: treat listener close as clean shutdown#3732
snormore merged 1 commit into
mainfrom
snor/state-ingest-shutdown-error

Conversation

@snormore
Copy link
Copy Markdown
Contributor

Summary of Changes

  • Stop logging the spurious ERR server exited with error error="accept tcp [::]:8443: use of closed network connection" at shutdown. On SIGINT/SIGTERM the deferred listener Close() in main races httpSrv.Shutdown(), so Serve can return net.ErrClosed instead of http.ErrServerClosed. The server now treats net.ErrClosed as a clean stop in both the ingest server and the metrics server.
  • Behavior is otherwise unchanged: a genuine, unexpected serve error still propagates to the error channel and triggers teardown.

Diff Breakdown

Category Files Lines (+/-) Net
Tests 1 +51 / -35 +16
Core logic 2 +5 / -2 +3
Docs 1 +1 / -0 +1
Total 4 +57 / -37 +20

Tiny logic change (the net.ErrClosed guard); 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 whose Accept returns 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 — treat net.ErrClosed as a clean exit in Serve
  • telemetry/state-ingest/cmd/server/main.go — same guard on the metrics server

Testing Verification

  • New ..._ListenerCloseIsBenign test: closing the listener out from under Serve cancels ctx (teardown) but forwards no error.
  • Reworked ..._ServeErrorPropagatesAndCancels and ..._MultiListener_OneErrorCancelsOther to 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-lint clean.

@snormore snormore force-pushed the snor/state-ingest-shutdown-error branch from 9242a5e to c3ba5de Compare May 20, 2026 12:20
@snormore snormore enabled auto-merge (squash) May 20, 2026 12:21
@snormore snormore force-pushed the snor/state-ingest-shutdown-error branch from c3ba5de to bd4b215 Compare May 20, 2026 13:29
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.
@snormore snormore force-pushed the snor/state-ingest-shutdown-error branch from bd4b215 to f10236b Compare May 22, 2026 14:22
@snormore snormore merged commit df9fff4 into main May 22, 2026
33 checks passed
@snormore snormore deleted the snor/state-ingest-shutdown-error branch May 22, 2026 14:36
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.

2 participants