Skip to content

[serve] Deflake test_metrics_3 - routable URL and a retry for dropped requests - #66529

Merged
abrarsheikh merged 2 commits into
ray-project:masterfrom
johntaylor-cell:serve-metrics3-batching
Oct 6, 2026
Merged

abrarsheikh merged 2 commits into
ray-project:masterfrom
johntaylor-cell:serve-metrics3-batching

Conversation

@johntaylor-cell

Copy link
Copy Markdown
Contributor

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 #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.

johntaylor-cell and others added 2 commits September 28, 2026 13:37
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]>
@johntaylor-cell
johntaylor-cell requested a review from a team as a code owner September 28, 2026 13:49
@johntaylor-cell johntaylor-cell self-assigned this Sep 28, 2026
@johntaylor-cell johntaylor-cell added go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue labels Sep 28, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
abrarsheikh merged commit a87e828 into ray-project:master Oct 6, 2026
6 checks passed
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants