Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear VG UUID from PVs after removing the PV (#2278058) #1230

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading