|
|
1c4b60 |
From ea5054b0cab19f3fe09d7010f8721e7f18ae399e Mon Sep 17 00:00:00 2001
|
|
|
1c4b60 |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
|
1c4b60 |
Date: Mon, 2 May 2022 15:30:16 +0200
|
|
|
1c4b60 |
Subject: [PATCH] Correctly set vg_name after adding/removing a PV from a VG
|
|
|
1c4b60 |
|
|
|
1c4b60 |
Without setting the LVMPhysicalVolume.vg_name argument to None
|
|
|
1c4b60 |
after removing the PV from its VG, the PV is still considered
|
|
|
1c4b60 |
active and cannot be removed.
|
|
|
1c4b60 |
|
|
|
1c4b60 |
Resolves: rhbz#2081278
|
|
|
1c4b60 |
---
|
|
|
1c4b60 |
blivet/devices/lvm.py | 3 +++
|
|
|
1c4b60 |
tests/devices_test/lvm_test.py | 13 +++++++++++++
|
|
|
1c4b60 |
2 files changed, 16 insertions(+)
|
|
|
1c4b60 |
|
|
|
1c4b60 |
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
|
|
|
1c4b60 |
index 9c230f1b..a971da8e 100644
|
|
|
1c4b60 |
--- a/blivet/devices/lvm.py
|
|
|
1c4b60 |
+++ b/blivet/devices/lvm.py
|
|
|
1c4b60 |
@@ -385,6 +385,8 @@ class LVMVolumeGroupDevice(ContainerDevice):
|
|
|
1c4b60 |
if not parent.format.exists:
|
|
|
1c4b60 |
parent.format.free = self._get_pv_usable_space(parent)
|
|
|
1c4b60 |
|
|
|
1c4b60 |
+ parent.format.vg_name = self.name
|
|
|
1c4b60 |
+
|
|
|
1c4b60 |
def _remove_parent(self, parent):
|
|
|
1c4b60 |
# XXX It would be nice to raise an exception if removing this member
|
|
|
1c4b60 |
# would not leave enough space, but the devicefactory relies on it
|
|
|
1c4b60 |
@@ -395,6 +397,7 @@ class LVMVolumeGroupDevice(ContainerDevice):
|
|
|
1c4b60 |
super(LVMVolumeGroupDevice, self)._remove_parent(parent)
|
|
|
1c4b60 |
parent.format.free = None
|
|
|
1c4b60 |
parent.format.container_uuid = None
|
|
|
1c4b60 |
+ parent.format.vg_name = None
|
|
|
1c4b60 |
|
|
|
1c4b60 |
# We can't rely on lvm to tell us about our size, free space, &c
|
|
|
1c4b60 |
# since we could have modifications queued, unless the VG and all of
|
|
|
1c4b60 |
diff --git a/tests/devices_test/lvm_test.py b/tests/devices_test/lvm_test.py
|
|
|
1c4b60 |
index 5efa369e..59c027da 100644
|
|
|
1c4b60 |
--- a/tests/devices_test/lvm_test.py
|
|
|
1c4b60 |
+++ b/tests/devices_test/lvm_test.py
|
|
|
1c4b60 |
@@ -454,6 +454,19 @@ class LVMDeviceTest(unittest.TestCase):
|
|
|
1c4b60 |
pool.autoset_md_size(enforced=True)
|
|
|
1c4b60 |
self.assertEqual(pool.chunk_size, Size("128 KiB"))
|
|
|
1c4b60 |
|
|
|
1c4b60 |
+ def test_add_remove_pv(self):
|
|
|
1c4b60 |
+ pv1 = StorageDevice("pv1", fmt=blivet.formats.get_format("lvmpv"),
|
|
|
1c4b60 |
+ size=Size("1024 MiB"))
|
|
|
1c4b60 |
+ pv2 = StorageDevice("pv2", fmt=blivet.formats.get_format("lvmpv"),
|
|
|
1c4b60 |
+ size=Size("1024 MiB"))
|
|
|
1c4b60 |
+ vg = LVMVolumeGroupDevice("testvg", parents=[pv1])
|
|
|
1c4b60 |
+
|
|
|
1c4b60 |
+ vg._add_parent(pv2)
|
|
|
1c4b60 |
+ self.assertEqual(pv2.format.vg_name, vg.name)
|
|
|
1c4b60 |
+
|
|
|
1c4b60 |
+ vg._remove_parent(pv2)
|
|
|
1c4b60 |
+ self.assertEqual(pv2.format.vg_name, None)
|
|
|
1c4b60 |
+
|
|
|
1c4b60 |
|
|
|
1c4b60 |
class TypeSpecificCallsTest(unittest.TestCase):
|
|
|
1c4b60 |
def test_type_specific_calls(self):
|
|
|
1c4b60 |
--
|
|
|
1c4b60 |
2.34.3
|
|
|
1c4b60 |
|