summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2017-09-08 02:40:01 +0200
committerAmar Tumballi <amarts@redhat.com>2018-03-26 12:48:16 +0000
commit6611aa8203d60bf8e5e8772a31b09ae63f3996f3 (patch)
treeb77e7769771f2ce106757fd2d2033ea10e8f642a /tools
parent52c63dafd297163067b8ccb26c864271e6bb11ac (diff)
glusterfind: Log remote stderr on `node_cmd` error. Fixes #1559130
The problem of lost stderr was introduced in commit feea851fad4f89b48bfe89fe3b75250cc7bd6501. Change-Id: Ic98f9bc9682ae3bd9c3ebea3855667fc8ba2843d BUG: 1559130 Signed-off-by: Niklas Hambüchen <mail@nh2.me>
Diffstat (limited to 'tools')
-rw-r--r--tools/glusterfind/src/main.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
index e7e9889569c..63de6d06410 100644
--- a/tools/glusterfind/src/main.py
+++ b/tools/glusterfind/src/main.py
@@ -75,12 +75,27 @@ def node_cmd(host, host_uuid, task, cmd, args, opts):
cmd = ["ssh",
"-oNumberOfPasswordPrompts=0",
"-oStrictHostKeyChecking=no",
+ # We force TTY allocation (-t -t) so that Ctrl+C is handed
+ # through; see:
+ # https://bugzilla.redhat.com/show_bug.cgi?id=1382236
+ # Note that this turns stderr of the remote `cmd`
+ # into stdout locally.
"-t",
"-t",
"-i", pem_key_path,
"root@%s" % host] + cmd
- execute(cmd, exit_msg="%s - %s failed" % (host, task), logger=logger)
+ (returncode, err, out) = execute(cmd, logger=logger)
+ if returncode != 0:
+ # Because the `-t -t` above turns the remote stderr into
+ # local stdout, we need to log both stderr and stdout
+ # here to print all error messages.
+ fail("%s - %s failed; stdout (including remote stderr):\n"
+ "%s\n"
+ "stderr:\n"
+ "%s" % (host, task, out, err),
+ returncode,
+ logger=logger)
if opts.get("copy_outfile", False) and not localdir:
cmd_copy = ["scp",