Skip to content

Commit 683176d

Browse files
committed
boot: Skip checks of first partition offset for for gpt partition table
This is extension of the previous commit. The original problem that we are trying to resolve is to be sure the embedding area (MBR gap) has expected size. This is irrelevant in case of GPT partition table is used on a device. The fdisk output format is in case of GPT disk label different, which breaks the parsing, resulting in empty list of partitions in related GRUBDevicePartitionLayout msg. For now, let's skip produce of msgs for "GPT devices". As a seatbelt, ignore processing of messages with empty partitions field, expecting that such a device does not contain MBR. We want to prevent false positive inhibitors (and FP blocking errors). We expect that total number of machines with small embedding area is very minor in total numbers, so even if we would miss something (which is not expected now to our best knowledge) it's still good trade-off as the major goal is to reduce number of machines that have problems with the in-place upgrade. The solution can be updated in future if there is a reason for it.
1 parent ea6cd79 commit 683176d

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

repos/system_upgrade/el7toel8/actors/checkfirstpartitionoffset/libraries/check_first_partition_offset.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ def check_first_partition_offset():
1616

1717
problematic_devices = []
1818
for grub_dev in api.consume(GRUBDevicePartitionLayout):
19+
if not grub_dev.partitions:
20+
# NOTE(pstodulk): In case of empty partition list we have nothing to do.
21+
# This can could happen when the fdisk output is different then expected.
22+
# E.g. when GPT partition table is used on the disk. We are right now
23+
# interested strictly about MBR only, so ignoring these cases.
24+
# This is seatbelt, as the msg should not be produced for GPT at all.
25+
continue
1926
first_partition = min(grub_dev.partitions, key=lambda partition: partition.start_offset)
2027
if first_partition.start_offset < SAFE_OFFSET_BYTES:
2128
problematic_devices.append(grub_dev.device)

repos/system_upgrade/el7toel8/actors/checkfirstpartitionoffset/tests/test_check_first_partition_offset.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@
2020
],
2121
True
2222
),
23+
(
24+
[
25+
GRUBDevicePartitionLayout(device='/dev/vda',
26+
partitions=[
27+
PartitionInfo(part_device='/dev/vda2', start_offset=1024*1025),
28+
PartitionInfo(part_device='/dev/vda1', start_offset=32256)
29+
])
30+
],
31+
True
32+
),
2333
(
2434
[
2535
GRUBDevicePartitionLayout(device='/dev/vda',
@@ -33,6 +43,12 @@
3343
partitions=[PartitionInfo(part_device='/dev/vda1', start_offset=1024*1024)])
3444
],
3545
False
46+
),
47+
(
48+
[
49+
GRUBDevicePartitionLayout(device='/dev/vda', partitions=[])
50+
],
51+
False
3652
)
3753
]
3854
)

repos/system_upgrade/el7toel8/actors/scangrubdevpartitionlayout/libraries/scan_layout.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,34 @@ def get_partition_layout(device):
3131
unit = int(unit.split(' ')[0].strip())
3232
break # First line of the partition table header
3333

34+
# Discover disk label type: dos | gpt
35+
for line in table_iter:
36+
line = line.strip()
37+
if not line.startswith('Disk label type'):
38+
continue
39+
disk_type = line.split(':')[1].strip()
40+
break
41+
42+
if disk_type == 'gpt':
43+
api.current_logger().info(
44+
'Detected GPT partition table. Skipping produce of GRUBDevicePartitionLayout message.'
45+
)
46+
# NOTE(pstodulk): The GPT table has a different output format than
47+
# expected below, example (ignore start/end lines):
48+
# --------------------------- start ----------------------------------
49+
# # Start End Size Type Name
50+
# 1 2048 4095 1M BIOS boot
51+
# 2 4096 2101247 1G Microsoft basic
52+
# 3 2101248 41940991 19G Linux LVM
53+
# ---------------------------- end -----------------------------------
54+
# But mainly, in case of GPT, we have nothing to actually check as
55+
# we are gathering this data now mainly to get information about the
56+
# actual size of embedding area (MBR gap). In case of GPT, there is
57+
# bios boot / prep boot partition, which has always 1 MiB and fulfill
58+
# our expectations. So skip in this case another processing and generation
59+
# of the msg. Let's improve it in future if we find a reason for it.
60+
return None
61+
3462
for line in table_iter:
3563
line = line.strip()
3664
if not line.startswith('Device'):

repos/system_upgrade/el7toel8/actors/scangrubdevpartitionlayout/tests/test_scan_partition_layout.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,8 @@ def consume_mocked(*args, **kwargs):
7676
expected_part_name_to_start = {part.name: part.start_offset*dev.sector_size for part in dev.partitions}
7777
actual_part_name_to_start = {part.part_device: part.start_offset for part in message.partitions}
7878
assert expected_part_name_to_start == actual_part_name_to_start
79+
80+
81+
def test_get_partition_layout_gpt(monkeypatch):
82+
# TODO(pstodulk): skipping for now, due to time pressure. Testing for now manually.
83+
pass

0 commit comments

Comments
 (0)