From a0f963143d7070e3468df22d559c9cc32adb85e1 Mon Sep 17 00:00:00 2001 From: han_hui_hui Date: Tue, 27 Dec 2022 03:34:47 +0000 Subject: [PATCH] Exclude unusable disks from PartitionFactory --- ...usable-disks-from-PartitionFactory-1.patch | 33 +++++++++++++ ...usable-disks-from-PartitionFactory-2.patch | 49 +++++++++++++++++++ ...partitions-threw-exception-when-raid.patch | 26 ---------- python-blivet.spec | 12 ++++- 4 files changed, 92 insertions(+), 28 deletions(-) create mode 100644 backport-Exclude-unusable-disks-from-PartitionFactory-1.patch create mode 100644 backport-Exclude-unusable-disks-from-PartitionFactory-2.patch delete mode 100644 huawei-fix-allocate-partitions-threw-exception-when-raid.patch diff --git a/backport-Exclude-unusable-disks-from-PartitionFactory-1.patch b/backport-Exclude-unusable-disks-from-PartitionFactory-1.patch new file mode 100644 index 0000000..ab29983 --- /dev/null +++ b/backport-Exclude-unusable-disks-from-PartitionFactory-1.patch @@ -0,0 +1,33 @@ +From b20753ac6db14999270d71387309baa9270aa927 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Thu, 13 Jan 2022 17:27:08 +0100 +Subject: [PATCH] Show better error when using unitialized disk in + do_partitioning + +Now all we get is "KeyError: '/dev/sda'" for example. + +Related: rhbz#2017432 + +Conflict:NA +Reference:https://github.com/storaged-project/blivet/commit/b20753ac6db14999270d71387309baa9270aa927 + +--- + blivet/partitioning.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/blivet/partitioning.py b/blivet/partitioning.py +index f12ec3c9e..ce77e4eb7 100644 +--- a/blivet/partitioning.py ++++ b/blivet/partitioning.py +@@ -764,7 +764,10 @@ def allocate_partitions(storage, disks, partitions, freespace, boot_disk=None): + growth = 0 # in sectors + # loop through disks + for _disk in req_disks: +- disklabel = disklabels[_disk.path] ++ try: ++ disklabel = disklabels[_disk.path] ++ except KeyError: ++ raise PartitioningError("Requested disk %s doesn't have a usable disklabel for partitioning" % _disk.name) + best = None + current_free = free + try: diff --git a/backport-Exclude-unusable-disks-from-PartitionFactory-2.patch b/backport-Exclude-unusable-disks-from-PartitionFactory-2.patch new file mode 100644 index 0000000..7c8d681 --- /dev/null +++ b/backport-Exclude-unusable-disks-from-PartitionFactory-2.patch @@ -0,0 +1,49 @@ +From 61c09c6922748877595272479d68270fe442f3d4 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Thu, 13 Jan 2022 16:53:30 +0100 +Subject: [PATCH] Exclude unusable disks from PartitionFactory + +We already remove disks that are too small or not partitionable +in the PartitionSetFactory which allows us to create partitions +on multipath devices where Anaconda tells us to use both the mpath +device and the backing disks, we should do the same for the +PartitionFactory. + +Resolves: rhbz#2017432 + +Conflict:NA +Reference:https://github.com/storaged-project/blivet/commit/61c09c6922748877595272479d68270fe442f3d4 + +--- + blivet/devicefactory.py | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/blivet/devicefactory.py b/blivet/devicefactory.py +index e6b8c1fad..2499484bf 100644 +--- a/blivet/devicefactory.py ++++ b/blivet/devicefactory.py +@@ -1065,6 +1065,24 @@ def _get_new_device(self, *args, **kwargs): + **kwargs) + return device + ++ def _configure(self): ++ disks = [] ++ for disk in self.disks: ++ if not disk.partitioned: ++ log.debug("removing unpartitioned disk %s", disk.name) ++ elif not disk.format.supported: ++ log.debug("removing disk with unsupported format %s", disk.name) ++ else: ++ disks.append(disk) ++ ++ if not disks: ++ raise DeviceFactoryError("no usable disks specified for partition") ++ ++ log.debug("setting new factory disks to %s", [d.name for d in disks]) ++ self.disks = disks # pylint: disable=attribute-defined-outside-init ++ ++ super(PartitionFactory, self)._configure() ++ + def _set_disks(self): + self.raw_device.req_disks = self.disks[:] + diff --git a/huawei-fix-allocate-partitions-threw-exception-when-raid.patch b/huawei-fix-allocate-partitions-threw-exception-when-raid.patch deleted file mode 100644 index 8fdb59b..0000000 --- a/huawei-fix-allocate-partitions-threw-exception-when-raid.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 00cdf3f0ace5f4d5407dbf610f056fef667c1cd2 Mon Sep 17 00:00:00 2001 -From: bitcoffeeiux -Date: Fri, 4 Jun 2021 02:23:37 +0800 -Subject: [PATCH] function allocate_partitions threw an exception - while adding /boot partitions to a RAID disk - ---- - blivet/partitioning.py | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/blivet/partitioning.py b/blivet/partitioning.py -index 40644f9..8219841 100644 ---- a/blivet/partitioning.py -+++ b/blivet/partitioning.py -@@ -758,6 +758,8 @@ def allocate_partitions(storage, disks, partitions, freespace, boot_disk=None): - growth = 0 # in sectors - # loop through disks - for _disk in req_disks: -+ if _disk.path not in disklabels: -+ continue - disklabel = disklabels[_disk.path] - best = None - current_free = free --- -2.27.0 - diff --git a/python-blivet.spec b/python-blivet.spec index d68a346..5124d68 100644 --- a/python-blivet.spec +++ b/python-blivet.spec @@ -3,7 +3,7 @@ Name: python-blivet Version: 3.2.2 -Release: 11 +Release: 12 Epoch: 1 Summary: A python module for system storage configuration License: LGPLv2+ @@ -23,7 +23,6 @@ Patch9000: fix-the-long-hostname.patch Patch6000: backport-Account-for-pmspare-grow-when-adjusting-thinpool-metadata.patch Patch6001: backport-Close-fd-if-it-fails-to-read-the-device.patch Patch6002: backport-Fix-UnboundLocalError.patch -Patch9001: huawei-fix-allocate-partitions-threw-exception-when-raid.patch Patch6003: backport-Convert-LVM-filter-lists-to-sets.patch Patch6004: backport-Remove-action-device-from-LVM-reject-list.patch @@ -33,6 +32,9 @@ Patch6006: backport-Fix-reading-hidden-sysfs-attribute.patch Patch6007: backport-Fix-logging-information-about-ignoring-hidden-device.patch Patch9002: Incomplete-Chineseization-of-disk-mount.patch +Patch6008: backport-Exclude-unusable-disks-from-PartitionFactory-1.patch +Patch6009: backport-Exclude-unusable-disks-from-PartitionFactory-2.patch + %description The python-blivet package is a python module for examining and modifying storage configuration. @@ -132,6 +134,12 @@ make PYTHON=%{__python2} DESTDIR=%{buildroot} install %doc README %changelog +* Tue Dec 27 2022 hanhuihui - 1:3.2.2-12 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:Exclude unusable disks from PartitionFactory + * Thu Dec 08 2022 wanglimin - 1:3.2.2-11 - Type:bugfix - ID:NA -- Gitee