Repository navigation
[serve] Deflake test_metrics_3 - routable URL and a retry for dropped requests - #66529
Merged
abrarsheikh merged 2 commits intoOct 6, 2026
Merged
Conversation
test_batching_metrics was the one site in the file still hardcoding http://localhost:8000/batch while every other request builds its URL with get_application_url. The literal assumes the proxy is on port 8000 and that the route is live the moment serve.run returns, but serve.run waits for the application to report RUNNING and routes reach the proxy separately over long poll, so a request can arrive before the route exists. get_application_url reads the port and route prefix from the controller and raises until the app is really routable, which closes that race by construction. Called once and reused for the burst, since each call costs a get_serve_details round trip. Co-Authored-By: Claude <[email protected]> Signed-off-by: john.taylor <[email protected]>
HAProxy reloads on every replica change, and its soft stop closes connections that are idle at that instant. httpx does not retry a request whose connection died, so on the HAProxy shard any un-retried request in this file can fail the test outright. The same mechanism was measured on test_deploy_app_2, where disabling keep-alive made it worse rather than better: a fresh connection is idle between accept and the request bytes, which is exactly the window the soft stop closes. Retrying once covers both cases. Mirrors the helper added there, made method-generic because this file also sends a POST burst and a GET carrying a body. config_updated is left alone, since the wait_for_condition around it already retries. The GET that injects a health check failure is included even though nothing asserts on it: if a reload drops that one, the test does not fail there, it times out later waiting for the failure count to rise. Co-Authored-By: Claude <[email protected]> Signed-off-by: john.taylor <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a helper function _request_retrying_dropped_connection to handle httpx.RemoteProtocolError during HAProxy reloads in tests, improving test stability. It replaces direct httpx calls with this helper across several test cases. The reviewer suggested enhancing the retry logic with a loop, exponential backoff, and broader exception handling to further improve robustness.
abrarsheikh
approved these changes
Oct 6, 2026
nadongjun
pushed a commit
to nadongjun/ray
that referenced
this pull request
Oct 6, 2026
… requests (ray-project#66529) `test_batching_metrics` was the one site still hardcoding `http://localhost:8000/batch`. That assumes the proxy is on 8000 and that the route is live when `serve.run` returns, but `serve.run` waits for the app to report RUNNING while routes reach the proxy separately over long poll. `get_application_url` reads the port and prefix from the controller and raises until the app is really routable, so the race cannot happen. HAProxy reloads on every replica change and its soft stop closes connections idle at that instant; httpx does not retry those. Second commit adds the retry helper from ray-project#66492, made method-generic since this file also sends a POST burst and a GET with a body. `config_updated` is left alone because its `wait_for_condition` already retries. Validated under load, 2 stressors: 15/15 green per run, runtimes unchanged. --------- Signed-off-by: john.taylor <[email protected]> Co-authored-by: Claude <[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.
test_batching_metricswas the one site still hardcodinghttp://localhost:8000/batch.That assumes the proxy is on 8000 and that the route is live when
serve.runreturns, butserve.runwaits for the app to report RUNNING while routes reach the proxy separately overlong poll.
get_application_urlreads the port and prefix from the controller and raisesuntil the app is really routable, so the race cannot happen.
HAProxy reloads on every replica change and its soft stop closes connections idle at that
instant; httpx does not retry those. Second commit adds the retry helper from #66492, made
method-generic since this file also sends a POST burst and a GET with a body.
config_updatedis left alone because its
wait_for_conditionalready retries.Validated under load, 2 stressors: 15/15 green per run, runtimes unchanged.