Skip to content

[core] Detach the driver when a rejected local:// URI leaves it connected - #66302

Merged
rueian merged 3 commits into
ray-project:masterfrom
YashwanthRanjanSingaravel:fix/local-working-dir-client-disconnect
Sep 28, 2026
Merged

rueian merged 3 commits into
ray-project:masterfrom
YashwanthRanjanSingaravel:fix/local-working-dir-client-disconnect

Conversation

@YashwanthRanjanSingaravel

Copy link
Copy Markdown
Contributor

Description

  • TestLocalWorkingDir::test_relative_path_rejected_on_the_client passes, then errors at teardown.
  • Only in //python/ray/tests:test_runtime_env_working_dir_client_mode, on every Windows postmerge run.
  • The teardown error is:
    • ValueError: Removing a node that is connected to this Ray client is not allowed
    • raised by Cluster.remove_node at cluster_utils.py:305.
  • connect sets worker.node before it validates the runtime_env.
    • worker.py:2649 reads worker.node.get_runtime_env_dir_path(), then calls upload_working_dir_if_needed.
    • parse_uri rejects the relative local:// path there, so ray.init raises after connecting.
    • The driver is left attached to the head node.
  • Under RAY_CLIENT_MODE=1 the fixture's own ray.shutdown is redirected to the Ray Client.
    • It never reaches disconnect, which is what clears worker.node at worker.py:2827.
    • That is why the plain target passes and only the client mode target fails.
  • Introduced by [core] Add local:// runtime_env URIs for code already in node #65245.

Changes

  • test_runtime_env_working_dir.py: detach the driver after the expected ValueError.
  • The ray.shutdown runs inside disable_client_hook so it reaches the real one in both modes.
  • disable_client_hook restores the previous hook state on exit; test_client.py already uses it.

Tests

  • No new test. The existing test is the regression test, and it is the one erroring today.
  • Verified the bypass with RAY_CLIENT_MODE=1: client_mode_should_convert() is True normally,
    False inside disable_client_hook(), and True again afterwards.
  • The client side rejection itself stays covered by unit/test_runtime_env_working_dir.py.

@YashwanthRanjanSingaravel YashwanthRanjanSingaravel added the go add ONLY when ready to merge, run all tests label Sep 18, 2026
@YashwanthRanjanSingaravel
YashwanthRanjanSingaravel marked this pull request as ready for review September 18, 2026 22:15
@YashwanthRanjanSingaravel
YashwanthRanjanSingaravel requested a review from a team as a code owner September 18, 2026 22:15

@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 adds a cleanup step using disable_client_hook and ray.shutdown() in test_relative_path_rejected_on_the_client to detach the driver from the head node after a failed ray.init call. The review feedback correctly points out that if the test fails before reaching this cleanup, the shutdown will be skipped, which can mask the original failure during cluster teardown. It is recommended to wrap the cleanup in a try...finally block or register a cleanup finalizer to ensure it always runs.

@martinlhw martinlhw 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.

LGTM!

@rueian
rueian merged commit b38ed8b into ray-project:master Sep 28, 2026
6 checks passed
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…cted (ray-project#66302)

## Description

- `TestLocalWorkingDir::test_relative_path_rejected_on_the_client`
passes, then errors at teardown.
- Only in `//python/ray/tests:test_runtime_env_working_dir_client_mode`,
on every Windows postmerge run.
- The teardown error is:
- `ValueError: Removing a node that is connected to this Ray client is
not allowed`
  - raised by `Cluster.remove_node` at `cluster_utils.py:305`.
- `connect` sets `worker.node` before it validates the runtime_env.
- `worker.py:2649` reads `worker.node.get_runtime_env_dir_path()`, then
calls `upload_working_dir_if_needed`.
- `parse_uri` rejects the relative `local://` path there, so `ray.init`
raises after connecting.
  - The driver is left attached to the head node.
- Under `RAY_CLIENT_MODE=1` the fixture's own `ray.shutdown` is
redirected to the Ray Client.
- It never reaches `disconnect`, which is what clears `worker.node` at
`worker.py:2827`.
- That is why the plain target passes and only the client mode target
fails.
- Introduced by ray-project#65245.

## Changes

- `test_runtime_env_working_dir.py`: detach the driver after the
expected `ValueError`.
- The `ray.shutdown` runs inside `disable_client_hook` so it reaches the
real one in both modes.
- `disable_client_hook` restores the previous hook state on exit;
`test_client.py` already uses it.

## Tests

- No new test. The existing test is the regression test, and it is the
one erroring today.
- Verified the bypass with `RAY_CLIENT_MODE=1`:
`client_mode_should_convert()` is `True` normally,
  `False` inside `disable_client_hook()`, and `True` again afterwards.
- The client side rejection itself stays covered by
`unit/test_runtime_env_working_dir.py`.

---------

Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests windows

Development

Successfully merging this pull request may close these issues.

3 participants