Repository navigation
[train] Add end-to-end tests for elastic runs, Ctrl-C while waiting, and losing the coordinator's node - #67481
Closed
pseudo-rnd-thoughts wants to merge 4 commits into
Conversation
…oordinator's view is wrong Train V2 sizes its worker group from the AutoscalingCoordinator's reservation, which is built from each node's total capacity, counts draining nodes as alive, and is recomputed from scratch when nodes join or leave. Pinning workers to that reservation (ray-project#66002, reverted in ray-project#67337) turned each of the following into a run that retried the same pins forever. These tests assert that the run starts and finishes instead: - Capacity held outside the coordinator: an actor holds node X's slot. The run must start on node Y. - Draining node: X is draining after a preemption notice and is still reported alive. The run must start on Y. - Node churn with two runs: a node joins and sorts first, then the node of the second run is removed. The second run must restart on the new node without disturbing the first, and both must finish. - STRICT_SPREAD on an autoscaling cluster (ray-project#66766): the autoscaler must launch one node per worker, and the run must start on two nodes. Each run's driver and controller stay on the head node, so the scenarios can drain and remove worker nodes. Against the code before the revert, the occupied and draining tests time out, the churn test's second run loops on WorkerGroupStartupTimeoutError while the new node sits free, and the STRICT_SPREAD run waits forever on a reservation that covers one node. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Mark Towers <[email protected]>
…eing, release and STRICT_PACK cases The tests check scheduling cases Train V2 must handle, so they belong with the existing placement tests rather than in a file of their own. - Merge the occupied-node and draining-node tests into one parametrized test, test_starts_when_a_node_is_unusable. - Add test_runs_queue_for_a_single_slot: a run waiting for a slot another run holds keeps retrying, then starts on that node once it frees up. - Add test_a_finished_run_releases_its_resources: a finished run gives back its placement group and its coordinator request, so a new request at the same priority gets the slot and a second run lands on the same node. - Add test_strict_pack_starts_on_an_autoscaling_cluster: the autoscaler launches a node with room for every STRICT_PACK worker. - The PACK/SPREAD and label-selector tests don't change their cluster, so they share one class-scoped cluster instead of starting five. - Remove the test_scheduling_regressions target and make test_scheduling large. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Mark Towers <[email protected]>
Signed-off-by: Mark Towers <[email protected]>
…and losing the coordinator's node Each test fails without the fix in this branch that it covers: - test_elastic_run_starts_when_a_node_is_unusable[draining]: an elastic run of one or two workers starts with one worker when the other node is draining. Without the draining exclusion it retries two workers forever. - test_elastic_run_starts_when_a_node_is_unusable[slot_held_outside_the_coordinator]: marked xfail(strict=True). Elastic runs still size themselves from total capacity, so they retry two workers forever. This records the known gap. - test_ctrl_c_aborts_a_run_waiting_for_workers: Ctrl-C on a real driver process aborts an elastic run waiting for min_workers within 30s. Without the controller yield, the abort never reaches the controller. A Ray task can't stand in for the driver, because a task blocked in ray.get doesn't run Python signal handlers. - test_run_restarts_after_the_coordinators_first_caller_dies: the coordinator is created from node X, a run starts on X and Y, then X dies. The run, which holds a handle to the coordinator, restarts on Y. Without the head-node placement the coordinator dies with X and the run never restarts. - test_higher_priority_request_is_reserved_first: when two requests' bundles don't both fit, a later HIGH request is reserved ahead of an earlier MEDIUM one. Nothing tested the priority ordering before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Mark Towers <[email protected]>
This was referenced Oct 27, 2026
pseudo-rnd-thoughts
added a commit
that referenced
this pull request
Oct 29, 2026
…d fix the elastic node-killing release test (#67478) ## Description This PR fixes two issues with the controller. 1. **Controller busy-wait:** In `INITIALIZING`, `RESTARTING` and `RESCHEDULING`, `TrainController._step` never awaits, yielding the event loop. While the scaling policy keeps returning `NoopDecision` (an elastic run waiting for `min_workers` to fit, or a failed coordinator query), `run()` loops without yielding the event loop meaning that the controller actor spins a full core and that an `abort()` can't reach it, so Ctrl-C on the driver doesn't stop the run. This has been true for elastic runs since #60721. This PR updates `_step` to now sleeps `RAY_TRAIN_HEALTH_CHECK_INTERVAL_S` before asking the policy again, matching the running path's poll interval. Once `abort()` can run during that sleep, the control loop must not overwrite the `AbortedState` it set with the state computed before the abort, so a terminal state set concurrently is left in place. 2. **Elastic node-killing release test:** `terminate_node` in `elastic_util.py` runs its killer task on the node it terminates, with hard affinity and default retries. When the task dies with the node, Ray retries it, and the retry can never be scheduled, so `ray.get` raises `TaskUnschedulableError` and `train_elastic_e2e_with_node_killing` fails after training already succeeded (failure mode A). The killer task is no longer retried, and `NodeDiedError`, `WorkerCrashedError` and `TaskUnschedulableError` count as the node having gone down. New test: `test_abort_while_waiting_for_a_scaling_decision` in `test_controller.py`. It raises `TimeoutError` without the fix. The end-to-end version, `test_ctrl_c_aborts_a_run_waiting_for_workers` (a real driver process receiving SIGINT), is in #67481. AI assistance (Claude Code) was used to write these changes and tests, run the suites, and write this description. --------- Signed-off-by: Mark Towers <[email protected]> Co-authored-by: Mark Towers <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
pseudo-rnd-thoughts
added a commit
that referenced
this pull request
Oct 30, 2026
## Summary Runs the shared AutoscalingCoordinator actor on the head node instead of the first caller's node, so losing a worker node no longer takes the coordinator with it for every Ray Data and Ray Train requester on the cluster. ## Before `get_or_create_autoscaling_coordinator` created the detached actor with hard node affinity to the caller's node and `max_restarts=-1`. The original PR (#59353) noted "Create the actor on the local node, to reduce network overhead". The problem is that the coordinator, though, is shared by every requester on the cluster. The first caller can be on any node, for example a Train controller or a Ray Data executor inside a Train worker. If that node dies, the actor can't be rescheduled (`ActorUnschedulableError`). Requesters that already hold a handle, such as Train's coordinator client, lose it for good, so a running elastic run can't resize or restart. Soft affinity doesn't help: `ClusterResourceScheduler::GetBestSchedulableNode` places an actor that requests no resources on a random node unless its affinity is hard, so it could land on an autoscaled worker and restart elsewhere every time that worker scales down. ## After The actor requests `node:__internal_head__: 0.001` and uses `scheduling_strategy="DEFAULT"`. This is the same pattern as the Serve controller (`serve/_private/default_impl.py`) and both Train state actors (`train/_internal/state/state_actor.py`, `train/v2/_internal/state/state_actor.py`). The head node lives as long as the cluster. With GCS fault tolerance, a restarted head has the same resource, so the actor can restart there. The explicit `"DEFAULT"` strategy matters. Without it, a caller in a placement group that captures child tasks (Tune trials, Train V1 workers) makes the actor join that group. The bundles don't hold the head-node resource, so creation fails with `ValueError: Cannot schedule _AutoscalingCoordinatorActor with the placement group` and a detached actor shouldn't die with someone else's group anyway. ## New tests In `test_autoscaling_coordinator.py`: - `test_coordinator_actor_runs_on_the_head_node`: created from a worker node, the actor runs on the head and survives that worker's removal. - `test_coordinator_actor_escapes_the_callers_placement_group`: created from a task in a placement group that captures child tasks, the actor runs on the head and survives the group's removal. It fails without `scheduling_strategy="DEFAULT"`. The end-to-end case, `test_run_restarts_after_the_coordinators_first_caller_dies`, is in #67481. AI assistance (Claude Code) was used to write these changes and tests, run the suites, and write this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Mark Towers <[email protected]> Signed-off-by: Mark Towers <[email protected]> Co-authored-by: Mark Towers <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Chi-Sheng Liu <[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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
End-to-end tests for the fixes in #67478, #67479 and #67480, which #67421 left out because they only pass with those fixes.
test_elastic_run_starts_when_a_node_is_unusable[draining]test_elastic_run_starts_when_a_node_is_unusable[slot_held_outside_the_coordinator]xfail(strict=True): elastic runs size themselves from total capacity, so this still retries forever. Records the known gaptest_ctrl_c_aborts_a_run_waiting_for_workersmin_workers, then gets SIGINTtest_run_restarts_after_the_coordinators_first_caller_diestest_higher_priority_request_is_reserved_first(unit,test_autoscaling_coordinator.py)The Ctrl-C test uses a real driver subprocess, because a Ray task blocked in
ray.getdoesn't run Python signal handlers and so can't stand in for one.Series
This splits #67422 into reviewable pieces:
Testing
All local on macOS:
Not a duplicate. These tests were in #67422, which this series replaces. #67421 explicitly leaves them out.
AI assistance (Claude Code) was used to write these tests, check them against broken code, and write this description.
🤖 Generated with Claude Code