Commit 710bc88c authored by Iustin Pop's avatar Iustin Pop
Browse files

QA: stop logging SSH arguments for each invocation



Currently, this is how the QA log looks like:

Command: ssh -oEscapeChar=none -oBatchMode=yes -l root -t -oStrictHostKeyChecking=yes -oClearAllForwardings=yes -oForwardAgent=yes -oControlPath=/tmp/ganeti-qa-multiplexer.DMzkuH -oControlMaster=no node14 exit
Command: ssh -oEscapeChar=none -oBatchMode=yes -l root -t -oStrictHostKeyChecking=yes -oClearAllForwardings=yes -oForwardAgent=yes node8 exit
Command: ssh -oEscapeChar=none -oBatchMode=yes -l root -t -oStrictHostKeyChecking=yes -oClearAllForwardings=yes -oForwardAgent=yes node18 exit

And these arguments are repeated over and over. This patch proposes to
log once the arguments, at the beginning of the QA (so that the SSH
commands can be reproduced, if needed) and then drop them from the
log. The new output looks like:

SSH command for primary node: ssh -oEscapeChar=none -oBatchMode=yes -lroot -oStrictHostKeyChecking=yes -oClearAllForwardings=yes -oForwardAgent=yes -oControlPath=/tmp/ganeti-qa-multiplexer.24lgrK -oControlMaster=no node14
SSH command for other nodes: ssh -oEscapeChar=none -oBatchMode=yes -lroot -oStrictHostKeyChecking=yes -oClearAllForwardings=yes -oForwardAgent=yes NODE
(the above are the informational messages about parameters, then)
Command: ssh node14 exit
Command: ssh node8 exit
Command: ssh node18 exit

This makes the QA log much more readable, by dropping unneeded clutter
(look how long the original lines were), and hopefully also a bit
smaller (current QA log is > 100MB of text output).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarBernardo Dal Seno <bdalseno@google.com>
parent f14a8b15
......@@ -553,7 +553,12 @@ def main():
qa_config.Load(config_file)
qa_utils.StartMultiplexer(qa_config.GetMasterNode()["primary"])
primary = qa_config.GetMasterNode()["primary"]
qa_utils.StartMultiplexer(primary)
print ("SSH command for primary node: %s" %
utils.ShellQuoteArgs(qa_utils.GetSSHCommand(primary, "")))
print ("SSH command for other nodes: %s" %
utils.ShellQuoteArgs(qa_utils.GetSSHCommand("NODE", "")))
try:
RunQa()
finally:
......
#
#
# Copyright (C) 2007, 2011 Google Inc.
# Copyright (C) 2007, 2011, 2012 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -207,7 +207,7 @@ def GetSSHCommand(node, cmd, strict=True, opts=None, tty=None):
@param tty: if we should use tty; if None, will be auto-detected
"""
args = ["ssh", "-oEscapeChar=none", "-oBatchMode=yes", "-l", "root"]
args = ["ssh", "-oEscapeChar=none", "-oBatchMode=yes", "-lroot"]
if tty is None:
tty = sys.stdout.isatty()
......@@ -235,11 +235,15 @@ def GetSSHCommand(node, cmd, strict=True, opts=None, tty=None):
return args
def StartLocalCommand(cmd, **kwargs):
def StartLocalCommand(cmd, _nolog_opts=False, **kwargs):
"""Starts a local command.
"""
print "Command: %s" % utils.ShellQuoteArgs(cmd)
if _nolog_opts:
pcmd = [i for i in cmd if not i.startswith("-")]
else:
pcmd = cmd
print "Command: %s" % utils.ShellQuoteArgs(pcmd)
return subprocess.Popen(cmd, shell=False, **kwargs)
......@@ -247,7 +251,8 @@ def StartSSH(node, cmd, strict=True):
"""Starts SSH.
"""
return StartLocalCommand(GetSSHCommand(node, cmd, strict=strict))
return StartLocalCommand(GetSSHCommand(node, cmd, strict=strict),
_nolog_opts=True)
def StartMultiplexer(node):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment