From 5d2c2c1f31d5ec8a322bccaebb47720b3a20ebef Mon Sep 17 00:00:00 2001 From: Petr Stodulka Date: Tue, 12 Nov 2024 09:10:50 +0100 Subject: [PATCH] scangrubdevpartitionlayout: Skip warning msgs The fdisk output can contain warning msgs when a partition is not alligned on physical sector boundary, like: Partition 4 does not start on physical sector boundary. We know that in case of MBR the line we expect to parse always starts with canonical path. So let's skip all lines which does not start with '/'. jira: https://issues.redhat.com/browse/RHEL-50947 --- .../libraries/scan_layout.py | 10 ++++++++++ .../tests/test_scan_partition_layout.py | 3 +++ 2 files changed, 13 insertions(+) diff --git a/repos/system_upgrade/el7toel8/actors/scangrubdevpartitionlayout/libraries/scan_layout.py b/repos/system_upgrade/el7toel8/actors/scangrubdevpartitionlayout/libraries/scan_layout.py index 83d026568c..cd529d18c9 100644 --- a/repos/system_upgrade/el7toel8/actors/scangrubdevpartitionlayout/libraries/scan_layout.py +++ b/repos/system_upgrade/el7toel8/actors/scangrubdevpartitionlayout/libraries/scan_layout.py @@ -68,6 +68,16 @@ def get_partition_layout(device): partitions = [] for partition_line in table_iter: + if not partition_line.startswith('/'): + # the output can contain warning msg when a partition is not alligned + # on physical sector boundary, like: + # ~~~ + # Partition 4 does not start on physical sector boundary. + # ~~~ + # We know that in case of MBR the line we expect to parse always + # starts with canonical path. So let's use this condition. + # See https://issues.redhat.com/browse/RHEL-50947 + continue # Fields: Device Boot Start End Sectors Size Id Type # The line looks like: `/dev/vda1 * 2048 2099199 2097152 1G 83 Linux` part_info = split_on_space_segments(partition_line) diff --git a/repos/system_upgrade/el7toel8/actors/scangrubdevpartitionlayout/tests/test_scan_partition_layout.py b/repos/system_upgrade/el7toel8/actors/scangrubdevpartitionlayout/tests/test_scan_partition_layout.py index 743ca71fe6..9c32e16fea 100644 --- a/repos/system_upgrade/el7toel8/actors/scangrubdevpartitionlayout/tests/test_scan_partition_layout.py +++ b/repos/system_upgrade/el7toel8/actors/scangrubdevpartitionlayout/tests/test_scan_partition_layout.py @@ -49,6 +49,9 @@ def test_get_partition_layout(monkeypatch, devices, fs): part_line = '{0} * {1} 2099199 1048576 83 {2}'.format(part.name, part.start_offset, fs) fdisk_output.append(part_line) + # add a problematic warning msg to test: + # https://issues.redhat.com/browse/RHEL-50947 + fdisk_output.append('Partition 3 does not start on physical sector boundary.') device_to_fdisk_output[device.name] = fdisk_output def mocked_run(cmd, *args, **kwargs):