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/fix-allocate-partitions-threw-exception-when-raid.patch b/fix-allocate-partitions-threw-exception-when-raid.patch deleted file mode 100644 index ca322b565ef2b540d2c26e98c03da39a19f6ea5b..0000000000000000000000000000000000000000 --- a/fix-allocate-partitions-threw-exception-when-raid.patch +++ /dev/null @@ -1,26 +0,0 @@ -From c9ddcf46a10738017fb442025c25863c25c20142 Mon Sep 17 00:00:00 2001 -From: bitcoffeeiux -Date: Fri, 4 Jun 2021 04:27:53 +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 53f9cc3..0b544be 100644 ---- a/blivet/partitioning.py -+++ b/blivet/partitioning.py -@@ -764,6 +764,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 e9ba19b577a37537c92fe3b6b094de6f5b7f39e5..372c7634b9522240d0a882ddeaf965542fdc031d 100644 --- a/python-blivet.spec +++ b/python-blivet.spec @@ -3,7 +3,7 @@ Name: python-blivet Version: 3.4.2 -Release: 3 +Release: 4 Epoch: 1 Summary: A python module for system storage configuration License: LGPLv2+ @@ -19,13 +19,13 @@ BuildRequires: python2-devel python2-setuptools Patch0: 0001-force-lvm-plugin.patch Patch1: fix-the-long-hostname.patch -Patch9000: fix-allocate-partitions-threw-exception-when-raid.patch Patch9001: 0001-Make-sure-we-mount-the-top-level-subvolume-when-moun.patch %ifarch sw_64 Patch9002: blivet-3.4.2-sw.patch %endif - +Patch6001: backport-Exclude-unusable-disks-from-PartitionFactory-1.patch +Patch6002: backport-Exclude-unusable-disks-from-PartitionFactory-2.patch %description The python-blivet package is a python module for examining and modifying @@ -126,6 +126,9 @@ make PYTHON=%{__python2} DESTDIR=%{buildroot} install %doc README.md %changelog +* Tue Dec 27 2022 hanhuihui - 3.4.2-4 +- Exclude unusable disks from PartitionFactory + * Tue Oct 18 2022 wuzx - 3.4.2-3 - add sw64 patch