Skip to content

[serve][in-place-updates][1/n] Keep old replicas routable after a failed rolling in-place update - #66252

Merged
abrarsheikh merged 1 commit into
ray-project:masterfrom
qishengxhe:serve/keep-old-replicas-routable
Sep 18, 2026
Merged

abrarsheikh merged 1 commit into
ray-project:masterfrom
qishengxhe:serve/keep-old-replicas-routable

Conversation

@qishengxhe

@qishengxhe qishengxhe commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A failed rolling update can leave healthy replicas from the previous version running, but Serve marks the deployment unavailable and rejects requests with HTTP 503.

This change keeps the deployment available while it has running replicas. Health checks continue as usual, and unhealthy replicas are removed from routing.

This preserves traffic through surviving replicas. It does not restore full capacity or automatically roll back the update. If no replicas survive, the deployment remains unavailable. A caller, such as the control plane, must redeploy a healthy configuration to recover.

Tests

Added a unit test for router availability and integration tests covering application rebuilds and runtime environment changes.

The new test sends continuous traffic through D1 → D2 during a healthy update, a failing update in D2, and an explicit rollback. It checks that no requests fail and both deployments recover fully.

All four integration cases passed. Removing the fix makes both new cases fail with HTTP 503s. The original deployment state unit suite passed all 259 tests.

Also tested on a real cluster with the next two commits in this series: no requests failed, compared with about 45 HTTP 503s per failed update on an unmodified image.

Duplicate check

Searches for open PRs about is_available and rolling updates, including changes to the same code in deployment_state.py, found no overlapping fix.

AI assistance

Claude Code assisted with the implementation. I reviewed every changed line and ran the tests listed above locally.

@qishengxhe qishengxhe changed the title [serve] Keep old replicas routable after a terminally failed rolling update [serve] Keep old replicas routable after a failed rolling in-place update Sep 17, 2026
@qishengxhe qishengxhe changed the title [serve] Keep old replicas routable after a failed rolling in-place update [serve][in-place-updates][1/n] Keep old replicas routable after a failed rolling in-place update Sep 17, 2026
@qishengxhe qishengxhe added go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue labels Sep 17, 2026
@qishengxhe
qishengxhe marked this pull request as ready for review September 17, 2026 23:26
@qishengxhe
qishengxhe requested a review from a team as a code owner September 17, 2026 23:26

@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 ensures that surviving replicas continue to receive traffic and remain available even after a rolling update fails terminally. This is achieved by updating the availability logic in deployment_state.py to check if there are any running replicas. Additionally, new integration and unit tests are added to verify this behavior. The review feedback suggests using the idiomatic dict.copy() method instead of copy() in the test file to avoid potential import issues.

@johntaylor-cell

Copy link
Copy Markdown
Contributor

The change is good. Two things belong in the description before it merges.

First, the scope. This only helps when the rollout leaves a surviving old replica, so num_replicas=1 and rolling_update_percentage=1.0 still get a full 503 outage. Both tests use the case that works.

Second, and worth a release note, the deployment now sits at reduced capacity indefinitely, serving stale code under a DEPLOY_FAILED status. _get_upscale_replicas bails on _terminally_failed(), so the replicas the rollout stopped are never replaced, and neither are survivors that later die, until the last one goes and it quietly returns to 503. That is a better failure mode than today's, but it swaps a loud outage for silent degradation. Is restoring capacity or rolling back the plan for a later part of the series?

On the integration test, timeout=60 has to cover six constructor failures plus the initial rollout on a target that also runs on Windows, so I would raise it to 120s. And the closing loop of 20 requests with no delay finishes in well under a second, so it proves routing survived the transition but not that it stays up.

And the bot comment seems reasonable to apply.

@qishengxhe
qishengxhe force-pushed the serve/keep-old-replicas-routable branch from c3946a2 to d8191c3 Compare September 18, 2026 02:27
@qishengxhe

Copy link
Copy Markdown
Contributor Author

The change is good. Two things belong in the description before it merges.

First, the scope. This only helps when the rollout leaves a surviving old replica, so num_replicas=1 and rolling_update_percentage=1.0 still get a full 503 outage. Both tests use the case that works.

