Commit 5bff52a
[core] Configure an interceptor to pass auth token in python direct g… (#58395)
## Description
there are places in the python code where we use the raw grpc library to
make grpc calls (eg: pub-sub, some calls to gcs etc). In the long term
we want to fully deprecate grpc library usage in our python code base
but as that can take more effort and testing, in this pr I am
introducing an interceptor to add auth headers (this will take effect
for all grpc calls made from python).
## Testing
### case 1: submitting a job using CLI
```
export RAY_auth_mode="token"
export RAY_AUTH_TOKEN="abcdef1234567890abcdef123456789"
ray start --head
ray job submit -- echo "hi"
```
output
```
ray job submit -- echo "hi"
2025-11-04 06:28:09,122 - INFO - NumExpr defaulting to 4 threads.
Job submission server address: http://127.0.0.1:8265
-------------------------------------------------------
Job 'raysubmit_1EV8q86uKM24nHmH' submitted successfully
-------------------------------------------------------
Next steps
Query the logs of the job:
ray job logs raysubmit_1EV8q86uKM24nHmH
Query the status of the job:
ray job status raysubmit_1EV8q86uKM24nHmH
Request the job to be stopped:
ray job stop raysubmit_1EV8q86uKM24nHmH
Tailing logs until the job exits (disable with --no-wait):
2025-11-04 06:28:10,363 INFO job_manager.py:568 -- Runtime env is setting up.
hi
Running entrypoint for job raysubmit_1EV8q86uKM24nHmH: echo hi
------------------------------------------
Job 'raysubmit_1EV8q86uKM24nHmH' succeeded
------------------------------------------
```
### case 2: submitting a job with actors and tasks and verifying on
dashboard
test.py
```python
import time
import ray
from ray._raylet import Config
ray.init()
@ray.remote
def print_hi():
print("Hi")
time.sleep(2)
@ray.remote
class SimpleActor:
def __init__(self):
self.value = 0
def increment(self):
self.value += 1
return self.value
actor = SimpleActor.remote()
result = ray.get(actor.increment.remote())
for i in range(100):
ray.get(print_hi.remote())
time.sleep(20)
ray.shutdown()
```
```
export RAY_auth_mode="token"
export RAY_AUTH_TOKEN="abcdef1234567890abcdef123456789"
python test.py
```
### dashboard screenshots:
#### promts user to input the token
<img width="1720" height="1073" alt="image"
src="https://github.com/user-attachments/assets/008829d8-51b6-445a-b135-5f76b6ccf292"
/>
### on passing the right token:
overview page
<img width="1720" height="1073" alt="image"
src="https://github.com/user-attachments/assets/cece0da7-0edd-4438-9d60-776526b49762"
/>
job page: tasks are listed
<img width="1720" height="1073" alt="image"
src="https://github.com/user-attachments/assets/b98eb1d9-cacc-45ea-b0e2-07ce8922202a"
/>
task page
<img width="1720" height="1073" alt="image"
src="https://github.com/user-attachments/assets/09ff38e1-e151-4e34-8651-d206eb8b5136"
/>
actors page
<img width="1720" height="1073" alt="image"
src="https://github.com/user-attachments/assets/10a30b3d-3f7e-4f3d-b669-962056579459"
/>
specific actor page
<img width="1720" height="1073" alt="image"
src="https://github.com/user-attachments/assets/ab1915bd-3d1b-4813-8101-a219432a55c0"
/>
---------
Signed-off-by: sampan <[email protected]>
Co-authored-by: sampan <[email protected]>1 parent 71c7bd0 commit 5bff52a
File tree
5 files changed
+213
-5
lines changed- python/ray
- _private
- authentication
- tests
5 files changed
+213
-5
lines changedLines changed: 122 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1026 | 1026 | | |
1027 | 1027 | | |
1028 | 1028 | | |
| 1029 | + | |
1029 | 1030 | | |
1030 | 1031 | | |
1031 | 1032 | | |
| |||
1040 | 1041 | | |
1041 | 1042 | | |
1042 | 1043 | | |
1043 | | - | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
1044 | 1060 | | |
1045 | 1061 | | |
1046 | 1062 | | |
1047 | 1063 | | |
1048 | 1064 | | |
1049 | 1065 | | |
1050 | | - | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
1051 | 1077 | | |
1052 | | - | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
1053 | 1081 | | |
1054 | 1082 | | |
1055 | 1083 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
345 | 401 | | |
346 | 402 | | |
0 commit comments