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 0000000000000000000000000000000000000000..ab29983f7997c5eb6a030c4370ac13320300fdc9 --- /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 0000000000000000000000000000000000000000..7c8d6811fbb5646b5d619646d8a87605062a2f00 --- /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 8fdb59bac828a96a4754db6ecffb4697f677ad2d..0000000000000000000000000000000000000000 --- 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 2b50ae4710822e2f2f6f32867c70ff4c471d778e..f64fe90fbea5c6b68018671bda93d55002830796 100644 --- a/python-blivet.spec +++ b/python-blivet.spec @@ -3,7 +3,7 @@ Name: python-blivet Version: 3.2.2 -Release: 10 +Release: 11 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 @@ -31,6 +30,8 @@ Patch6004: backport-Remove-action-device-from-LVM-reject-list.patch Patch6005: backport-Ignore-devices-marked-as-hidden-in-sysfs-1856974.patch Patch6006: backport-Fix-reading-hidden-sysfs-attribute.patch Patch6007: backport-Fix-logging-information-about-ignoring-hidden-device.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 @@ -131,6 +132,12 @@ make PYTHON=%{__python2} DESTDIR=%{buildroot} install %doc README %changelog +* Tue Dec 27 2022 hanhuihui - 3.2.2-11 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:Exclude unusable disks from PartitionFactory + * Thu Sep 1 2022 yueyuankun - 3.2.2-10 - Type:bugfix - ID:NA