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