[rhel7-branch 3/6] Raise UnusableConfigurationError when unusable configuration is detected.

dwlehman installerbot-noreply at redhat.com
Fri May 29 17:35:12 UTC 2015


From: David Lehman <dlehman at redhat.com>

The two cases included initially are a corrupt gpt disklabel and
multiple lvm volume groups with the same name.

Blivet cannot proceed in the corrupt gpt case because pyparted doesn't
support instantiating a parted.Disk if the underlying gpt disklabel is
corrupt.

The lvm case has several issues, the most basic being that lvm is not
designed to handle multiple volume groups with the same name. A user
would have to rename one of the same-named vgs manually in order to
make it possible to use both vgs.

(cherry picked from commit 0e1b6446c01f2acbf329e8859b8437c6206183f4)

Resolves: rhbz#1123450
---
 blivet/devicetree.py | 15 +++++++++++++--
 blivet/errors.py     |  4 ++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index c08b1c3..760bd3f 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -27,7 +27,7 @@
 import pprint
 import copy
 
-from .errors import CryptoError, DeviceError, DeviceTreeError, DiskLabelCommitError, DMError, FSError, InvalidDiskLabelError, LUKSError, MDRaidError, StorageError
+from .errors import CryptoError, DeviceError, DeviceTreeError, DiskLabelCommitError, DMError, FSError, InvalidDiskLabelError, LUKSError, MDRaidError, StorageError, UnusableConfigurationError
 from .devices import BTRFSDevice, BTRFSSubVolumeDevice, BTRFSVolumeDevice, BTRFSSnapShotDevice
 from .devices import DASDDevice, DMDevice, DMLinearDevice, DMRaidArrayDevice, DiskDevice
 from .devices import FcoeDiskDevice, FileDevice, LoopDevice, LUKSDevice
@@ -944,7 +944,12 @@ def addUdevPartitionDevice(self, info, disk=None):
                disk.format.type != "iso9660" and \
                not disk.format.hidden and \
                not self._isIgnoredDisk(disk):
-                raise DeviceTreeError("failed to scan disk %s" % disk.name)
+                if info.get("ID_PART_TABLE_TYPE") == "gpt":
+                    msg = "corrupt gpt disklabel on disk %s" % disk.name
+                else:
+                    msg = "failed to scan disk %s" % disk.name
+
+                raise UnusableConfigurationError(msg)
 
             # there's no need to filter partitions on members of multipaths or
             # fwraid members from lvm since multipath and dmraid are already
@@ -1527,6 +1532,12 @@ def handleUdevLVMPVFormat(self, info, device):
         if vg_device:
             vg_device.parents.append(device)
         else:
+            same_name = self.getDeviceByName(vg_name)
+            if isinstance(same_name, LVMVolumeGroupDevice) and \
+               not (all(self._isIgnoredDisk(d) for d in same_name.disks) or
+                    all(self._isIgnoredDisk(d) for d in device.disks)):
+                raise UnusableConfigurationError("multiple LVM volume groups with the same name")
+
             try:
                 vg_size = udev.device_get_vg_size(pv_info)
                 vg_free = udev.device_get_vg_free(pv_info)
diff --git a/blivet/errors.py b/blivet/errors.py
index 508e3ef..e48b649 100644
--- a/blivet/errors.py
+++ b/blivet/errors.py
@@ -153,6 +153,10 @@ class DeviceTreeError(StorageError):
 class DeviceNotFoundError(StorageError):
     pass
 
+class UnusableConfigurationError(StorageError):
+    """ User has an unusable initial storage configuration. """
+    pass
+
 # DeviceAction
 class DeviceActionError(StorageError):
     pass


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/756e30ef3add74b287534c81c04cc9ae7cc52264


More information about the anaconda-patches mailing list