Second, and worth a release note, the deployment now sits at reduced capacity indefinitely, serving stale code under a DEPLOY_FAILED status. _get_upscale_replicas bails on _terminally_failed(), so the replicas the rollout stopped are never replaced, and neither are survivors that later die, until the last one goes and it quietly returns to 503. That is a better failure mode than today's, but it swaps a loud outage for silent degradation. Is restoring capacity or rolling back the plan for a later part of the series?

On the integration test, timeout=60 has to cover six constructor failures plus the initial rollout on a target that also runs on Windows, so I would raise it to 120s. And the closing loop of 20 requests with no delay finishes in well under a second, so it proves routing survived the transition but not that it stays up.

And the bot comment seems reasonable to apply.

good idea, I updated the description and addressed the bot comment.
The control plane will decide when to roll back based on failure status reported by ray serve, because the control plane tracks service versions and persists the last good config as rollback target.

…update

`is_available` was derived from `_terminally_failed()` alone, so once a
rolling update hit the replica startup threshold the routers rejected every
request (HTTP 503) although the old-version replicas that were not replaced
yet were still RUNNING and in the broadcast running set. A deployment is now
unavailable only when it is terminally failed *and* has no running replica,
which keeps fresh deploys and scale-from-zero (ray-project#51600) unchanged.

Tests: unit test on the broadcast payload after a failed rolling update
(fails on master with is_available=False) and an integration test that keeps
getting 200 from the surviving replica after DEPLOY_FAILED, for both a
rebuild-class and a replica-restart-class update (fails on master with 503).

Signed-off-by: Qisheng He <[email protected]>
@abrarsheikh
abrarsheikh merged commit d08f88c into ray-project:master Sep 18, 2026
6 checks passed
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
sai-miduthuri pushed a commit that referenced this pull request Oct 16, 2026
…rcent` for start-before-stop rolling updates (#66267) (#67094)

Cherry-pick of #66267 (master commit
9491664) onto `releases/2.60.0`.

## Why

The first three PRs of the in-place-updates series (#66252, #66290,
#66266) are already on `releases/2.60.0`. This picks the fourth, which
adds `max_surge_percent` for start-before-stop rolling updates, so
2.60.0 ships the complete series.

## Cherry-pick details

`git cherry-pick -x` conflicted in one file,
`python/ray/serve/tests/unit/test_deployment_state.py`. The conflict was
positional only: on master, #66243 (push-based replica health) had
appended `TestPushedHealthEndToEnd` and related tests to the end of that
file, and #66267 inserts `TestMaxSurge` right before them. This branch
doesn't have #66243, so git couldn't anchor the hunk and offered the
#66243 tests as part of the incoming side. Resolved by inserting only
the PR's `TestMaxSurge` block (plus its `defaultdict` import) before the
`__main__` guard. The added and removed lines in each of the 17 files
are identical to the master commit's diff.

After the pick, 11 of the 17 files are byte-identical to master at
9491664. The other 6 differ only by master commits that aren't on
this branch and that #66267 doesn't depend on:

- `_private/deployment_state.py`, `tests/unit/test_deployment_state.py`:
#66243.
- `schema.py`, `tests/BUILD.bazel`, `tests/test_controller.py`,
`tests/test_direct_ingress.py`: #66339 and #66940.

No commit on `releases/2.60.0` after the branch cut touched any of these
files.

Not a duplicate: no PR against `releases/2.60.0` references #66267.

## Testing

Run on this branch with the Serve protobuf regenerated from the branch's
`serve.proto` (the pick adds the `max_surge_percent` field).

```
python -m pytest python/ray/serve/tests/unit/test_deployment_state.py python/ray/serve/tests/unit/test_config.py python/ray/serve/tests/unit/test_deployment_class.py python/ray/serve/tests/unit/test_schema.py
3530 passed, 12 skipped
```

```
python -m pytest python/ray/serve/tests/test_deploy_app_3.py python/ray/serve/tests/test_deploy_app_2.py -k surge
13 passed, 41 deselected in 282s
```

`pre-commit run --files <changed files>` passed.

AI assistance was used to prepare this cherry-pick.

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

Signed-off-by: Qisheng He <[email protected]>
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.

3 participants