Skip to content

[serve] Deflake test_deploy_app_2 - wait budgets, a longer ingress drain for the traffic tests, and a Windows timeout - #66492

Merged
abrarsheikh merged 3 commits into
ray-project:masterfrom
johntaylor-cell:serve-deploy-app2-deflake
Oct 19, 2026
Merged

abrarsheikh merged 3 commits into
ray-project:masterfrom
johntaylor-cell:serve-deploy-app2-deflake

Conversation

@johntaylor-cell

@johntaylor-cell johntaylor-cell commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

test_deploy_app_2 flakes on the HAProxy shard (5 of its last 16 commits) and runs within about 100s of its Windows timeout.

  • Wait budgets: 19 waits over fresh deploys and multi-replica starts move off the bare 10s default, to 20s or to the 60s their sibling tests use. Nothing is shortened.
  • Ingress drain: the shard's 0.01s drain closes a stopping replica's connections before HAProxy's reload stops routing to it. The two traffic tests now give their ingress replicas 5s, as test_deploy_app_3 does. Over 30 rolling updates under load: 12 failed requests in 23,172 at 0.01s, none in 52,867 at 5s.
  • Windows timeout: this file gets timeout = "eternal"; its Windows runs take 719-798s of the 900s long limit.

Validated under load with the HAProxy shard's environment: traffic tests 20 of 20, whole file 40 of 41, where the one failure only happens in a virtualenv rig.

@johntaylor-cell
johntaylor-cell requested a review from a team as a code owner September 25, 2026 13:03
@johntaylor-cell johntaylor-cell self-assigned this Sep 25, 2026
@johntaylor-cell johntaylor-cell added serve Ray Serve Related Issue go add ONLY when ready to merge, run all tests labels Sep 25, 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 adds explicit timeouts to several wait_for_condition calls in test_deploy_app_2.py to prevent hanging, and introduces a helper function to retry HTTP GET requests when HAProxy drops connections during rolling updates. The reviewer suggests catching the broader httpx.TransportError instead of just httpx.RemoteProtocolError in the retry helper to make it more robust against other transient network issues.

@johntaylor-cell johntaylor-cell changed the title [server] Deflake test_deploy_app_2 - explicit wait budgets and a retry for requests dropped by HAProxy reloads [serve] Deflake test_deploy_app_2 - explicit wait budgets and a retry for requests dropped by HAProxy reloads Sep 25, 2026
@johntaylor-cell johntaylor-cell added the unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. label Oct 1, 2026
abrarsheikh pushed a commit that referenced this pull request Oct 6, 2026
… requests (#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 #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]>
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]>

@abrarsheikh abrarsheikh 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.

@harshit-anyscale can you take a look at this? Seems to be an issue you have dealt with in the past? Is this issue a fundamental gap in HAProxy? Trying to assess is masking the issue with test retry and timeout is the right fix here.

johntaylor-cell and others added 3 commits October 16, 2026 15:15
…esh deploys and multi-replica starts

The target flaked on the HAProxy shard (d758095, 2026-09-24). 19 wait_for_condition calls sat on the bare 10s default over work that scales with what is deployed: a fresh deploy_apps (build task, replica start, first routable request) in the older tests, and 2- and 5-replica starts in the rolling-update tests, whose sibling tests already budget 60s for the same deploy. Under load the 5-replica check_running missed its deadline by 0.1s (a 2s build plus five parallel starts at 7-8s each) and two of the deploy waits ran at 99-104% of budget. One of them waits for a rebuild that must fail: Ray retries a failing build task three times in fresh workers (max_retries=3, retry_exceptions=True), so that wait spans four build attempts and sits at 93% of the bare budget even at CI-like load.

Waits over a fresh deploy get 20s; the three multi-replica check_running calls get the 60s their siblings use. No wait is shortened, so green runs take the same time. Validated in the same rig, whole file under the HAProxy shard's environment: before, 5 failures at these sites in 3 runs at 2 stressors; after, none in 5 runs at 1 and 2 stressors. The two failures that remained, both in test_rolling_update_chain_with_rollback, are the drain race the next commit addresses.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: john.taylor <[email protected]>
…r than an HAProxy reload

The HAProxy shard sets RAY_SERVE_DIRECT_INGRESS_MIN_DRAINING_PERIOD_S=0.01; the default is 30s. When a replica's draining period ends, its graceful shutdown closes HAProxy's pooled connections to it, and at 0.01s that happens before the reload that stops HAProxy routing to the replica has landed. A request HAProxy writes into a closing connection fails, as an SH-- 502 or as a client-side "Server disconnected without sending a response", and the two tests that assert every request returns 200 through rolling updates count it.

