-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Update xCAT bindings example, to prevent lsdef
from gobbling stdin
#580
Conversation
jobs from specific accounts, or under specific QOSes.
I'd argue clustershell should not pass stdin to mapping commands in the first place? diff --git a/lib/ClusterShell/NodeUtils.py b/lib/ClusterShell/NodeUtils.py
index f4a52f639743..ba8ebad4ec5b 100644
--- a/lib/ClusterShell/NodeUtils.py
+++ b/lib/ClusterShell/NodeUtils.py
@@ -44,7 +44,7 @@ import shlex
import time
from string import Template
-from subprocess import Popen, PIPE
+from subprocess import Popen, PIPE, DEVNULL
try:
basestring
@@ -202,8 +202,8 @@ class UpcallGroupSource(GroupSource):
"""
cmdline = Template(self.upcalls[cmdtpl]).safe_substitute(args)
self.logger.debug("EXEC '%s'", cmdline)
- proc = Popen(cmdline, stdout=PIPE, shell=True, cwd=self.cfgdir,
- universal_newlines=True)
+ proc = Popen(cmdline, stdin=DEVNULL, stdout=PIPE, shell=True,
+ cwd=self.cfgdir, universal_newlines=True)
output = proc.communicate()[0].strip()
self.logger.debug("READ '%s'", output)
if proc.returncode != 0: might want to check if we have more like that... |
Very good point, why are we doing that?! Maybe because In clustershell 1.9.x we should just be careful to do it so it doesn't break the compat for py2.7 (I know, it's old, but it's nice to be able to upgrade older clusters) |
For 2.7 we apparently need to open devnull ourselves...
|
Looks good to me, thank you! @degremont any opinion on this? |
I'm fine with @martinetd proposal, that's the right thing to do here IMO. |
lsdef
consumes stdin by default, so we feed it/dev/null
to avoid issues in read loops (useful in scripts!)See xcat2/xcat-core#6024 for reference.