mirror of
https://github.com/wassname/ray.git
synced 2026-07-14 11:17:54 +08:00
Forward multiple ports for autoscaler (#5893)
This commit is contained in:
@@ -347,7 +347,7 @@ def exec_cluster(config_file, cmd, docker, screen, tmux, stop, start,
|
||||
stop: whether to stop the cluster after command run
|
||||
start: whether to start the cluster if it isn't up
|
||||
override_cluster_name: set the name of the cluster
|
||||
port_forward: port to forward
|
||||
port_forward (int or list[int]): port(s) to forward
|
||||
"""
|
||||
assert not (screen and tmux), "Can specify only one of `screen` or `tmux`."
|
||||
|
||||
|
||||
@@ -57,10 +57,12 @@ class KubernetesCommandRunner(object):
|
||||
logger.info(self.log_prefix + "Running {}...".format(cmd))
|
||||
|
||||
if port_forward:
|
||||
if not isinstance(port_forward, list):
|
||||
port_forward = [port_forward]
|
||||
port_forward_cmd = self.kubectl + [
|
||||
"port-forward", self.node_id,
|
||||
str(port_forward)
|
||||
]
|
||||
"port-forward",
|
||||
self.node_id,
|
||||
] + [str(fwd) for fwd in port_forward]
|
||||
port_forward_process = subprocess.Popen(port_forward_cmd)
|
||||
# Give port-forward a grace period to run and print output before
|
||||
# running the actual command. This is a little ugly, but it should
|
||||
@@ -242,7 +244,10 @@ class SSHCommandRunner(object):
|
||||
ssh.append("-tt")
|
||||
|
||||
if port_forward:
|
||||
ssh += ["-L", "{}:localhost:{}".format(port_forward, port_forward)]
|
||||
if not isinstance(port_forward, list):
|
||||
port_forward = [port_forward]
|
||||
for fwd in port_forward:
|
||||
ssh += ["-L", "{}:localhost:{}".format(fwd, fwd)]
|
||||
|
||||
final_cmd = ssh + self.get_default_ssh_options(timeout) + [
|
||||
"{}@{}".format(self.ssh_user, self.ssh_ip)
|
||||
|
||||
Reference in New Issue
Block a user