Use kpartx option to update partition mappings
Fix cases of 'mkfs' failing because the partitions never showed up. Partition mappings will now be updated instead of just adding them with 'kpartx'. That means that 'kpartx' will also remove devmappings for deleted partitions. Traceback of failing mkfs call: 2020-05-11 22:03:25.523 | INFO diskimage_builder.block_device.utils [-] Calling [sudo sync] 2020-05-11 22:03:25.539 | INFO diskimage_builder.block_device.utils [-] Calling [sudo kpartx -avs /dev/loop0] 2020-05-11 22:03:25.581 | INFO diskimage_builder.block_device.utils [-] Calling [sudo mkfs -t ext4 -i 4096 -J size=64 -L cloudimg-rootfs -U 21c6f9eb-4d52-4e5c-b9b7-796735de8909 -q /dev/mapper/loop0p1] 2020-05-11 22:03:25.700 | ERROR diskimage_builder.block_device.blockdevice [-] Create failed; rollback initiated 2020-05-11 22:03:25.700 | Traceback (most recent call last): 2020-05-11 22:03:25.700 | File "/home/zuul/dib/lib/python3.6/site-packages/diskimage_builder/block_device/blockdevice.py", line 406, in cmd_create 2020-05-11 22:03:25.700 | node.create() 2020-05-11 22:03:25.700 | File "/home/zuul/dib/lib/python3.6/site-packages/diskimage_builder/block_device/level2/mkfs.py", line 133, in create 2020-05-11 22:03:25.700 | exec_sudo(cmd) 2020-05-11 22:03:25.700 | File "/home/zuul/dib/lib/python3.6/site-packages/diskimage_builder/block_device/utils.py", line 143, in exec_sudo 2020-05-11 22:03:25.700 | raise e 2020-05-11 22:03:25.700 | diskimage_builder.block_device.exception.BlockDeviceSetupException: exec_sudo failed 2020-05-11 22:03:25.700 | INFO diskimage_builder.block_device.level0.localloop [-] loopdev detach 2020-05-11 22:03:25.701 | INFO diskimage_builder.block_device.utils [-] Calling [sudo losetup -d /dev/loop0] 2020-05-11 22:03:25.732 | INFO diskimage_builder.block_device.level0.localloop [-] Remove image file [/tmp/dib_image.muyw7t1h/image0.raw] 2020-05-11 22:03:25.734 | ERROR diskimage_builder.block_device.blockdevice [-] Rollback complete, exiting 2020-05-11 22:03:25.740 | Traceback (most recent call last): 2020-05-11 22:03:25.740 | File "/home/zuul/dib/bin/dib-block-device", line 8, in <module> 2020-05-11 22:03:25.740 | sys.exit(main()) 2020-05-11 22:03:25.740 | File "/home/zuul/dib/lib/python3.6/site-packages/diskimage_builder/block_device/cmd.py", line 120, in main 2020-05-11 22:03:25.740 | return bdc.main() 2020-05-11 22:03:25.740 | File "/home/zuul/dib/lib/python3.6/site-packages/diskimage_builder/block_device/cmd.py", line 115, in main 2020-05-11 22:03:25.740 | self.args.func() 2020-05-11 22:03:25.740 | File "/home/zuul/dib/lib/python3.6/site-packages/diskimage_builder/block_device/cmd.py", line 36, in cmd_create 2020-05-11 22:03:25.740 | self.bd.cmd_create() 2020-05-11 22:03:25.740 | File "/home/zuul/dib/lib/python3.6/site-packages/diskimage_builder/block_device/blockdevice.py", line 406, in cmd_create 2020-05-11 22:03:25.740 | node.create() 2020-05-11 22:03:25.740 | File "/home/zuul/dib/lib/python3.6/site-packages/diskimage_builder/block_device/level2/mkfs.py", line 133, in create 2020-05-11 22:03:25.740 | exec_sudo(cmd) 2020-05-11 22:03:25.740 | File "/home/zuul/dib/lib/python3.6/site-packages/diskimage_builder/block_device/utils.py", line 143, in exec_sudo 2020-05-11 22:03:25.740 | raise e 2020-05-11 22:03:25.740 | diskimage_builder.block_device.exception.BlockDeviceSetupException: exec_sudo failed Change-Id: I374f7f22f9e93ef35eb5813712ca59e75f0733e8 Related-Bug: #1698337
This commit is contained in:
parent
1a95c3f93f
commit
4a424ecabb
@ -206,7 +206,7 @@ class Partitioning(PluginBase):
|
|||||||
# now all the partitions are created, get device-mapper to
|
# now all the partitions are created, get device-mapper to
|
||||||
# mount them
|
# mount them
|
||||||
if not os.path.exists("/.dockerenv"):
|
if not os.path.exists("/.dockerenv"):
|
||||||
exec_sudo(["kpartx", "-avs", self.device_path])
|
exec_sudo(["kpartx", "-uvs", self.device_path])
|
||||||
else:
|
else:
|
||||||
# If running inside Docker, make our nodes manually,
|
# If running inside Docker, make our nodes manually,
|
||||||
# because udev will not be working. kpartx cannot run in
|
# because udev will not be working. kpartx cannot run in
|
||||||
|
@ -70,7 +70,7 @@ class TestGPT(tc.TestGraphGeneration):
|
|||||||
cmd_sequence = [
|
cmd_sequence = [
|
||||||
mock.call(parted_cmd),
|
mock.call(parted_cmd),
|
||||||
mock.call(['sync']),
|
mock.call(['sync']),
|
||||||
mock.call(['kpartx', '-avs', '/dev/loopX'])
|
mock.call(['kpartx', '-uvs', '/dev/loopX'])
|
||||||
]
|
]
|
||||||
self.assertEqual(mock_exec_sudo.call_count, len(cmd_sequence))
|
self.assertEqual(mock_exec_sudo.call_count, len(cmd_sequence))
|
||||||
mock_exec_sudo.assert_has_calls(cmd_sequence)
|
mock_exec_sudo.assert_has_calls(cmd_sequence)
|
||||||
|
@ -512,7 +512,7 @@ class TestLVM(tc.TestGraphGeneration):
|
|||||||
mock.call.create_mbr(),
|
mock.call.create_mbr(),
|
||||||
# now mount partitions
|
# now mount partitions
|
||||||
mock.call.sudo_part(['sync']),
|
mock.call.sudo_part(['sync']),
|
||||||
mock.call.sudo_part(['kpartx', '-avs', '/dev/fake/image0']),
|
mock.call.sudo_part(['kpartx', '-uvs', '/dev/fake/image0']),
|
||||||
# now create lvm environment
|
# now create lvm environment
|
||||||
mock.call.sudo_lvm(['pvcreate', '/dev/fake/root', '--force']),
|
mock.call.sudo_lvm(['pvcreate', '/dev/fake/root', '--force']),
|
||||||
mock.call.sudo_lvm(
|
mock.call.sudo_lvm(
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Fix cases of 'mkfs' failing because the partitions never showed up.
|
||||||
|
Partition mappings will now be updated instead of just adding them with
|
||||||
|
'kpartx'. That means that 'kpartx' will also remove devmappings for deleted
|
||||||
|
partitions.
|
Loading…
Reference in New Issue
Block a user