← Back to team overview

curtin-dev team mailing list archive

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

 

Michael Hudson-Doyle has proposed merging ~mwhudson/curtin:fix-multipath-reuse into curtin:master.

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.



Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/415928

This time for sure (tm)
-- 
Your team curtin developers is requested to review the proposed merge of ~mwhudson/curtin:fix-multipath-reuse into curtin:master.
diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py
index f3f19dc..fbbfeeb 100644
--- a/curtin/commands/block_meta.py
+++ b/curtin/commands/block_meta.py
@@ -820,7 +820,7 @@ def verify_ptable_flag(devpath, expected_flag, label, part_info):
 
 
 def partition_verify_sfdisk(part_action, label, sfdisk_part_info):
-    devpath = sfdisk_part_info['node']
+    devpath = os.path.realpath(sfdisk_part_info['node'])
     verify_size(
         devpath, int(util.human2bytes(part_action['size'])), sfdisk_part_info)
     expected_flag = part_action.get('flag')
diff --git a/tests/unittests/test_commands_block_meta.py b/tests/unittests/test_commands_block_meta.py
index 3e22792..7c8e7bf 100644
--- a/tests/unittests/test_commands_block_meta.py
+++ b/tests/unittests/test_commands_block_meta.py
@@ -2572,6 +2572,8 @@ class TestPartitionVerifySfdisk(CiTestCase):
         base = 'curtin.commands.block_meta.'
         self.add_patch(base + 'verify_size', 'm_verify_size')
         self.add_patch(base + 'verify_ptable_flag', 'm_verify_ptable_flag')
+        self.add_patch(base + 'os.path.realpath', 'm_realpath')
+        self.m_realpath.side_effect = lambda x: x
         self.info = {
             'id': 'disk-sda-part-2',
             'type': 'partition',

Follow ups