Give those tests' ingress replicas a 5s drain through the replica environment, as test_deploy_app_3 already does: on D1 in test_rolling_update_chain_with_rollback's config, and as a code-defined option of a FailOnFlag builder for test_sparse_config_rollback_restores_code_defined_options, whose rollback must carry no config overrides. The setting has no effect without direct ingress, so other shards are unchanged. Measured over 30 rolling updates of a 2-replica app with a request every 5 ms under load: at 0.01s, 12 failed requests in 23,172 across three runs; at 5s, none in 52,867 across two; at 30s, none in 225,913 across two, at five times the wall time.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: john.taylor <[email protected]>
On Windows the target's successful runs take 719s, 771s and 798s (min, median and max over the last 16 commits that ran it) against the long timeout's 900s, and in that window one commit FAILED and two were FLAKY. Bazel cannot set a test timeout per platform, so the file moves to its own block with timeout = "eternal"; Linux runs take 460-593s and are unaffected in practice. The block's env becomes a variable both blocks use, so they cannot drift apart. The target name, tags and Windows shard (use_all_core_windows) are unchanged.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: john.taylor <[email protected]>
@johntaylor-cell
johntaylor-cell force-pushed the serve-deploy-app2-deflake branch from 916e187 to ec2ff3c Compare October 16, 2026 18:26
@johntaylor-cell johntaylor-cell changed the title [serve] Deflake test_deploy_app_2 - explicit wait budgets and a retry for requests dropped by HAProxy reloads [serve] Deflake test_deploy_app_2 - wait budgets, a longer ingress drain for the traffic tests, and a Windows timeout Oct 16, 2026
@abrarsheikh
abrarsheikh enabled auto-merge (squash) October 16, 2026 23:18
@abrarsheikh
abrarsheikh merged commit 09cc6ec into ray-project:master Oct 19, 2026
7 checks passed
qishengxhe pushed a commit to qishengxhe/ray that referenced this pull request Oct 26, 2026
…, a longer ingress drain for the traffic tests, and a Windows timeout (ray-project#66492)

(cherry picked from commit 09cc6ec)
Signed-off-by: qishengxhe <[email protected]>
elliot-barn pushed a commit that referenced this pull request Oct 26, 2026
…, a longer ingress drain for the traffic tests, and a Windows timeout (#66492) (#67439)

Cherry-pick of #66492 ([serve] Deflake test_deploy_app_2 - wait budgets,
a longer ingress drain for the traffic tests, and a Windows timeout)
onto `releases/2.60.0`. Master commit `09cc6ec807`.

Applied cleanly with `git cherry-pick -x`. Test-only changes:
`BUILD.bazel`, `test_config_files/fail_on_flag.py`,
`test_deploy_app_2.py`.

Needed on the release branch because #67165 (cherry-pick in #67438)
imports `INGRESS_DRAIN_ENV`, which this change adds. Split into its own
PR so each squash on the release branch maps to one master commit.

No other backport PR for this change targets `releases/2.60.0`.
`pre-commit run --files` on the touched files passes. Relying on CI for
the test runs.

AI assistance was used to prepare this cherry-pick.

Signed-off-by: qishengxhe <[email protected]>
Co-authored-by: johntaylor-cell <[email protected]>
elliot-barn pushed a commit that referenced this pull request Oct 26, 2026
Cherry-pick of #67165 ([serve] Deflake test_deploy_app_3) onto
`releases/2.60.0`. Master commit `b2ca380473`.

Applied cleanly with `git cherry-pick -x`. Test-only change:
`test_deploy_app_3.py`.

Depends on #67439 (cherry-pick of #66492), which adds the
`INGRESS_DRAIN_ENV` fixture constant this test imports. Stacked on that
PR so this diff shows only #67165; merge #67439 first, then retarget
this PR to `releases/2.60.0`.

No other backport PR for this change targets `releases/2.60.0`.
`pre-commit run --files` on the touched file passes. Relying on CI for
the test runs.

AI assistance was used to prepare this cherry-pick.

Signed-off-by: john.taylor <[email protected]>
Signed-off-by: qishengxhe <[email protected]>
Co-authored-by: johntaylor-cell <[email protected]>
Co-authored-by: Claude <[email protected]>
elliot-barn added a commit that referenced this pull request Oct 26, 2026
Cherry-pick of #67165 onto `releases/2.60.0`.

Original PR: #67165 (merged on master as b2ca380). This cherry-pick
was first made as #67438. That PR was stacked on the #66492 cherry-pick
branch and merged into it after #67439 had already landed, so it never
reached `releases/2.60.0`. This PR applies the same commit (c4840ed)
directly onto `releases/2.60.0`. It replaces #67441, which was opened
from the stacked branch and showed the already-landed #66492 changes
alongside this one.

## Change

`python/ray/serve/tests/test_deploy_app_3.py` only, +59/-41, identical
to #67165 and #67438. The cherry-pick applied cleanly.

From #67165: `test_deploy_app_3` flakes on the HAProxy, gRPC and
flaky-tests shards. The fix:
- waits read replica counts and pids from one snapshot;
- traffic tests whose replicas stop during a rollout use the 5s HAProxy
drain;
- handles the direct-ingress request-count race.

## Testing

Test-only change, verified on master in #67165. This PR's premerge runs
the Serve test shards against `releases/2.60.0`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: john.taylor <[email protected]>
Signed-off-by: qishengxhe <[email protected]>
Co-authored-by: qishengxhe <[email protected]>
Co-authored-by: johntaylor-cell <[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 unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants