feat(registry): Make graceful shutdown test robust#4720
Merged
Conversation
The `TestGracefulShutdown` test was failing intermittently, especially with stricter HTTP handling in newer Go versions (e.g., 1.25). This was caused by sending an incomplete HTTP request in two separate writes, creating a race condition where the server could shut down before receiving the full request. This commit fixes the test's flakiness by sending a single, complete, and valid HTTP/1.1 request before triggering the shutdown. This ensures the test accurately verifies the intended behavior: that a valid, in-flight request is fully processed while new connections are rejected. Fixes:distribution#4696 Signed-off-by: Sumedh Vats <sumedhvats2004@gmail.com>
milosgajdos
approved these changes
Oct 19, 2025
joaodrp
approved these changes
Oct 19, 2025
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.
Description
Fixes the
TestGracefulShutdowntest that has been failing with Go 1.25.Closes #4696
Problem
The test was failing with
unexpected EOFwhen run with Go 1.25. The root cause was that the test attempted to send an incomplete HTTP request by splitting the request line into two separate writes:This approach has several issues:
Invalid HTTP protocol: The request line
"GET /v2/ "is incomplete - it's missing the required HTTP version and CRLF terminator. A valid HTTP/1.1 request line must follow the format:METHOD SP REQUEST-URI SP HTTP-VERSION CRLFUndefined behavior: The server cannot distinguish between:
Go 1.25 stricter behavior: Go 1.25 improved graceful shutdown to immediately close connections with incomplete or invalid requests, rather than waiting indefinitely for them to complete.
Solution
Updated the test to send a complete, valid HTTP/1.1 request before triggering graceful shutdown:
This properly tests graceful shutdown behavior:
Changes Made
defer conn.Close()for proper resource cleanupdefer conn2.Close()when second connection test failserrchan := make(chan error, 1))