!96 [sync] PR-93: Exclude unusable disks from PartitionFactory
From: @openeuler-sync-bot Reviewed-by: @t_feng Signed-off-by: @t_feng
This commit is contained in:
commit
d9d2a68dee
@ -0,0 +1,33 @@
|
|||||||
|
From b20753ac6db14999270d71387309baa9270aa927 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
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:
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
From 61c09c6922748877595272479d68270fe442f3d4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
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[:]
|
||||||
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
From c9ddcf46a10738017fb442025c25863c25c20142 Mon Sep 17 00:00:00 2001
|
|
||||||
From: bitcoffeeiux <liuxin264@huawei.com>
|
|
||||||
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
|
|
||||||
|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Name: python-blivet
|
Name: python-blivet
|
||||||
Version: 3.4.2
|
Version: 3.4.2
|
||||||
Release: 4
|
Release: 5
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Summary: A python module for system storage configuration
|
Summary: A python module for system storage configuration
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
@ -19,13 +19,15 @@ 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: fix-allocate-partitions-threw-exception-when-raid.patch
|
|
||||||
Patch9001: 0001-Make-sure-we-mount-the-top-level-subvolume-when-moun.patch
|
Patch9001: 0001-Make-sure-we-mount-the-top-level-subvolume-when-moun.patch
|
||||||
%ifarch sw_64
|
%ifarch sw_64
|
||||||
Patch9002: blivet-3.4.2-sw.patch
|
Patch9002: blivet-3.4.2-sw.patch
|
||||||
%endif
|
%endif
|
||||||
patch9003: Incomplete-Chineseization-of-disk-mount.patch
|
patch9003: Incomplete-Chineseization-of-disk-mount.patch
|
||||||
|
|
||||||
|
patch6001: backport-Exclude-unusable-disks-from-PartitionFactory-1.patch
|
||||||
|
patch6002: backport-Exclude-unusable-disks-from-PartitionFactory-2.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
The python-blivet package is a python module for examining and modifying
|
The python-blivet package is a python module for examining and modifying
|
||||||
storage configuration.
|
storage configuration.
|
||||||
@ -125,6 +127,12 @@ make PYTHON=%{__python2} DESTDIR=%{buildroot} install
|
|||||||
%doc README.md
|
%doc README.md
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Dec 27 2022 hanhuihui<hanhuihui5@huawei.com> - 1:3.4.2-5
|
||||||
|
- Type:bugfix
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:Exclude unusable disks from PartitionFactory
|
||||||
|
|
||||||
* Fri Dec 09 2022 wanglimin<wanglimin@xfusion.com> - 1:3.4.2-4
|
* Fri Dec 09 2022 wanglimin<wanglimin@xfusion.com> - 1:3.4.2-4
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user