mirror of
https://github.com/wassname/ray.git
synced 2026-06-29 06:49:48 +08:00
[Dashboard] Remove token authentication from dashboard (#5888)
This commit is contained in:
committed by
Philipp Moritz
parent
26a724c5e6
commit
235dec8aa3
+20
-10
@@ -2,7 +2,6 @@ from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import binascii
|
||||
import collections
|
||||
import json
|
||||
import logging
|
||||
@@ -13,6 +12,7 @@ import resource
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
import time
|
||||
import redis
|
||||
|
||||
@@ -545,7 +545,7 @@ def check_version_info(redis_client):
|
||||
true_version_info = tuple(json.loads(ray.utils.decode(redis_reply)))
|
||||
version_info = _compute_version_info()
|
||||
if version_info != true_version_info:
|
||||
node_ip_address = ray.services.get_node_ip_address()
|
||||
node_ip_address = get_node_ip_address()
|
||||
error_message = ("Version mismatch: The cluster was started with:\n"
|
||||
" Ray: " + true_version_info[0] + "\n"
|
||||
" Python: " + true_version_info[1] + "\n"
|
||||
@@ -972,7 +972,8 @@ def start_reporter(redis_address,
|
||||
return process_info
|
||||
|
||||
|
||||
def start_dashboard(redis_address,
|
||||
def start_dashboard(host,
|
||||
redis_address,
|
||||
temp_dir,
|
||||
stdout_file=None,
|
||||
stderr_file=None,
|
||||
@@ -980,6 +981,7 @@ def start_dashboard(redis_address,
|
||||
"""Start a dashboard process.
|
||||
|
||||
Args:
|
||||
host (str): The host to bind the dashboard web server to.
|
||||
redis_address (str): The address of the Redis instance.
|
||||
temp_dir (str): The temporary directory used for log files and
|
||||
information for this Ray session.
|
||||
@@ -1002,17 +1004,15 @@ def start_dashboard(redis_address,
|
||||
except socket.error:
|
||||
port += 1
|
||||
|
||||
token = ray.utils.decode(binascii.hexlify(os.urandom(24)))
|
||||
|
||||
dashboard_filepath = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "dashboard/dashboard.py")
|
||||
command = [
|
||||
sys.executable,
|
||||
"-u",
|
||||
dashboard_filepath,
|
||||
"--host={}".format(host),
|
||||
"--port={}".format(port),
|
||||
"--redis-address={}".format(redis_address),
|
||||
"--http-port={}".format(port),
|
||||
"--token={}".format(token),
|
||||
"--temp-dir={}".format(temp_dir),
|
||||
]
|
||||
if redis_password:
|
||||
@@ -1034,10 +1034,20 @@ def start_dashboard(redis_address,
|
||||
ray_constants.PROCESS_TYPE_DASHBOARD,
|
||||
stdout_file=stdout_file,
|
||||
stderr_file=stderr_file)
|
||||
dashboard_url = "http://{}:{}/?token={}".format(
|
||||
ray.services.get_node_ip_address(), port, token)
|
||||
dashboard_url = "http://{}:{}".format(
|
||||
host if host == "127.0.0.1" else get_node_ip_address(), port)
|
||||
print("\n" + "=" * 70)
|
||||
print("View the dashboard at {}".format(dashboard_url))
|
||||
print("View the dashboard at {}.".format(dashboard_url))
|
||||
if host == "127.0.0.1":
|
||||
note = (
|
||||
"Note: If Ray is running on a remote node, you will need to set "
|
||||
"up an SSH tunnel with local port forwarding in order to access "
|
||||
"the dashboard in your browser, e.g. by running "
|
||||
"'ssh -L {}:{}:{} <username>@<host>'. Alternatively, you can set "
|
||||
"webui_host=\"0.0.0.0\" in the call to ray.init() to allow direct "
|
||||
"access from external machines.")
|
||||
note = note.format(port, host, port)
|
||||
print("\n".join(textwrap.wrap(note, width=70)))
|
||||
print("=" * 70 + "\n")
|
||||
return dashboard_url, process_info
|
||||
|
||||
|
||||
Reference in New Issue
Block a user