Do not remove PVs from devices file if disabled or doesn't exist
Resolves: RHEL-84662
This commit is contained in:
parent
e149a4deb2
commit
17a29e1441
@ -0,0 +1,83 @@
|
||||
From 3e3b8d415ca50c4feaaf8d3688f0ebda2522d866 Mon Sep 17 00:00:00 2001
|
||||
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||
Date: Mon, 20 Jan 2025 13:02:50 +0100
|
||||
Subject: [PATCH] Do not remove PVs from devices file if disabled or doesn't
|
||||
exists
|
||||
|
||||
When the file doesn't exists the 'lvmdevices --deldev' call will
|
||||
fail but it will still create the devices file. This means we now
|
||||
have an empty devices file and all subsequent LVM calls will fail.
|
||||
|
||||
Resolves: RHEL-84662
|
||||
---
|
||||
blivet/formats/lvmpv.py | 5 +++++
|
||||
tests/unit_tests/formats_tests/lvmpv_test.py | 22 ++++++++++++++++++++
|
||||
2 files changed, 27 insertions(+)
|
||||
|
||||
diff --git a/blivet/formats/lvmpv.py b/blivet/formats/lvmpv.py
|
||||
index 51fa4a3c8..f5d71dbd1 100644
|
||||
--- a/blivet/formats/lvmpv.py
|
||||
+++ b/blivet/formats/lvmpv.py
|
||||
@@ -166,6 +166,11 @@ def lvmdevices_remove(self):
|
||||
if not lvm.HAVE_LVMDEVICES:
|
||||
raise PhysicalVolumeError("LVM devices file feature is not supported")
|
||||
|
||||
+ if not os.path.exists(lvm.LVM_DEVICES_FILE):
|
||||
+ log.debug("Not removing %s from devices file: %s doesn't exist",
|
||||
+ self.device, lvm.LVM_DEVICES_FILE)
|
||||
+ return
|
||||
+
|
||||
try:
|
||||
blockdev.lvm.devices_delete(self.device)
|
||||
except blockdev.LVMError as e:
|
||||
diff --git a/tests/unit_tests/formats_tests/lvmpv_test.py b/tests/unit_tests/formats_tests/lvmpv_test.py
|
||||
index 6490c7d48..54a59026d 100644
|
||||
--- a/tests/unit_tests/formats_tests/lvmpv_test.py
|
||||
+++ b/tests/unit_tests/formats_tests/lvmpv_test.py
|
||||
@@ -41,6 +41,11 @@ def test_lvm_devices(self):
|
||||
|
||||
mock["blockdev"].lvm.devices_add.assert_not_called()
|
||||
|
||||
+ # LVM devices file not enabled/supported -> devices_delete should not be called
|
||||
+ fmt._destroy()
|
||||
+
|
||||
+ mock["blockdev"].lvm.devices_delete.assert_not_called()
|
||||
+
|
||||
with self.patches() as mock:
|
||||
# LVM devices file enabled and devices file exists -> devices_add should be called
|
||||
mock["lvm"].HAVE_LVMDEVICES = True
|
||||
@@ -50,6 +55,11 @@ def test_lvm_devices(self):
|
||||
|
||||
mock["blockdev"].lvm.devices_add.assert_called_with("/dev/test")
|
||||
|
||||
+ # LVM devices file enabled and devices file exists -> devices_delete should be called
|
||||
+ fmt._destroy()
|
||||
+
|
||||
+ mock["blockdev"].lvm.devices_delete.assert_called_with("/dev/test")
|
||||
+
|
||||
with self.patches() as mock:
|
||||
# LVM devices file enabled and devices file doesn't exist
|
||||
# and no existing VGs present -> devices_add should be called
|
||||
@@ -61,6 +71,12 @@ def test_lvm_devices(self):
|
||||
|
||||
mock["blockdev"].lvm.devices_add.assert_called_with("/dev/test")
|
||||
|
||||
+ # LVM devices file enabled but devices file doesn't exist
|
||||
+ # -> devices_delete should not be called
|
||||
+ fmt._destroy()
|
||||
+
|
||||
+ mock["blockdev"].lvm.devices_delete.assert_not_called()
|
||||
+
|
||||
with self.patches() as mock:
|
||||
# LVM devices file enabled and devices file doesn't exist
|
||||
# and existing VGs present -> devices_add should not be called
|
||||
@@ -71,3 +87,9 @@ def test_lvm_devices(self):
|
||||
fmt._create()
|
||||
|
||||
mock["blockdev"].lvm.devices_add.assert_not_called()
|
||||
+
|
||||
+ # LVM devices file enabled but devices file doesn't exist
|
||||
+ # -> devices_delete should not be called
|
||||
+ fmt._destroy()
|
||||
+
|
||||
+ mock["blockdev"].lvm.devices_delete.assert_not_called()
|
@ -23,7 +23,7 @@ Version: 3.6.0
|
||||
|
||||
#%%global prerelease .b2
|
||||
# prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2
|
||||
Release: 23%{?prerelease}%{?dist}
|
||||
Release: 24%{?prerelease}%{?dist}
|
||||
Epoch: 1
|
||||
License: LGPLv2+
|
||||
%global realname blivet
|
||||
@ -62,6 +62,7 @@ Patch28: 0029-Align-sizes-up-for-growable-LVs.patch
|
||||
Patch29: 0030-mod_pass_in_stratis_test.patch
|
||||
Patch30: 0031-Fix_running_tests_in_FIPS_mode.patch
|
||||
Patch31: 0032-Set-persistent-allow-discards-flag-for-new-LUKS-devices.patch
|
||||
Patch32: 0033-Do-not-remove-PVs-from-devices-file-if-disabled-or-doesnt-exist.patch
|
||||
|
||||
# Versions of required components (done so we make sure the buildrequires
|
||||
# match the requires versions of things).
|
||||
@ -225,6 +226,10 @@ configuration.
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Thu Mar 27 2025 Vojtech Trefny <vtrefny@redhat.com> - 3.6.0-24
|
||||
- Do not remove PVs from devices file if disabled or doesn't exist
|
||||
Resolves: RHEL-84662
|
||||
|
||||
* Tue Mar 11 2025 Vojtech Trefny <vtrefny@redhat.com> - 3.6.0-23
|
||||
- Set persistent allow-discards flag for newly created LUKS devices
|
||||
Resolves: RHEL-82430
|
||||
|
Loading…
Reference in New Issue
Block a user