Repository navigation
Conversation
|
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. |
e1c68df to
8e97c94
Compare
Signed-off-by: Rueian <[email protected]>
8e97c94 to
7802f77
Compare
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
ed1fe17 to
7e1ff81
Compare
Signed-off-by: Rueian <[email protected]>
Signed-off-by: Rueian <[email protected]>
| node_info->death_info().reason() == | ||
| rpc::NodeDeathInfo::AUTOSCALER_DRAIN_PREEMPTED; | ||
| } | ||
| if (num_retries_left > 0 || (is_preempted && task_entry.spec.IsRetriable())) { |
There was a problem hiding this comment.
Even when num_retries_left == 0, we should still retry the task if it was preempted.
There was a problem hiding this comment.
Pull Request Overview
This PR implements a feature to exclude task retries due to node preemption from counting against the max_retries limit. When a task fails due to a node being preempted by the autoscaler, the task is retried without decrementing the retry counter, allowing for more resilient task execution in autoscaling environments.
- Modifies the task retry logic to check if a node failure was due to preemption using GCS client node information
- Adds death info handling to the NodeInfoAccessor for tracking preemption reasons
- Updates TaskManager constructor to include GCS client dependency for node status queries
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ray/core_worker/task_manager.cc | Core retry logic to check node preemption status and bypass retry counter |
| src/ray/core_worker/task_manager.h | Constructor signature update to accept GCS client |
| src/ray/core_worker/core_worker.cc | Passes GCS client to TaskManager constructor |
| src/ray/gcs/gcs_client/accessor.cc | Copies death info when handling dead node notifications |
| src/ray/gcs/gcs_client/test/accessor_test.cc | Test for death info handling in NodeInfoAccessor |
| src/ray/core_worker/test/task_manager_test.cc | Unit tests for preemption retry behavior |
| python/ray/tests/test_draining.py | Integration test for task retry behavior during node draining |
Comments suppressed due to low confidence (1)
python/ray/tests/test_draining.py:460
- The test only covers the case where max_retries=1. Consider adding test cases with max_retries=0 and max_retries>1 to ensure the preemption retry logic works correctly across different retry configurations.
@ray.remote(max_retries=1, resources={"worker": 1})
65da5ac to
17e7736
Compare
17e7736 to
0e8378c
Compare
|
Hi @edoakes, I've resolved all merge conflicts and all tests have passed successfully. Could you please take another look? Thanks! |
…ject#54182) We decided that task retries due to node preemption should not count toward `max_retries`. --------- Signed-off-by: Rueian <[email protected]> Signed-off-by: Rueian <[email protected]> Co-authored-by: Rueian <[email protected]> Co-authored-by: Rueian <[email protected]> Signed-off-by: avigyabb <[email protected]>
We decided that task retries due to node preemption should not count toward `max_retries`. --------- Signed-off-by: Rueian <[email protected]> Signed-off-by: Rueian <[email protected]> Co-authored-by: Rueian <[email protected]> Co-authored-by: Rueian <[email protected]> Signed-off-by: Kamil Kaczmarek <[email protected]>
…ject#54182) We decided that task retries due to node preemption should not count toward `max_retries`. --------- Signed-off-by: Rueian <[email protected]> Signed-off-by: Rueian <[email protected]> Co-authored-by: Rueian <[email protected]> Co-authored-by: Rueian <[email protected]> Signed-off-by: Michael Acar <[email protected]>
…ject#54182) We decided that task retries due to node preemption should not count toward `max_retries`. --------- Signed-off-by: Rueian <[email protected]> Signed-off-by: Rueian <[email protected]> Co-authored-by: Rueian <[email protected]> Co-authored-by: Rueian <[email protected]> Signed-off-by: jugalshah291 <[email protected]>
We decided that task retries due to node preemption should not count toward `max_retries`. --------- Signed-off-by: Rueian <[email protected]> Signed-off-by: Rueian <[email protected]> Co-authored-by: Rueian <[email protected]> Co-authored-by: Rueian <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
… passed (#68457) ## Why are these changes needed? Closes #68304. On SIGTERM, `ray start --block` drains the local node with `DRAIN_NODE_REASON_PREEMPTION` and a deadline of `now + RAY_GRACEFUL_SHUTDOWN_DRAIN_TIMEOUT_S` (#64454). If the node is still busy when that time is up, `_drain_node_before_shutdown` returns and `kill_all_processes()` sends SIGTERM to the raylet right away. The raylet records the node as preempted only if the drain deadline is strictly in the past when it receives SIGTERM (`deadline_timestamp_ms < now`, `src/ray/raylet/main.cc`). The poll loop ends on the monotonic clock at about the same instant as the wall-clock deadline, so the raylet often sees `deadline == now` and records `EXPECTED_TERMINATION`. Owners then count the failed tasks against `max_retries` (`TaskManager` only skips the count for `AUTOSCALER_DRAIN_PREEMPTED`), so #54182 does not take effect for busy nodes. This PR keeps the raylet's rule as it is and fixes the caller: after the poll loop times out, it sleeps until wall-clock time is 10 ms past the deadline it sent, then kills local processes. The extra wait is capped at 1 s so that a backwards wall-clock jump cannot stall teardown. Nothing changes when the raylet exits on its own after draining, because in that case it takes the death reason from the drain request. ## Related issue number Closes #68304 ## Testing Unit tests (`python/ray/tests/test_draining.py`): - `_run_drain` now fakes the wall clock in lockstep with the monotonic clock. - `test_drain_timeout_kills_only_after_deadline` (16 cases over timeout and poll interval) checks that a timed-out drain ends strictly after the deadline sent to the GCS, by at most the margin. Without the fix in `node.py`, all 16 cases fail. - `test_drain_early_exit_does_not_wait_for_deadline` checks that an early exit does not wait. - `test_wait_until_past_drain_deadline` covers the helper: before, at and after the deadline, and a backwards clock jump. ``` python -m pytest python/ray/tests/test_draining.py -k "drain_ or sigterm or wait_until" 35 passed, 10 deselected ``` End to end on Kubernetes (minikube, KubeRay v1.6.2, `rayproject/ray:2.60.0`, `RAY_GRACEFUL_SHUTDOWN_DRAIN_TIMEOUT_S=3`, grace period 10 s). A task pinned to each worker keeps the node busy, the worker pods are deleted, and the head reads each node's death reason from the GCS. Both runs mount `node.py` from a ConfigMap: the stock 2.60.0 file (same sha256 as the image) or the same file with this patch applied (the hunk applies to 2.60.0 unchanged). Each run deletes 2 busy workers per round, for 15 rounds (30 nodes): | `node.py` | `AUTOSCALER_DRAIN_PREEMPTED` | `EXPECTED_TERMINATION` | |---|---|---| | stock 2.60.0 | 24 | 6 | | with this PR | 30 | 0 | With the stock file, 6 of 30 busy nodes are recorded as `EXPECTED_TERMINATION` ("received SIGTERM"). With the patch, all 30 are recorded as preempted. ## Duplicate check - No open or closed PR references #68304 or touches `_drain_node_before_shutdown` apart from #64454, which introduced it. - @MaiAditya offered to work on this in the issue. I replied there before opening this PR, and the PR follows the approach they outlined (option 1). - Option 3 from the issue (treating any `PREEMPTION` drain as preempted in the raylet) is intentionally left out; it overlaps with #66901. ## AI assistance I used an AI coding assistant (Claude Code) to draft the change, the tests and this description. I reviewed every changed line and ran the tests and the Kubernetes check above myself. ## Checks - [x] I've signed off every commit (by using the -s flag, i.e., `git commit -s`) in this PR. - [x] I've run `black` and `ruff` (pre-commit versions) on the changed files. - [x] Unit tests - [ ] Release tests - [ ] This PR is not tested :( 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: zhangsikai123 <[email protected]>
Why are these changes needed?
We decided that task retries due to node preemption should not count toward
max_retries.Related issue number
N/A
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.