Description
What happened + What you expected to happen
Description
When an app was deployed declaratively (with serve deploy or the REST API) and is then removed with serve.delete(), the app is deleted, but the saved config checkpoint (CONFIG_CHECKPOINT_KEY) still contains it. On the next controller restart, the deleted app is redeployed without any user action.
serve.delete() and serve deploy update different state:
serve deploygoes throughServeController.apply_config, which writes the full config toCONFIG_CHECKPOINT_KEYand then applies it.serve.delete()goes throughServeController.delete_apps, which deletes the app from the application state manager and saves the application state checkpoint, but does not updateCONFIG_CHECKPOINT_KEY.
When the controller recovers, _recover_state_from_checkpoint re-applies the saved config with apply_config, which recreates the deleted app.
The stale entry is not visible beforehand. serve config and deployed_app_config only list apps that are still running, so the deleted app looks gone until the controller restarts.
Impact
- A deleted app comes back. Any controller restart, for example after a crash or a head node recovery, redeploys apps the user deleted with
serve.delete(). - Auto-rollback ([Serve][RFC] Auto-rollback for
serve deploy#63016). Rolling back to the last good config would also restore an app deleted withserve.delete().
serve.shutdown() does not have this problem, because ServeController.shutdown deletes CONFIG_CHECKPOINT_KEY.
Proposed fix
Proposed fix
Treat serve.delete() on a declarative app as a change to the current config, not a new config submission.
In ServeController.delete_apps:
- Find the declarative apps among the requested names, using
api_type. Imperative apps (serve.run) are deleted directly, as today. - Remove them from the saved config. Edit
CONFIG_CHECKPOINT_KEYin place and drop only those apps. Everything else is written back unchanged: the other apps,target_capacityand its direction, the deployment time andconfig_id. The saved config is updated before the apps are deleted, so if the controller crashes in between, recovery still deletes them. - Log a warning that the app was removed from the saved config and that the user's config file should be updated too, so the next
serve deploydoesn't bring it back. - Docs. Update the
serve.delete()docstring and the multi-app guide.
The other apps are never reapplied. Re applying the config through apply_config would also fix the restart bug, but it would reapply every remaining app: a build still in progress would restart, and a failed build would be retried, just because a different app was deleted.
Behavior after the fix
| Today | After the fix | |
|---|---|---|
| Deleted declarative app after a restart | Comes back | Stays deleted |
| Saved config checkpoint | Still lists the deleted app | Updated without it |
| Other apps in the config | Not touched | Not touched (not re-applied, rebuilt or restarted) |
Imperative apps (serve.run) |
Deleted directly | Same |
serve.delete() blocking |
Waits until the app is gone | Same |
applied_config_id |
Not changed by a delete | Same |
| Rejected deletes | None | None |
target_capacity and its direction remain unchanged.
applied_config_id. This keeps today's behavior. The ID is only set when a config is submitted through apply_config (#67458), so a delete doesn't change it. After the fix, the rebuilt config keeps the same config_id, so the ID still identifies the same submission, and the deleted app simply shows as missing from applications. Only a new serve deploy or REST PUT changes the ID, and a new config without an ID clears it, as today.
Documentation.
serve.delete()docstring: explain that deleting a declarative app also removes it from the saved config, that the user's config file should be updated, and thatapplied_config_idis unchanged.ServeDeploySchema.config_iddescription: note that the ID is kept whenserve.delete()removes apps, and only changes when a new config is submitted.- Any Serve guides under
doc/source/serve/that describeserve.delete()with declarative configs.
I have a working fix along these lines and will open a PR shortly.
Related
- [Serve][RFC] Auto-rollback for
serve deploy#63016: auto-rollback RFC - [Serve] [1/N] Add RolloutSupervisor core logic - auto-rollback feature #63382:
RolloutSupervisorcore logic - [serve] Expose replica versions and applied config id in the details API #67458: added
config_id/applied_config_id
Versions / Dependencies
- Ray: 3.0.0.dev0 (built from master at commit
7cd3cd3c0e) - Python: 3.11.13
- Pydantic: 2.12
- OS: macOS (Darwin 25.6.0)
Reproduction script
Steps to reproduce (verified on master)
app.py:
from ray import serve
@serve.deployment
class Hello:
def __call__(self, request) -> str:
return "hello"
app = Hello.bind()config.yaml:
applications:
- name: app1
route_prefix: /app1
import_path: app:app
runtime_env:
working_dir: local:///tmp/serve_delete_test
- name: app2
route_prefix: /app2
import_path: app:app
runtime_env:
working_dir: local:///tmp/serve_delete_testray start --head, thenserve deploy config.yaml. Both apps reachRUNNING.- Delete
app1:import ray from ray import serve ray.init(address="auto", namespace="serve") serve.delete("app1")
serve statusnow shows onlyapp2. - Restart the Serve controller:
import ray from ray.serve._private.constants import SERVE_CONTROLLER_NAME, SERVE_NAMESPACE ray.init(address="auto", namespace=SERVE_NAMESPACE) controller = ray.get_actor(SERVE_CONTROLLER_NAME, namespace=SERVE_NAMESPACE) ray.kill(controller, no_restart=False)
serve statusshowsapp1running again, with the samelast_deployed_time_sas the original deploy.
Issue Severity
Low: It annoys or frustrates me.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn progress
Activity
PCTEJA commentedon Nov 30, 2026
Thanks for the thorough write-up — the checkpoint divergence between
serve deployandserve.delete()is very clear, and the proposed fix (split by api_type, re-apply the saved config minus the deleted declarative apps throughapply_config) looks like the right shape.I'm planning to work on the fix for this. Do you already have something locally for it, or are you already working on it? Happy to pick it up if not — I'll hold off on opening a PR until I hear back.
vaishdho1 commentedon Nov 30, 2026
I already have a working fix locally verified. I will open the PR shortly.