mirror of
https://github.com/vale981/ray
synced 2025-03-06 02:21:39 -05:00
[autoscaler] Command runner interactivity (#7198)
This commit is contained in:
parent
7bfce5c027
commit
2c485a2598
2 changed files with 7 additions and 11 deletions
|
@ -471,7 +471,6 @@ def _exec(updater, cmd, screen, tmux, port_forward=None, with_output=False):
|
||||||
cmd = " ".join(cmd)
|
cmd = " ".join(cmd)
|
||||||
return updater.cmd_runner.run(
|
return updater.cmd_runner.run(
|
||||||
cmd,
|
cmd,
|
||||||
allocate_tty=True,
|
|
||||||
exit_on_fail=True,
|
exit_on_fail=True,
|
||||||
port_forward=port_forward,
|
port_forward=port_forward,
|
||||||
with_output=with_output)
|
with_output=with_output)
|
||||||
|
|
|
@ -47,7 +47,6 @@ class KubernetesCommandRunner:
|
||||||
def run(self,
|
def run(self,
|
||||||
cmd=None,
|
cmd=None,
|
||||||
timeout=120,
|
timeout=120,
|
||||||
allocate_tty=False,
|
|
||||||
exit_on_fail=False,
|
exit_on_fail=False,
|
||||||
port_forward=None,
|
port_forward=None,
|
||||||
with_output=False):
|
with_output=False):
|
||||||
|
@ -77,12 +76,12 @@ class KubernetesCommandRunner:
|
||||||
raise Exception(exception_str)
|
raise Exception(exception_str)
|
||||||
else:
|
else:
|
||||||
logger.info(self.log_prefix + "Running {}...".format(cmd))
|
logger.info(self.log_prefix + "Running {}...".format(cmd))
|
||||||
final_cmd = self.kubectl + [
|
final_cmd = self.kubectl + ["exec", "-it"]
|
||||||
"exec",
|
final_cmd += [
|
||||||
"-it" if allocate_tty else "-i",
|
|
||||||
self.node_id,
|
self.node_id,
|
||||||
"--",
|
"--",
|
||||||
] + with_interactive(cmd)
|
]
|
||||||
|
final_cmd += with_interactive(cmd)
|
||||||
try:
|
try:
|
||||||
if with_output:
|
if with_output:
|
||||||
return self.process_runner.check_output(
|
return self.process_runner.check_output(
|
||||||
|
@ -230,16 +229,13 @@ class SSHCommandRunner:
|
||||||
def run(self,
|
def run(self,
|
||||||
cmd,
|
cmd,
|
||||||
timeout=120,
|
timeout=120,
|
||||||
allocate_tty=False,
|
|
||||||
exit_on_fail=False,
|
exit_on_fail=False,
|
||||||
port_forward=None,
|
port_forward=None,
|
||||||
with_output=False):
|
with_output=False):
|
||||||
|
|
||||||
self.set_ssh_ip_if_required()
|
self.set_ssh_ip_if_required()
|
||||||
|
|
||||||
ssh = ["ssh"]
|
ssh = ["ssh", "-tt"]
|
||||||
if allocate_tty:
|
|
||||||
ssh.append("-tt")
|
|
||||||
|
|
||||||
if port_forward:
|
if port_forward:
|
||||||
if not isinstance(port_forward, list):
|
if not isinstance(port_forward, list):
|
||||||
|
@ -260,7 +256,8 @@ class SSHCommandRunner:
|
||||||
else:
|
else:
|
||||||
# We do this because `-o ControlMaster` causes the `-N` flag to
|
# We do this because `-o ControlMaster` causes the `-N` flag to
|
||||||
# still create an interactive shell in some ssh versions.
|
# still create an interactive shell in some ssh versions.
|
||||||
final_cmd.append("while true; do sleep 86400; done")
|
final_cmd.append(quote("while true; do sleep 86400; done"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if with_output:
|
if with_output:
|
||||||
return self.process_runner.check_output(final_cmd)
|
return self.process_runner.check_output(final_cmd)
|
||||||
|
|
Loading…
Add table
Reference in a new issue