Repository navigation
[Core/Auth] Make token auth the default for all clusters - #67523
elliot-barn merged 10 commits into
Conversation
Signed-off-by: Chi-Sheng Liu <[email protected]>
Signed-off-by: Chi-Sheng Liu <[email protected]>
… default Signed-off-by: Chi-Sheng Liu <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request enables token authentication by default in Ray by changing the default AUTH_MODE to "token" and removing the now-redundant auto-enable token authentication helper functions. It updates various tests, Bazel build targets, and scripts to ensure that authentication tokens are correctly generated and propagated. The review comments provide valuable feedback: one suggests prepending http:// to the Cypress request URL in the dashboard tests to prevent routing issues, and another recommends using python3 instead of python in run_ui_tests.sh for better portability.
…7055-default-all-clusters Signed-off-by: Chi-Sheng Liu <[email protected]> # Conflicts: # python/ray/serve/tests/test_ray_client.py
Signed-off-by: Chi-Sheng Liu <[email protected]>
|
AI reviews:
|
Signed-off-by: Chi-Sheng Liu <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Reviewed by Cursor Bugbot for commit 8c4c937. Configure here.
… start head rejects a tokenless driver Signed-off-by: Chi-Sheng Liu <[email protected]>
|
@rueian 1 and 3 are now listed as breaking changes. 2: |
Signed-off-by: Chi-Sheng Liu <[email protected]>
…om the C++ test token genrule Signed-off-by: Chi-Sheng Liu <[email protected]>
… sends the token Signed-off-by: Chi-Sheng Liu <[email protected]>
|
I am preparing a draft alternative for the existing head/worker mismatch, and documenting the difference here before opening it, per AGENTS.md. A persisted The alternative keeps the existing The draft will include regression tests for existing token sources, head/worker consistency, all |
… clusters (#67724) ## Description Updates the docs for #67523, which makes token authentication the default for every cluster: - `ray-security/token-auth.md` and `core/internals/token-authentication.md`: who creates the token, how nodes and clients get it, and the `RAY_AUTH_MODE=disabled` opt-out. - `cluster/metrics.md`: scraping with the token, and `RAY_AUTH_SKIP_METRICS`. - VM, on-prem, Slurm, YARN, `starting-ray.md` and Serve `deploy-vm.md`: create the token before `ray start --head`. The cluster YAML reference documents the new `auth_mode` key. - `conf.py`: removes the token-auth banner. The KubeRay guide is left to #67057. ## Related issues Closes #67056 --------- Signed-off-by: Chi-Sheng Liu <[email protected]>
## Why `test_advanced_9.py::test_redis_wrong_password` has failed both attempts in every postmerge run of `:ray: core: redis tests` since build 20681 (2026-11-03), 20 of 20 runs (e.g. 20894). It passed in every run before that. The test runs `ray start --head --redis-password=1234` and expects the Redis auth error. Since #67523 made token auth the default, `ray start --head` exits first because no auth token exists: ``` PANIC scripts.py:1081 -- Token authentication is enabled but no authentication token was found. ``` #67523 added the `create_auth_token` fixture to the sibling `test_redis_not_available` but not to this test. This test only runs in the redis job, which premerge runs only when `src/ray/gcs/store_client/` changes, so it never ran on that PR. In every other job the test skips itself ("Only valid in redis env"), so the `test_advanced_9` target looks flaky across jobs. It fails every time in the redis job. ## Change Add `create_auth_token` to `test_redis_wrong_password`, the same as `test_redis_not_available`. The `ray start --head` subprocess then has a token and fails on the wrong Redis password, as intended. ## Duplicate check No open or closed issue/PR covers `test_redis_wrong_password` (searched by test name and "redis wrong password auth token"). ## Testing - `pre-commit run --files python/ray/tests/test_advanced_9.py`: all hooks pass. - Not run locally (needs `TEST_EXTERNAL_REDIS=1` and a Redis server). Opening as draft until the redis tests job passes on this branch; premerge won't run it automatically because this PR doesn't touch `src/ray/gcs/store_client/`. AI assistance (Claude Code) was used for the investigation and the change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Kartica Modi <[email protected]>
…ad it (#68262) ## Description Since the Bazel 8 bump (#66483), Windows C++ tests that read the token from the `auth_token_file` genrule (#67523) crash in setup with `RAY_AUTH_TOKEN_PATH is set but file cannot be opened or is empty`. The genrule's output comes from the remote cache and is never downloaded, so the test's runfiles link points at a missing file. Tagging the genrule `no-remote` makes every build generate it locally. | Targets | Before | After | |---|---|---| | `open_telemetry_metric_recorder_test`, `object_manager_test`, `node_manager_test`, `grpc_server_client_test`, `core_worker_test`, `gcs_client_test` | failed 2/2, [postmerge 21056](https://buildkite.com/ray-project/postmerge/builds/21056) | passed, [premerge 77225](https://buildkite.com/ray-project/premerge/builds/77225) | | `global_state_accessor_test` | failed, [premerge 77216](https://buildkite.com/ray-project/premerge/builds/77216) | passed, [premerge 77227](https://buildkite.com/ray-project/premerge/builds/77227) | ## Related issues Related to #67047 Signed-off-by: Chi-Sheng Liu <[email protected]>
…de and a readable token ray up ships an auth token by default since #67523. A cluster YAML whose image holds an older Ray (such as rayproject/ray:latest before 2.61 is published) then gets a head that requires the token, because Ray < 2.61's ray start --head turns on token mode when it finds a token file, while workers and clients in the containers default to disabled and send none. This fails every cluster-launcher release test that uses the latest image. - Set RAY_AUTH_MODE to the YAML's auth_mode (token by default) in every container through the Docker run options, which the head's autoscaler also uses for worker containers. - The token is bind mounted with the host SSH user's UID, which can differ from the container user's, as on GCP common-cpu images, where the head's autoscaler crashes with PermissionError reading it. Take ownership with sudo chown when the container user can't read it, as for the bootstrap files. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: davik <[email protected]>
## Description The [post merge kuberay tests](https://buildkite.com/ray-project/postmerge/builds/21065#01a1ea91-4a88-4d8e-862f-bc611fa93702) are currently failing due to timeout. Upon, running the tests on master locally via a kind cluster, we see the kuberay operator failing to bring pods up due to: ``` PANIC scripts.py:1081 -- Token authentication is enabled but no authentication token was found. Run `ray get-auth-token --generate` to create one, then put that token on every node of the cluster before starting it. ``` This was because #67523 enabled token authentication across the cluster by default. This meant that simply starting the cluster with `ray start --head` without a token present on the cluster will lead to the failure we see above. Instead, the kuberay operator must create the token and pass it to the cluster. This PR adds this mechanism to the kuberay post merge tests. Once kuberay side comes up with a standard way of handling this in future versions, we can get rid of this fix: kuberay-project/kuberay#5496. ## Related issues ## Additional information Kuberay test postmerge run: https://buildkite.com/ray-project/postmerge/builds/21179 Signed-off-by: davik <[email protected]>
…ing token" (#68466) onto releases/2.61.0 (#68473) ## Description Cherry-pick of #68466 (`65a0a1bd40`) onto `releases/2.61.0`. The KubeRay chaos tests time out because token authentication is now on by default (#67523) and the cluster starts without a token; this passes one explicitly. Clean pick. The two touched files (`ci/k8s/run-chaos-test.sh`, `python/ray/tests/chaos/prepare_env.sh`) are identical to master after the pick. ## Testing Not run locally. The KubeRay tests run in the release branch's postmerge build. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: davik <[email protected]> Signed-off-by: elliot-barn <[email protected]> Co-authored-by: Kunchen (David) Dai <[email protected]>
## Why are these changes needed? Ray token auth is enabled by default in Ray 2.61 (ray-project/ray#67523). KubeRay assumed token auth is disabled by default, so no `RAY_AUTH_MODE` is added when `authOptions` is not set. Users get an auth error when they use Ray 2.61 with the current KubeRay version. This PR makes the following changes: 1. Always set `RAY_AUTH_MODE` on every Ray container. Set to `token` when `authOptions.mode` is `token`, otherwise `disabled`. A user-provided `RAY_AUTH_MODE` is never overridden. 2. Add comments in `config/prometheus/podMonitor.yaml` on how to configure Prometheus for a RayCluster with token auth enabled, since Ray 2.61 also requires the token on the metrics endpoints (ray-project/ray#67119). ## Related issue number Related to ray-project/ray#67057 ## Labels <!-- Please add the appropriate labels to this PR. --> - [x] If this PR has user-facing changes that require documentation updates at release time, I have added the `doc-updates-required` label. - doc PR: ray-project/ray#67897 - [ ] If this PR contains breaking changes, I have added the `breaking-change` label. ## AI assistance Yes, AI assisted coding and test, reviewed by me and all manual tests run by me manually ## Checks - [x] I've made sure the tests are passing. - Testing Strategy - [x] Unit tests - [x] Manual tests - [ ] This PR is not tested :( <!-- If you selected "Manual tests" above, please fill in the section below. Otherwise you can remove it. --> ### Manual test instructions Test results: #5496 (comment) Signed-off-by: machichima <[email protected]>

Description
AUTH_MODEnow defaults totoken, so every cluster runs with token auth unlessRAY_AUTH_MODE=disabledis set. Until now only a local cluster turned auth on, and only through special cases that read whether a token already existed. With token as the default those special cases do nothing, so this PR deletes them:The old warnings fired only when
RAY_AUTH_MODEwas unset, which no longer means auth is off. They are replaced by one warning fromNode(head=True)when the head starts withRAY_AUTH_MODE=disabled. Worker nodes, drivers and clients don't warn.RAY_AUTH_MODEnow accepts onlytokenanddisabled, case-insensitively. Any other value, including an empty one, used to turn auth off silently. With token as the default, a typo would start an unauthenticated cluster without warning. Such a value now fails at startup withInvalid RAY_AUTH_MODE '<value>': set it to 'token' or 'disabled'.Before, on a fresh HOME, the documented local flow failed at the second node:
ray.init(address="127.0.0.1:6379")failed with the same error, since only an address ofNoneor"auto"turned auth on. After this PR both join with token auth on, with no extra steps.ray upnow reads a top-levelauth_modekey (tokenordisabled) in the cluster YAML instead of theRAY_AUTH_MODEof the shell that runs it. It ships the token unless the key isdisabled. When the key is set, every node's start commands run withRAY_AUTH_MODEset to that value, including workers the autoscaler adds later.The behavior change is in
ray_config_def.h,authentication_mode.cc,rpc_token_authentication.pxi,authentication_token_setup.py,worker.py,scripts.py,node.py,install_and_start_prometheus.py, theray uppath (commands.py,updater.py,autoscaler.py,ray_installer.py,ray-schema.json) and the removed C++, JNI and Java helpers. The other files are test, test-build or comment changes.Test fixtures:
python/ray/tests/conftest.pyused to turn auth off by removingRAY_AUTH_MODE. It now setsRAY_AUTH_MODE=disabled.ray start --headnever creates a token, and neither do tests that run Ray's servers and clients with no driver. Python tests like these, Serve's included, use the newcreate_auth_tokenfixture.call_ray_start_contextand module-scoped fixtures usehold_test_auth_mode(), which does the same. Both create the token first and keep it until the test or head is done. The per-test cleanup deletes~/.ray/auth_tokenafter every test, which would break a head shared across a test module.auth_token = Trueonray_cc_test. That reads a random token generated at build time by the//src/ray/common:auth_token_filegenrule (moved fromcpp/BUILD.bazel), so no token is written in source and every other test still exercises token creation.RAY_AUTH_TOKEN, generated at run time. The UI test logs in throughPOST /api/authenticatebefore opening the dashboard.get_load_metrics_report,test_serve_ha.pyandtest_cli_3.pycall the dashboard directly and now send the token.test_grpc_client_credentials.pyacceptstry_to_connect. In token mode the client wraps its channel withgrpc.intercept_channel, which passes that keyword tosubscribe.torch_tune_serve_test.pyrelease test setsRAY_AUTH_TOKENbeforeray start --head.release/ray_release/byod/byod.Dockerfileanddocker/ray-torch/Dockerfile) setRAY_AUTH_MODE=disabled. Anyscale's agent on the head node calls the Ray dashboard API without a token, so the job is never submitted when auth is on. [Core/Auth] Verify Anyscale platform clusters work with token auth on by default #67058 tracks turning auth back on.authOptions: {mode: token}and raiserayVersionfrom2.46.0to2.52.0, the lowest version KubeRay v1.7.0 accepts withauthOptions. [KubeRay][Core/Auth] Verify KubeRay clusters work with token auth on by default #67057 tracks whether KubeRay users should need this.ray uptests check thatdisabledin theauth_modekey ships no token even from a shell withRAY_AUTH_MODE=token, and that a missing key ships it even from a shell withRAY_AUTH_MODE=disabled.Related issues
Closes #67055
Additional information
This changes the default for every cluster, so it breaks setups that silently relied on auth being off:
ray start --headwith no token now fails at once and says to runray get-auth-token --generate.RAY_AUTH_MODE=disabled.ray metrics launch-prometheuswith no token now fails instead of writing a config without auth.ray.util.spark.setup_ray_cluster) can't start a cluster, because its head runsray start --headand nothing inray.util.sparkcreates or ships a token. This PR doesn't fix that.RAY_AUTH_SKIP_METRICS=1on every node to keep the metrics endpoints open.ray upcluster out, setauth_mode: disabledin the cluster YAML. TheRAY_AUTH_MODEof the shell runningray upno longer decides whether the token ships.RAY_AUTH_MODEother thantokenordisabled, such asnone,offor an empty value, now fails at startup instead of turning auth off.aws_cluster_launcher_minimalfails on this PR's release run and should pass once the nightly wheel includes this change. Its nodes install the latest nightly wheel, so this PR'sray upships a token to an older Ray. That older head turns auth on when the token file exists, but a driver that passes an explicit address stays in disabled mode and is rejected.This needs a release note. The docs update in #67056 has to ship in the same release. #67057 and #67058 check that KubeRay and Anyscale clusters work with this default.
The test fixes above come from premerge runs on this PR. Each failure got its own fix:
create_auth_token(Python),auth_token = True(C++), sending the token, orenable_token_auth=FalseonCluster(). CI config doesn't setRAY_AUTH_MODE=disabledglobally.