From: Matthew Treinish Date: Mon, 24 Aug 2015 17:28:22 +0000 (-0400) Subject: Stop logging STDOUT and STDERR on every shell out X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=423392564e6c135be4cf6270659065b2c8b08b37;p=openstack-build%2Fneutron-build.git Stop logging STDOUT and STDERR on every shell out Sometimes you can log too much. For example, logging a complete iptables dump on every security group operation, OMG TMI. Doing this during DSVM run results in a log file >7M compressed. To mitigate this issue this commit switches the execute method to only log the command and it's exit code on the success case. If there is a failure the entire stdin, stdout and stderr are logged. Change-Id: Iaf17297306dc752e666612033c805a528f078f2f --- diff --git a/neutron/agent/linux/utils.py b/neutron/agent/linux/utils.py index 95c47a060..ff1ef7b02 100644 --- a/neutron/agent/linux/utils.py +++ b/neutron/agent/linux/utils.py @@ -134,19 +134,20 @@ def execute(cmd, process_input=None, addl_env=None, except UnicodeError: pass - m = _("\nCommand: {cmd}\nExit code: {code}\nStdin: {stdin}\n" - "Stdout: {stdout}\nStderr: {stderr}").format( + m = _("\nCommand: {cmd}\nExit code: {code}\n").format( cmd=cmd, - code=returncode, - stdin=process_input or '', - stdout=_stdout, - stderr=_stderr) + code=returncode) extra_ok_codes = extra_ok_codes or [] if returncode and returncode in extra_ok_codes: returncode = None if returncode and log_fail_as_error: + m += ("Stdin: {stdin}\n" + "Stdout: {stdout}\nStderr: {stderr}").format( + stdin=process_input or '', + stdout=_stdout, + stderr=_stderr) LOG.error(m) else: LOG.debug(m)