Skip to content

[Serve] Fix race in test_flapping_rolling_update_stops_consuming_old_replicas - #67163

Merged
jeffreywang88 merged 1 commit into
masterfrom
serve-flaky
Oct 20, 2026
Merged

jeffreywang88 merged 1 commit into
masterfrom
serve-flaky

Conversation

@jeffreywang88

Copy link
Copy Markdown
Contributor

Description

Fix a race in test_flapping_rolling_update_stops_consuming_old_replicas: separate state and PID queries could incorrectly declare cleanup complete. Wait for terminal rollout failure and derive both checks from the same replica details.

Validated with real actors and HAProxy in Ray and RayTurbo: controlled failure reproduced before the fix; controlled runs and five ordinary repetitions passed afterward in both. Pre-commit passed.

AI assistance was used.

Related issues

Link related issues: "Fixes #1234", "Closes #1234", or "Related to #1234".

Additional information

Optional: Add implementation details, API changes, usage examples, screenshots, etc.

@jeffreywang88 jeffreywang88 added the go add ONLY when ready to merge, run all tests label Oct 19, 2026
@jeffreywang88
jeffreywang88 requested a review from a team as a code owner October 19, 2026 18:04

@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 refactors the test test_flapping_rolling_update_stops_consuming_old_replicas in python/ray/serve/tests/test_deploy_app_2.py. It replaces the local check_deploy_failed helper with a shared _check_terminal_rolling_update function. Additionally, it updates check_settled to query replica details once via _deployment_details(client).replicas instead of making separate queries, preventing race conditions where a replica transitioning from RUNNING to STOPPING might be missed. There are no review comments to address.

@johntaylor-cell johntaylor-cell 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.

LGTM

@jeffreywang88
jeffreywang88 enabled auto-merge (squash) October 19, 2026 18:51
@ray-gardener ray-gardener Bot added the serve Ray Serve Related Issue label Oct 19, 2026
@jeffreywang88
jeffreywang88 merged commit a705161 into master Oct 20, 2026
6 checks passed
@jeffreywang88
jeffreywang88 deleted the serve-flaky branch October 20, 2026 02:31
jeffreywang88 pushed a commit that referenced this pull request Oct 20, 2026
`test_deploy_app_3` (added in #66267) flakes on the HAProxy, gRPC and
flaky-tests shards. One commit per cause:

- Two waits read replica counts and pids in separate calls, so a replica
changing state in between could pass for the state they wait for. They
now read one snapshot, as #67163 does for the same race in
`test_deploy_app_2`.
- The HAProxy shard's 0.01s drain lets a stopping replica close
connections HAProxy still uses. The traffic tests whose replicas stop
during a rollout now use the 5s drain `test_deploy_app_2` already uses;
the gang test is left out, since gang replicas are force-stopped.
- Under direct ingress, a request moving from the handle to a replica
can briefly count twice, which raised the autoscaling target in
`test_surge_rolling_update_follows_autoscaling_mid_rollout`. A 2s
upscale delay filters it.
- Two waits that ran close to their limit under load get more room.

Tested with `pytest python/ray/serve/tests/test_deploy_app_3.py` under
the default and HAProxy shard environments with CPU stressors: 13 of 13
in each at the final commit.

---------

Signed-off-by: john.taylor <[email protected]>
Co-authored-by: Claude <[email protected]>
qishengxhe pushed a commit to qishengxhe/ray that referenced this pull request Oct 26, 2026
…7165)

`test_deploy_app_3` (added in ray-project#66267) flakes on the HAProxy, gRPC and
flaky-tests shards. One commit per cause:

- Two waits read replica counts and pids in separate calls, so a replica
changing state in between could pass for the state they wait for. They
now read one snapshot, as ray-project#67163 does for the same race in
`test_deploy_app_2`.
- The HAProxy shard's 0.01s drain lets a stopping replica close
connections HAProxy still uses. The traffic tests whose replicas stop
during a rollout now use the 5s drain `test_deploy_app_2` already uses;
the gang test is left out, since gang replicas are force-stopped.
- Under direct ingress, a request moving from the handle to a replica
can briefly count twice, which raised the autoscaling target in
`test_surge_rolling_update_follows_autoscaling_mid_rollout`. A 2s
upscale delay filters it.
- Two waits that ran close to their limit under load get more room.

Tested with `pytest python/ray/serve/tests/test_deploy_app_3.py` under
the default and HAProxy shard environments with CPU stressors: 13 of 13
in each at the final commit.

---------

Signed-off-by: john.taylor <[email protected]>
Co-authored-by: Claude <[email protected]>
(cherry picked from commit b2ca380)
Signed-off-by: qishengxhe <[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.

Ray fails to serialize self-reference objects

3 participants