mirror of
https://github.com/vale981/ray
synced 2025-03-06 02:21:39 -05:00
[autoscaler] Flush stdout and stdin when running commands. (#19473)
Flush command stdout/stderr before exiting CommandRunner.run, so that setup command output is less likely to get swallowed.
This commit is contained in:
parent
b05b28b209
commit
806c187878
6 changed files with 13 additions and 10 deletions
|
@ -443,8 +443,8 @@ class SSHCommandRunner(CommandRunnerInterface):
|
||||||
Full command to run. Should include SSH options and other
|
Full command to run. Should include SSH options and other
|
||||||
processing that we do.
|
processing that we do.
|
||||||
with_output (bool):
|
with_output (bool):
|
||||||
If `with_output` is `True`, command stdout and stderr
|
If `with_output` is `True`, command stdout will be captured and
|
||||||
will be captured and returned.
|
returned.
|
||||||
exit_on_fail (bool):
|
exit_on_fail (bool):
|
||||||
If `exit_on_fail` is `True`, the process will exit
|
If `exit_on_fail` is `True`, the process will exit
|
||||||
if the command fails (exits with a code other than 0).
|
if the command fails (exits with a code other than 0).
|
||||||
|
@ -465,10 +465,8 @@ class SSHCommandRunner(CommandRunnerInterface):
|
||||||
silent=silent,
|
silent=silent,
|
||||||
use_login_shells=is_using_login_shells(),
|
use_login_shells=is_using_login_shells(),
|
||||||
)
|
)
|
||||||
if with_output:
|
|
||||||
return self.process_runner.check_output(final_cmd)
|
|
||||||
else:
|
else:
|
||||||
return self.process_runner.check_call(final_cmd)
|
return self.process_runner.check_output(final_cmd)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
joined_cmd = " ".join(final_cmd)
|
joined_cmd = " ".join(final_cmd)
|
||||||
if not is_using_login_shells():
|
if not is_using_login_shells():
|
||||||
|
@ -488,6 +486,11 @@ class SSHCommandRunner(CommandRunnerInterface):
|
||||||
if is_output_redirected():
|
if is_output_redirected():
|
||||||
fail_msg += " See above for the output from the failure."
|
fail_msg += " See above for the output from the failure."
|
||||||
raise click.ClickException(fail_msg) from None
|
raise click.ClickException(fail_msg) from None
|
||||||
|
finally:
|
||||||
|
# Do our best to flush output to terminal.
|
||||||
|
# See https://github.com/ray-project/ray/pull/19473.
|
||||||
|
sys.stdout.flush()
|
||||||
|
sys.stderr.flush()
|
||||||
|
|
||||||
def run(
|
def run(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -325,7 +325,7 @@ def run_cmd_redirected(
|
||||||
process_runner: Process runner used for executing commands.
|
process_runner: Process runner used for executing commands.
|
||||||
silent (bool): If true, the command output will be silenced completely
|
silent (bool): If true, the command output will be silenced completely
|
||||||
(redirected to /dev/null), unless verbose logging
|
(redirected to /dev/null), unless verbose logging
|
||||||
is enabled. Use this for runnign utility commands like
|
is enabled. Use this for running utility commands like
|
||||||
rsync.
|
rsync.
|
||||||
"""
|
"""
|
||||||
if silent and cli_logger.verbosity < 1:
|
if silent and cli_logger.verbosity < 1:
|
||||||
|
|
|
@ -436,7 +436,7 @@ class NodeUpdater:
|
||||||
_numbered=("[]", 4, NUM_SETUP_STEPS),
|
_numbered=("[]", 4, NUM_SETUP_STEPS),
|
||||||
)
|
)
|
||||||
with cli_logger.group(
|
with cli_logger.group(
|
||||||
"Initalizing command runner",
|
"Initializing command runner",
|
||||||
# todo: fix command numbering
|
# todo: fix command numbering
|
||||||
_numbered=("[]", 5, NUM_SETUP_STEPS),
|
_numbered=("[]", 5, NUM_SETUP_STEPS),
|
||||||
):
|
):
|
||||||
|
|
|
@ -32,7 +32,7 @@ Acquiring an up-to-date head node
|
||||||
\[3/7\] No worker file mounts to sync
|
\[3/7\] No worker file mounts to sync
|
||||||
New status: setting-up
|
New status: setting-up
|
||||||
\[4/7\] Running initialization commands
|
\[4/7\] Running initialization commands
|
||||||
\[5/7\] Initalizing command runner
|
\[5/7\] Initializing command runner
|
||||||
\[6/7\] Running setup commands
|
\[6/7\] Running setup commands
|
||||||
\(0/4\) echo a
|
\(0/4\) echo a
|
||||||
\(1/4\) echo b
|
\(1/4\) echo b
|
||||||
|
|
|
@ -32,7 +32,7 @@ Acquiring an up-to-date head node
|
||||||
\[3/7\] No worker file mounts to sync
|
\[3/7\] No worker file mounts to sync
|
||||||
New status: setting-up
|
New status: setting-up
|
||||||
\[4/7\] Running initialization commands
|
\[4/7\] Running initialization commands
|
||||||
\[5/7\] Initalizing command runner
|
\[5/7\] Initializing command runner
|
||||||
\[6/7\] Running setup commands
|
\[6/7\] Running setup commands
|
||||||
\(0/4\) echo a
|
\(0/4\) echo a
|
||||||
\(1/4\) echo b
|
\(1/4\) echo b
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
.+\.py.*Running `echo init`
|
.+\.py.*Running `echo init`
|
||||||
.+\.py.*Full command is `ssh.+`
|
.+\.py.*Full command is `ssh.+`
|
||||||
.+\.py.*NodeUpdater: i-.+: Initialization commands succeeded \[LogTimer=.+\]
|
.+\.py.*NodeUpdater: i-.+: Initialization commands succeeded \[LogTimer=.+\]
|
||||||
.+\.py.*\[5/7\] Initalizing command runner
|
.+\.py.*\[5/7\] Initializing command runner
|
||||||
.+\.py.*\[6/7\] Running setup commands
|
.+\.py.*\[6/7\] Running setup commands
|
||||||
.+\.py.*\(0/4\) echo a
|
.+\.py.*\(0/4\) echo a
|
||||||
.+\.py.*Running `echo a`
|
.+\.py.*Running `echo a`
|
||||||
|
|
Loading…
Add table
Reference in a new issue