[autoscaler] Command runner interactivity (#7198)

This commit is contained in:
Alex Wu 2020-06-05 17:08:38 -07:00 committed by GitHub
parent 7bfce5c027
commit 2c485a2598
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 11 deletions

View file

@ -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)

View file

@ -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)