From b41e98d04fb644b82c3b399fec3903c9632bc43e Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Mon, 17 Jun 2019 11:37:07 +0200 Subject: [PATCH] Stop logging lshw output, collect it with other logs instead The lshw output is huge even on virtual machines, and it pollutes the debug logging. This change silences it. Instead, the lshw output is collected as part of the ramdisk logs. Depends-On: https://review.opendev.org/#/c/665635/ Change-Id: I6a3015b2d8d09f6f48b5cbd39dc84bd75b72f909 (cherry picked from commit 94048fe97e93af3ad6902c3c1aa4ec5d92b41747) --- ironic_python_agent/hardware.py | 2 +- ironic_python_agent/tests/unit/test_utils.py | 10 ++++++---- ironic_python_agent/utils.py | 1 + releasenotes/notes/lshw-cb89894be057bdc9.yaml | 5 +++++ 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/lshw-cb89894be057bdc9.yaml diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index 42561c25c..4a884c889 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -73,7 +73,7 @@ def _get_system_lshw_dict(): :return: A python dict from the lshw json output """ - out, _e = utils.execute('lshw', '-quiet', '-json') + out, _e = utils.execute('lshw', '-quiet', '-json', log_stdout=False) return json.loads(out) diff --git a/ironic_python_agent/tests/unit/test_utils.py b/ironic_python_agent/tests/unit/test_utils.py index d99ebfaa7..24b5994f0 100644 --- a/ironic_python_agent/tests/unit/test_utils.py +++ b/ironic_python_agent/tests/unit/test_utils.py @@ -498,12 +498,13 @@ class TestUtils(testtools.TestCase): self.assertEqual(ret, logs_string) mock_logs.assert_called_once_with(lines=None) calls = [mock.call(['ps', 'au']), mock.call(['df', '-a']), - mock.call(['iptables', '-L']), mock.call(['ip', 'addr'])] + mock.call(['iptables', '-L']), mock.call(['ip', 'addr']), + mock.call(['lshw', '-quiet', '-json'])] mock_outputs.assert_has_calls(calls, any_order=True) mock_gzip_b64.assert_called_once_with( file_list=[], io_dict={'journal': mock.ANY, 'ip_addr': mock.ANY, 'ps': mock.ANY, - 'df': mock.ANY, 'iptables': mock.ANY}) + 'df': mock.ANY, 'iptables': mock.ANY, 'lshw': mock.ANY}) @mock.patch.object(utils, 'gzip_and_b64encode', autospec=True) @mock.patch.object(utils, 'is_journalctl_present', autospec=True) @@ -518,12 +519,13 @@ class TestUtils(testtools.TestCase): self.assertEqual(ret, logs_string) calls = [mock.call(['dmesg']), mock.call(['ps', 'au']), mock.call(['df', '-a']), mock.call(['iptables', '-L']), - mock.call(['ip', 'addr'])] + mock.call(['ip', 'addr']), + mock.call(['lshw', '-quiet', '-json'])] mock_outputs.assert_has_calls(calls, any_order=True) mock_gzip_b64.assert_called_once_with( file_list=['/var/log'], io_dict={'iptables': mock.ANY, 'ip_addr': mock.ANY, 'ps': mock.ANY, - 'dmesg': mock.ANY, 'df': mock.ANY}) + 'dmesg': mock.ANY, 'df': mock.ANY, 'lshw': mock.ANY}) def test_get_ssl_client_options(self): # defaults diff --git a/ironic_python_agent/utils.py b/ironic_python_agent/utils.py index 4621ff8d7..f391b74d2 100644 --- a/ironic_python_agent/utils.py +++ b/ironic_python_agent/utils.py @@ -56,6 +56,7 @@ COLLECT_LOGS_COMMANDS = { 'df': ['df', '-a'], 'iptables': ['iptables', '-L'], 'ip_addr': ['ip', 'addr'], + 'lshw': ['lshw', '-quiet', '-json'], } diff --git a/releasenotes/notes/lshw-cb89894be057bdc9.yaml b/releasenotes/notes/lshw-cb89894be057bdc9.yaml new file mode 100644 index 000000000..94a97a3f9 --- /dev/null +++ b/releasenotes/notes/lshw-cb89894be057bdc9.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + The ``lshw`` output no longer pollutes the debug logging. Instead, it's + stored as part of the ramdisk logs.