Collect lsblk and /proc/mdstat with ramdisk logs

This should improve debugability of partitioning problems.

Change-Id: I3c7ae3f2831c9900a3f0d24daec6dd6b8bea6a60
This commit is contained in:
Dmitry Tantsur 2019-10-08 17:30:05 +02:00
parent 5e3153825a
commit 11976c9d2b
4 changed files with 16 additions and 2 deletions

View File

@ -288,6 +288,7 @@ def list_all_block_devices(block_type='disk',
"version of block device name is unavailable "
"Cause: %(error)s", {'path': disk_by_path_dir, 'error': e})
# NOTE(dtantsur): keep in sync with utils.LSBLK_COLUMNS
columns = ['KNAME', 'MODEL', 'SIZE', 'ROTA', 'TYPE']
report = utils.execute('lsblk', '-Pbia', '-o{}'.format(','.join(columns)),
check_exit_code=[0])[0]

View File

@ -504,7 +504,8 @@ class TestUtils(testtools.TestCase):
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, 'lshw': mock.ANY})
'df': mock.ANY, 'iptables': mock.ANY, 'lshw': mock.ANY,
'lsblk': mock.ANY, 'mdstat': mock.ANY})
@mock.patch.object(utils, 'gzip_and_b64encode', autospec=True)
@mock.patch.object(utils, 'is_journalctl_present', autospec=True)
@ -525,7 +526,8 @@ class TestUtils(testtools.TestCase):
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, 'lshw': mock.ANY})
'dmesg': mock.ANY, 'df': mock.ANY, 'lshw': mock.ANY,
'lsblk': mock.ANY, 'mdstat': mock.ANY})
def test_get_ssl_client_options(self):
# defaults

View File

@ -52,12 +52,17 @@ LOG = logging.getLogger(__name__)
AGENT_PARAMS_CACHED = dict()
LSBLK_COLUMNS = ['KNAME', 'MODEL', 'SIZE', 'ROTA', 'TYPE', 'UUID', 'PARTUUID']
COLLECT_LOGS_COMMANDS = {
'ps': ['ps', 'au'],
'df': ['df', '-a'],
'iptables': ['iptables', '-L'],
'ip_addr': ['ip', 'addr'],
'lshw': ['lshw', '-quiet', '-json'],
'lsblk': ['lsblk', '--all', '-o%s' % ','.join(LSBLK_COLUMNS)],
'mdstat': ['cat', '/proc/mdstat'],
}
@ -404,6 +409,7 @@ def collect_system_logs(journald_max_lines=None):
the journald. if None, return everything.
:returns: A tar, gzip base64 encoded string with the logs.
"""
LOG.info('Collecting system logs and debugging information')
def try_get_command_output(io_dict, file_name, command):
try:

View File

@ -0,0 +1,5 @@
---
other:
- |
The output of ``lsblk`` and the contents of ``/proc/mdstat`` are now
collected with the ramdisk logs for debugging.