Merge "Use kpartx option to update partition mappings"

This commit is contained in:
Zuul 2020-07-07 08:27:29 +00:00 committed by Gerrit Code Review
commit b6d4bef9eb
4 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -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(

View File

@ -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.