Repository navigation
fix(shutdown-manager): deliver the shutdown ready response after a long drain - #10186
Closed
sharad-baid-mrsool wants to merge 2 commits into
Closed
sharad-baid-mrsool wants to merge 2 commits into
sharad-baid-mrsool wants to merge 2 commits into
Conversation
…ng drain The Envoy container's preStop hook is an httpGet on /shutdown/ready, which blocks until the drain writes the ready file. The shutdown manager server has a 10s WriteTimeout, so for any drain longer than that the response can no longer be written: the kubelet sees the connection close without a response and reports FailedPreStopHook on every pod termination, even though the drain completed normally. Extend the write deadline for the shutdown ready response only, to the ready timeout plus a small margin. Other endpoints keep the 10s server timeout. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: sharad-baid-mrsool <[email protected]>
✅ Deploy Preview for cerulean-figolla-1f9435 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: sharad-baid-mrsool <[email protected]>
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.
What this PR does / why we need it:
The Envoy container's preStop hook is
httpGet /shutdown/ready :19002. The handler blocks until the shutdown-manager's own preStop (envoy-gateway envoy shutdown) finishes the drain and writes/tmp/shutdown-ready, which with the default--ready-timeoutcan take minutes. But the shutdown manager'shttp.ServerhasWriteTimeout: 10s. The deadline is set when the request is read, so for any drain longer than 10s the handler's response (200 on readiness, 500 on timeout) can't be written. The connection closes with no response, and the kubelet logsFailedPreStopHookfor every proxy pod termination.The drain itself works. The hook stays blocked for the whole drain, and SIGTERM still reaches Envoy once the ready file exists. So the effect is a misleading event, not lost connections. It is still costly in practice: during an incident it reads exactly like a failed drain. We saw this on every termination with
drainTimeout: 300sand long-lived WebSocket connections, on v1.8.4.This change:
/shutdown/readyresponse only, usinghttp.ResponseController.SetWriteDeadline, toreadyTimeout + 5s. The margin covers the final 1s poll interval and the write./healthzkeeps the 10s server timeout.newShutdownManagerServerso it can be tested, and makes the write timeout a package variable so the test can shorten it.TestShutdownReadyResponseOutlivesWriteTimeout. It runs the real server with a 100ms write timeout and checks that both the 200 (drain completes) and 500 (ready timeout exceeded) responses are delivered. Without the fix both cases fail withEOF, which is what the kubelet reports as the failed hook.This is the same problem as the closed, never-reviewed draft #10074. That draft raised the server-wide
WriteTimeout; this PR scopes the change to the one blocking endpoint.Which issue(s) this PR fixes:
No existing issue; same problem as #10074.
PR Checklist
git commit -s).go test ./internal/cmd/envoy/andgolangci-lint(repo config) pass on the changed package locally; full CI pending.TestShutdownReadyResponseOutlivesWriteTimeout.release-notes/current/bug_fixes/.🤖 Generated with Claude Code