Drain guest responses before scale-to-zero - #369
Draft
tnsardesai wants to merge 1 commit into
Draft
Conversation
tnsardesai
force-pushed
the
hypeship/guest-drain-hold
branch
2 times, most recently
from
September 6, 2026 03:37
831acb0 to
16df82d
Compare
tnsardesai
force-pushed
the
hypeship/guest-drain-hold
branch
from
September 6, 2026 16:29
16df82d to
b9e0e87
Compare
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.
problem
An HTTP handler can return while response bytes remain unacknowledged in the guest TCP send queue. Re-enabling scale-to-zero at that point can suspend the guest before the peer receives the response tail.
change
This implements the fix entirely inside the guest image. It requires no caller or control-plane protocol changes.
TIOCOUTQafter net/http finalizes explicit response framingshutdown(SHUT_WR), closing the Go connection promptly, and retaining the hold until TCP acknowledges the closeSO_LINGER=0; retry abort failures with backoff while scale-to-zero remains heldTCP_USER_TIMEOUTas bounded recovery if close monitoring and abort setup both failhttp.ErrAbortHandler, preventing net/http from synthesizing a successful response for an operation that never ranThe release invariant is: response data and required close framing were acknowledged outside the guest, or the connection was abortively terminated. A timeout, inspection failure, or cleanup failure alone never releases the hold.
tests
go build ./...go vet ./...go test -race ./lib/scaletozero ./lib/metrics ./cmd/api/apigo test -race $(go list ./... | grep -v '/e2e$')CloseNowdeadlines