Skip to content

clush: always close stdin stream of worker when it is not used #478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lib/ClusterShell/CLI/Clush.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,13 +676,13 @@ def run_command(task, cmd, ns, timeout, display, remote, trytree):
# this is the simpler but faster output handler
handler = DirectOutputHandler(display)

stdin = task.default("USER_stdin_worker")
worker = task.shell(cmd, nodes=ns, handler=handler, timeout=timeout,
remote=remote, tree=trytree)
remote=remote, tree=trytree, stdin=stdin)
if ns is None:
worker.set_key('LOCAL')
if task.default("USER_stdin_worker"):
if stdin:
bind_stdin(worker, display)

task.resume()

def run_copy(task, sources, dest, ns, timeout, preserve_flag, display):
Expand Down Expand Up @@ -1032,9 +1032,6 @@ def main():
# Enable stdout/stderr separation
task.set_default("stderr", not options.gatherall)

# Prevent reading from stdin?
task.set_default("stdin", not options.nostdin)

# Disable MsgTree buffering if not gathering outputs
task.set_default("stdout_msgtree", display.gather or display.line_mode)

Expand Down
12 changes: 12 additions & 0 deletions tests/CLIClushTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,18 @@ def test_039_conf_option(self):
"foo[1-10]", "echo ok"], b"",
b"---------------\nfoo[1-10]\n---------------\nok\n")

def test_040_stdin_eof(self):
"""test clush (stdin eof)"""
# should not block if connection to stdin cannot be established
# or of --nostdin is specified
self._clush_t(["-w", HOSTNAME, "cat"], None, b'')
self._clush_t(["-w", HOSTNAME, "--nostdin", "cat"], None, b'')
setattr(ClusterShell.CLI.Clush, '_f_user_interaction', True)
try:
self._clush_t(["-w", HOSTNAME, "cat"], None, b'')
finally:
delattr(ClusterShell.CLI.Clush, '_f_user_interaction')


class CLIClushTest_B_StdinFailure(unittest.TestCase):
"""Unit test class for testing CLI/Clush.py and stdin failure"""
Expand Down