From 2c485a259891a2e185b772a4a20466d086765150 Mon Sep 17 00:00:00 2001 From: Alex Wu Date: Fri, 5 Jun 2020 17:08:38 -0700 Subject: [PATCH] [autoscaler] Command runner interactivity (#7198) --- python/ray/autoscaler/commands.py | 1 - python/ray/autoscaler/updater.py | 17 +++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/python/ray/autoscaler/commands.py b/python/ray/autoscaler/commands.py index 81c40494e..121d2970d 100644 --- a/python/ray/autoscaler/commands.py +++ b/python/ray/autoscaler/commands.py @@ -471,7 +471,6 @@ def _exec(updater, cmd, screen, tmux, port_forward=None, with_output=False): cmd = " ".join(cmd) return updater.cmd_runner.run( cmd, - allocate_tty=True, exit_on_fail=True, port_forward=port_forward, with_output=with_output) diff --git a/python/ray/autoscaler/updater.py b/python/ray/autoscaler/updater.py index 026b6c905..cf253e775 100644 --- a/python/ray/autoscaler/updater.py +++ b/python/ray/autoscaler/updater.py @@ -47,7 +47,6 @@ class KubernetesCommandRunner: def run(self, cmd=None, timeout=120, - allocate_tty=False, exit_on_fail=False, port_forward=None, with_output=False): @@ -77,12 +76,12 @@ class KubernetesCommandRunner: raise Exception(exception_str) else: logger.info(self.log_prefix + "Running {}...".format(cmd)) - final_cmd = self.kubectl + [ - "exec", - "-it" if allocate_tty else "-i", + final_cmd = self.kubectl + ["exec", "-it"] + final_cmd += [ self.node_id, "--", - ] + with_interactive(cmd) + ] + final_cmd += with_interactive(cmd) try: if with_output: return self.process_runner.check_output( @@ -230,16 +229,13 @@ class SSHCommandRunner: def run(self, cmd, timeout=120, - allocate_tty=False, exit_on_fail=False, port_forward=None, with_output=False): self.set_ssh_ip_if_required() - ssh = ["ssh"] - if allocate_tty: - ssh.append("-tt") + ssh = ["ssh", "-tt"] if port_forward: if not isinstance(port_forward, list): @@ -260,7 +256,8 @@ class SSHCommandRunner: else: # We do this because `-o ControlMaster` causes the `-N` flag to # 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: if with_output: return self.process_runner.check_output(final_cmd)