Merge ~mwhudson/curtin:fix-multipath-reuse into curtin:master

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: c3ed71475cca693aa8f11fadbbab19bb7b88b630
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~mwhudson/curtin:fix-multipath-reuse
Merge into: curtin:master
Diff against target: 26 lines (+3/-1)
2 files modified
curtin/commands/block_meta.py (+1/-1)
tests/unittests/test_commands_block_meta.py (+2/-0)
Reviewer Review Type Date Requested Status
Dan Bungert Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+415928@code.launchpad.net

Commit message

block_meta: call realpath on partition node returned by sfdisk

sfdisk --json on a device mapper block device will "helpfully" return
paths like /device/mapper/mpatha-part1 for the "node" of each partition.
This doesn't work so well when you then assume that the basename of the
returned path is the kernel name for the device.

This fixes reusing a partition on a multipath disk.

Description of the change

This time for sure (tm)

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Dan Bungert (dbungert) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py
2index f3f19dc..fbbfeeb 100644
3--- a/curtin/commands/block_meta.py
4+++ b/curtin/commands/block_meta.py
5@@ -820,7 +820,7 @@ def verify_ptable_flag(devpath, expected_flag, label, part_info):
6
7
8 def partition_verify_sfdisk(part_action, label, sfdisk_part_info):
9- devpath = sfdisk_part_info['node']
10+ devpath = os.path.realpath(sfdisk_part_info['node'])
11 verify_size(
12 devpath, int(util.human2bytes(part_action['size'])), sfdisk_part_info)
13 expected_flag = part_action.get('flag')
14diff --git a/tests/unittests/test_commands_block_meta.py b/tests/unittests/test_commands_block_meta.py
15index 3e22792..7c8e7bf 100644
16--- a/tests/unittests/test_commands_block_meta.py
17+++ b/tests/unittests/test_commands_block_meta.py
18@@ -2572,6 +2572,8 @@ class TestPartitionVerifySfdisk(CiTestCase):
19 base = 'curtin.commands.block_meta.'
20 self.add_patch(base + 'verify_size', 'm_verify_size')
21 self.add_patch(base + 'verify_ptable_flag', 'm_verify_ptable_flag')
22+ self.add_patch(base + 'os.path.realpath', 'm_realpath')
23+ self.m_realpath.side_effect = lambda x: x
24 self.info = {
25 'id': 'disk-sda-part-2',
26 'type': 'partition',

Subscribers

People subscribed via source and target branches