Convert LVM filter lists to sets and Remove action device from LVM reject list

Signed-off-by: yanan-rock <yanan@huawei.com>
This commit is contained in:
yanan-rock 2021-10-29 12:05:18 -04:00
parent b9aab5f8e4
commit 6880ae9051
3 changed files with 92 additions and 1 deletions

View File

@ -0,0 +1,57 @@
From 18167263c3bfd3a99a38fc88a7e139a313c249e7 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Mon, 24 May 2021 14:49:12 +0200
Subject: [PATCH] Convert LVM filter lists to sets
To prevent devices being added multiple times and removed only
once.
Related: rhbz#1955942
---
blivet/devicelibs/lvm.py | 12 ++++++------
tests/devicetree_test.py | 6 +++---
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/blivet/devicelibs/lvm.py b/blivet/devicelibs/lvm.py
index d56a76edc..c4b237a2c 100644
--- a/blivet/devicelibs/lvm.py
+++ b/blivet/devicelibs/lvm.py
@@ -70,8 +70,8 @@
# Theoretically we can handle all that can be handled with the LVM --config
# argument. For every time we call an lvm_cc (lvm compose config) funciton
# we regenerate the config_args with all global info.
-config_args_data = {"filterRejects": [], # regular expressions to reject.
- "filterAccepts": []} # regexp to accept
+config_args_data = {"filterRejects": set(), # regular expressions to reject.
+ "filterAccepts": set()} # regexp to accept
def _set_global_config():
@@ -119,7 +119,7 @@ def fn_with_refresh(*args, **kwargs):
def lvm_cc_addFilterRejectRegexp(regexp):
""" Add a regular expression to the --config string."""
log.debug("lvm filter: adding %s to the reject list", regexp)
- config_args_data["filterRejects"].append(regexp)
+ config_args_data["filterRejects"].add(regexp)
@needs_config_refresh
@@ -128,15 +128,15 @@ def lvm_cc_removeFilterRejectRegexp(regexp):
log.debug("lvm filter: removing %s from the reject list", regexp)
try:
config_args_data["filterRejects"].remove(regexp)
- except ValueError:
+ except KeyError:
log.debug("%s wasn't in the reject list", regexp)
return
@needs_config_refresh
def lvm_cc_resetFilter():
- config_args_data["filterRejects"] = []
- config_args_data["filterAccepts"] = []
+ config_args_data["filterRejects"] = set()
+ config_args_data["filterAccepts"] = set()
def determine_parent_lv(internal_lv, lvs, lv_info):

View File

@ -0,0 +1,24 @@
From f0862e211eb9949dea1a5ccb151e7d099b9585e6 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Mon, 24 May 2021 13:35:39 +0200
Subject: [PATCH] Remove action device from LVM reject list
Because the device doesn't depend on itself the existing code
won't remove the device we are trying to modify from the list.
Resolves: rhbz#1955942
---
blivet/actionlist.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/blivet/actionlist.py b/blivet/actionlist.py
index d03e32b95..2de3fed33 100644
--- a/blivet/actionlist.py
+++ b/blivet/actionlist.py
@@ -260,6 +260,7 @@ def _pre_process(self, devices=None):
log.debug("action: %s", action)
# Remove lvm filters for devices we are operating on
+ lvm.lvm_cc_removeFilterRejectRegexp(action.device.name)
for device in (d for d in devices if d.depends_on(action.device)):
lvm.lvm_cc_removeFilterRejectRegexp(device.name)

View File

@ -3,7 +3,7 @@
Name: python-blivet Name: python-blivet
Version: 3.3.2 Version: 3.3.2
Release: 2 Release: 3
Epoch: 1 Epoch: 1
Summary: A python module for system storage configuration Summary: A python module for system storage configuration
License: LGPLv2+ License: LGPLv2+
@ -20,6 +20,9 @@ BuildRequires: python2-devel python2-setuptools
Patch0: 0001-force-lvm-plugin.patch Patch0: 0001-force-lvm-plugin.patch
Patch1: fix-the-long-hostname.patch Patch1: fix-the-long-hostname.patch
Patch9000: huawei-fix-allocate-partitions-threw-exception-when-raid.patch Patch9000: huawei-fix-allocate-partitions-threw-exception-when-raid.patch
Patch6000: backport-Convert-LVM-filter-lists-to-sets.patch
Patch6001: backport-Remove-action-device-from-LVM-reject-list.patch
%description %description
@ -121,6 +124,13 @@ make PYTHON=%{__python2} DESTDIR=%{buildroot} install
%doc README.md %doc README.md
%changelog %changelog
* Sat Oct 30 2021 yanan <yanan@huawei.com> - 3.3.2-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:Convert LVM filter lists to sets
Remove action device from LVM reject list
* Thu Jun 10 2021 liuxin <liuxin264@huawei.com> - 3.3.2-2 * Thu Jun 10 2021 liuxin <liuxin264@huawei.com> - 3.3.2-2
- Type:bugfix - Type:bugfix
- ID:NA - ID:NA