Repository navigation
Conversation
Signed-off-by: Vaishnavi Panchavati <[email protected]>
Signed-off-by: Vaishnavi Panchavati <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces the RolloutSupervisor to manage automatic rollbacks for Ray Serve deployments, supported by new RolloutState and ConfigSnapshot definitions and a unit test suite. The reviewer identified a critical logic error in the application status check where the DEPLOYING status was incorrectly prioritized over DEPLOY_FAILED, potentially delaying rollbacks. Other feedback included correcting type hints for optional configuration attributes and fixing a typo in a test function name.
| for app_name in self._current_config.config_dict: | ||
| if app_name not in app_statuses: | ||
| return ApplicationStatus.DEPLOYING | ||
| status = app_statuses[app_name].status | ||
| if status == ApplicationStatus.DEPLOY_FAILED: | ||
| return ApplicationStatus.DEPLOY_FAILED | ||
| if status == ApplicationStatus.DEPLOYING: | ||
| atleast_one_deploying = True | ||
| elif status == ApplicationStatus.UNHEALTHY: | ||
| atleast_one_unhealthy = True |
There was a problem hiding this comment.
The current implementation of _check_apps_status returns ApplicationStatus.DEPLOYING immediately if an application is not found in app_statuses. This violates the precedence rules defined in the docstring, where DEPLOY_FAILED should take priority. If one application has already failed but another is not yet present in the status manager, the supervisor will incorrectly report DEPLOYING and delay the rollback process. The loop should continue checking for failures even if an app is missing.
| for app_name in self._current_config.config_dict: | |
| if app_name not in app_statuses: | |
| return ApplicationStatus.DEPLOYING | |
| status = app_statuses[app_name].status | |
| if status == ApplicationStatus.DEPLOY_FAILED: | |
| return ApplicationStatus.DEPLOY_FAILED | |
| if status == ApplicationStatus.DEPLOYING: | |
| atleast_one_deploying = True | |
| elif status == ApplicationStatus.UNHEALTHY: | |
| atleast_one_unhealthy = True | |
| for app_name in self._current_config.config_dict: | |
| if app_name not in app_statuses: | |
| atleast_one_deploying = True | |
| continue | |
| status = app_statuses[app_name].status | |
| if status == ApplicationStatus.DEPLOY_FAILED: | |
| return ApplicationStatus.DEPLOY_FAILED | |
| if status == ApplicationStatus.DEPLOYING: | |
| atleast_one_deploying = True | |
| elif status == ApplicationStatus.UNHEALTHY: | |
| atleast_one_unhealthy = True |
There was a problem hiding this comment.
This condition will never be touched in the actual flow. apply_app_configs guarantees all apps exist before update() runs.
Removed in 5451521
There was a problem hiding this comment.
right, but still good to be defensive here right?
There was a problem hiding this comment.
If an app in config_dict isn't in app_statuses, it means apply_app_configs never created its state, which shouldn't happen in the current flow. We can still add a defensive check here and treat it as DEPLOY_FAILED since we can only recover from this scenario by rolling back if that is possible.
Added in 7cd3cd3
Signed-off-by: Vaishnavi Panchavati <[email protected]>
Signed-off-by: Vaishnavi Panchavati <[email protected]>
| return ApplicationStatus.DEPLOYING | ||
| if atleast_one_unhealthy: | ||
| return ApplicationStatus.UNHEALTHY | ||
| return ApplicationStatus.RUNNING |
There was a problem hiding this comment.
Unhandled app statuses silently treated as RUNNING
Medium Severity
_check_apps_status only explicitly handles DEPLOY_FAILED, DEPLOYING, and UNHEALTHY, causing any other ApplicationStatus value — including DELETING and NOT_STARTED — to silently fall through and be counted as RUNNING. The real ApplicationState._determine_app_status can return DELETING for apps that exist in _application_states. If an app in the current config happens to have one of these unhandled statuses, _check_apps_status returns RUNNING, and update() would incorrectly promote the config to _last_good_config and transition to IDLE. This also isn't future-proof — any new ApplicationStatus variant added to the enum would be silently treated as healthy.
Reviewed by Cursor Bugbot for commit f6e8b8e. Configure here.
There was a problem hiding this comment.
The supervisor only sees apps that were just submitted via apply_app_configs, and those apps can only be in DEPLOYING, RUNNING, UNHEALTHY, or DEPLOY_FAILED states. The other states are not touched during its watching state.
There was a problem hiding this comment.
will update not be called on every controller loop? if it is being called on every loop then it is possible to get app status with DELETING no?
There was a problem hiding this comment.
This is an interesting case. An app in _current_config can only reach DELETING if someone calls the imperative serve.delete() on it. In the declarative flow, removing an app means submitting a new config without it, apply_app_configs handles deletion via set difference and updates _current_config in the same call, so _check_apps_status never sees it.
Hitting DELETING here would require mixing imperative and declarative APIs. There's no guard preventing that today, so it could still happen accidentally. There are a couple of options to prevent this:
- Add a guard in
controller.delete_apps()that rejects calls targeting declaratively managed apps. - Internally translate the imperative delete into a new config without that app and route it through
apply_app_configs.
There was a problem hiding this comment.
Following up on this. The supervisor now handles DELETING and missing apps explicitly instead of treating them as RUNNING. If an app in the current config was deleted outside the config, the supervisor goes back to IDLE without promoting the config, and real failures still trigger a rollback. The updated state diagram is on the RFC #63016 (comment)
For serve.delete() on declarative apps, I have opened a separate issue #68660 with the second fix, since the deleted app also comes back after a controller restart. The fix will go in it own PR
|
@abrarsheikh Could you review this PR? |
|
@vaishdho1 premerge tests have been failing, can you PTAL? |
|
@harshit-anyscale This is a windows build failure in the CI environment. I retried it after pushing the latest changes, but its the same failure again. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Reviewed by Cursor Bugbot for commit a9d0b29. Configure here.
| elif self._state == RolloutState.ROLLING_BACK: | ||
| # Rollback succeeded. | ||
| self._state = RolloutState.ROLLED_BACK | ||
| return False |
There was a problem hiding this comment.
Premature rollback completion
High Severity
When a deploy fails, update() sets ROLLING_BACK and points _current_config at _last_good_config before the controller reapplies that snapshot. The next update() then runs _check_apps_status() only over last-good app names, so statuses from the failed rollout (still RUNNING, DEPLOY_FAILED, or DELETING) can be misread as rollback success or immediate ROLLBACK_FAILED.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit a9d0b29. Configure here.
There was a problem hiding this comment.
This is not a problem here. The next PR which connects the controller to the rollout supervisor logic makes it clear.
The controller 's run_control_loop_step implements the following steps:
- calls
supervisor.update()detects failure, sets ROLLING_BACK, swaps _current_config to _last_good_config, returns True - Controller immediately calls apply_config() on the application state manager
- apply_app_configs() always resets every app in the rollback config to DEPLOYING
In the next tick, when the supervisor runs _check_apps_status(), all last-good apps are already at DEPLOYING after reconciliation.
| for app_name in self._current_config.config_dict: | ||
| if app_name not in app_statuses: | ||
| return ApplicationStatus.DEPLOYING | ||
| status = app_statuses[app_name].status | ||
| if status == ApplicationStatus.DEPLOY_FAILED: | ||
| return ApplicationStatus.DEPLOY_FAILED | ||
| if status == ApplicationStatus.DEPLOYING: | ||
| atleast_one_deploying = True | ||
| elif status == ApplicationStatus.UNHEALTHY: | ||
| atleast_one_unhealthy = True |
There was a problem hiding this comment.
right, but still good to be defensive here right?
| return ApplicationStatus.DEPLOYING | ||
| if atleast_one_unhealthy: | ||
| return ApplicationStatus.UNHEALTHY | ||
| return ApplicationStatus.RUNNING |
There was a problem hiding this comment.
will update not be called on every controller loop? if it is being called on every loop then it is possible to get app status with DELETING no?
| return ApplicationStatus.UNHEALTHY | ||
| return ApplicationStatus.RUNNING | ||
|
|
||
| def update(self) -> bool: |
There was a problem hiding this comment.
maybe a future addition but how do we want to handle stuck (ApplicationStatus.DEPLOYING, ApplicationStatus.UNHEALTHY), should we have a timeout feature?
There was a problem hiding this comment.
Handling stuck states inside the rollout supervisor or even at controller level is not going to be accurate. It doesn't have enough context to make the right call. The deployment state manager is where the actual logic lives, so that's where the decision on how long to wait should be made. In the current flow it just waits forever.
For this we need to analyze how to change the flow for DEPLOYING and UNHEALTHY states which are stuck and decide on when to escalate this.
This needs its own exploration and design work. I can check that and file it separately.
We can keep the supervisor to just react on the signal that it receives, to keep this simple.
…ager Signed-off-by: Vaishnavi Panchavati <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
unstale, will review |
|
@abrarsheikh Could you review this PR |
Signed-off-by: Vaishnavi Panchavati <[email protected]>
Signed-off-by: Vaishnavi Panchavati <[email protected]>
Signed-off-by: Vaishnavi Panchavati <[email protected]>


Description
This is the first PR towards implementing auto-rollback for
serve deploy(#63016). It Implements the core RolloutSupervisor state machine logic along with unit tests to test its behavior.Changes
common.py: AddRolloutStateenum andConfigSnapshotdataclass.rollout_supervisor.py(new) : Entire state machine logic for the Rollout supervisortest_rollout_supervisor.py(new): Unit tests covering all state transitions.Related issues
Related to #63016
Follow up
The next PR is Controller integration and checkpoint persistence