Skip to content

Commit

Permalink
EngineClient: skip closing eof on non-existing streams
Browse files Browse the repository at this point in the history
We close stdin when clush's stdin closes as well as when remote workers
exit.

Fixes this kind of trace:
$ echo | clush -w foobar[0-11] -d echo
...
WARNING:ClusterShell.Worker.EngineClient:<ClusterShell.Worker.Ssh.SshClient instance at 0x28eaab8>: [Errno 32] Broken pipe
...
foobar0: ssh: Could not resolve hostname foobar0: Name or service not known
...
clush: foobar0: exited with exit code 255
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ClusterShell/CLI/Clush.py", line 751, in clush_excepthook
    raise exp
KeyError: 'stdin'

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/clush", line 10, in <module>
    main()
  File "/usr/lib/python2.7/site-packages/ClusterShell/CLI/Clush.py", line 1069, in main
    options.remote != 'no')
  File "/usr/lib/python2.7/site-packages/ClusterShell/CLI/Clush.py", line 667, in run_command
    task.resume()
  File "/usr/lib/python2.7/site-packages/ClusterShell/Task.py", line 799, in resume
    self._resume()
  File "/usr/lib/python2.7/site-packages/ClusterShell/Task.py", line 762, in _resume
    self._run(self.timeout)
  File "/usr/lib/python2.7/site-packages/ClusterShell/Task.py", line 407, in _run
    self._engine.run(timeout)
  File "/usr/lib/python2.7/site-packages/ClusterShell/Engine/Engine.py", line 700, in run
    self.runloop(timeout)
  File "/usr/lib/python2.7/site-packages/ClusterShell/Engine/EPoll.py", line 165, in runloop
    client._handle_read(sname)
  File "/usr/lib/python2.7/site-packages/ClusterShell/Worker/EngineClient.py", line 520, in _handle_read
    self.eh.ev_msg(self, pmsg.get())
  File "/usr/lib/python2.7/site-packages/ClusterShell/CLI/Clush.py", line 85, in ev_msg
    self.master_worker.set_write_eof()
  File "/usr/lib/python2.7/site-packages/ClusterShell/Worker/Exec.py", line 365, in set_write_eof
    client._set_write_eof(sname or self.SNAME_STDIN)
  File "/usr/lib/python2.7/site-packages/ClusterShell/Worker/EngineClient.py", line 415, in _set_write_eof
    wfile = self.streams[sname]
KeyError: 'stdin'

Closes #320.

Change-Id: I877e036548dd95abda4494e420ab6c9bc5138bff
  • Loading branch information
Dominique Martinet committed Sep 13, 2016
1 parent 1604ffb commit b121270
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ClusterShell/Worker/EngineClient.py
Expand Up @@ -418,6 +418,11 @@ def _write(self, sname, buf):

def _set_write_eof(self, sname):
"""Set EOF on specific writable stream."""
if sname not in self.streams:
LOGGER.debug("stream %s was already closed on client %s, skipping",
sname, self.key)
return

wfile = self.streams[sname]
wfile.eof = True
if self._engine and wfile.fd and not wfile.wbuf:
Expand Down

0 comments on commit b121270

Please sign in to comment.