Skip to content

Commit

Permalink
Merge pull request #1230 from vojtechtrefny/3.10-devel_vg-remove-pv-uuid
Browse files Browse the repository at this point in the history
Clear VG UUID from PVs after removing the PV (#2278058)
  • Loading branch information
vojtechtrefny authored May 6, 2024
2 parents db86dc1 + 5b358f0 commit f92f32c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions blivet/devices/lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ def remove_hook(self, modparent=True):
if modparent:
for pv in self.pvs:
pv.format.vg_name = None
pv.format.vg_uuid = None

super(LVMVolumeGroupDevice, self).remove_hook(modparent=modparent)

Expand All @@ -677,6 +678,7 @@ def add_hook(self, new=True):

for pv in self.pvs:
pv.format.vg_name = self.name
pv.format.vg_uuid = self.uuid

def populate_ksdata(self, data):
super(LVMVolumeGroupDevice, self).populate_ksdata(data)
Expand Down
9 changes: 9 additions & 0 deletions tests/storage_tests/devices_test/lvm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def test_lvm_basic(self):
self.assertIsNotNone(vg.format)
self.assertIsNone(vg.format.type)
self.assertEqual(pv.format.vg_name, vg.name)
self.assertEqual(pv.format.vg_uuid, vg.uuid)
self.assertEqual(len(vg.parents), 1)
self.assertEqual(vg.parents[0], pv)

Expand All @@ -93,6 +94,13 @@ def test_lvm_basic(self):
self.assertEqual(len(lv.parents), 1)
self.assertEqual(lv.parents[0], vg)

self.storage.destroy_device(lv)
self.storage.destroy_device(vg)

pv = self.storage.devicetree.get_device_by_path(self.vdevs[0] + "1")
self.assertIsNone(pv.format.vg_name)
self.assertIsNone(pv.format.vg_uuid)

def test_lvm_thin(self):
disk = self.storage.devicetree.get_device_by_path(self.vdevs[0])
self.assertIsNotNone(disk)
Expand Down Expand Up @@ -398,6 +406,7 @@ def test_lvm_pvs_add_remove(self):
self.storage.devicetree.actions.add(ac)

self.assertIsNone(pv1.format.vg_name)
self.assertIsNone(pv1.format.vg_uuid)

# schedule also removing the lvmpv format from the PV
ac = blivet.deviceaction.ActionDestroyFormat(pv1)
Expand Down
3 changes: 2 additions & 1 deletion tests/unit_tests/devices_test/lvm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,14 @@ def test_add_remove_pv(self):
size=Size("1024 MiB"))
pv2 = StorageDevice("pv2", fmt=blivet.formats.get_format("lvmpv"),
size=Size("1024 MiB"))
vg = LVMVolumeGroupDevice("testvg", parents=[pv1])
vg = LVMVolumeGroupDevice("testvg", parents=[pv1], uuid="b0bf62ba-2a96-437e-8299-b0c5fffc43bb")

vg._add_parent(pv2)
self.assertEqual(pv2.format.vg_name, vg.name)

vg._remove_parent(pv2)
self.assertEqual(pv2.format.vg_name, None)
self.assertEqual(pv2.format.vg_uuid, None)

def test_device_id(self):
pv = StorageDevice("pv1", fmt=blivet.formats.get_format("lvmpv"),
Expand Down

0 comments on commit f92f32c

Please sign in to comment.