[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 4/4] Handle vgs with duplicate names (#591469)



With the changed udev rules properly setting the vg-uuid for pvs to the
pvs vg id, rather then getting the vg uuid by vg-name, and thus using
the same uuid for all pvs even if there are duplicate vgs, the uuid
check in LVMVolumeGroupDevice._addDevice triggers.

Rather then making this throw an error, track that there is a duplicate
vg and make complete always return false (even if there happens to be
the right number of pvs in the 2 vgs combined) and then let
devicetree._handleInconsistencies() further handle this.
---
 storage/devices.py |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index ffd50c8..8894129 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -1759,6 +1759,7 @@ class LVMVolumeGroupDevice(DMDevice):
         self.lv_uuids = []
         self.lv_sizes = []
         self.lv_attr = []
+        self.hasDuplicate = False
 
         # circular references, here I come
         self._lvs = []
@@ -1880,7 +1881,12 @@ class LVMVolumeGroupDevice(DMDevice):
             raise ValueError("addDevice requires a PV arg")
 
         if self.uuid and device.format.vgUuid != self.uuid:
-            raise ValueError("UUID mismatch")
+            # this means there is another vg with the same name on the system
+            # set hasDuplicate which will make complete return False
+            # and let devicetree._handleInconsistencies() further handle this.
+            # Note we still add the device to our parents for use by
+            # devicetree._handleInconsistencies()
+            self.hasDuplicate = True
 
         if device in self.pvs:
             raise ValueError("device is already a member of this VG")
@@ -1889,7 +1895,7 @@ class LVMVolumeGroupDevice(DMDevice):
         device.addChild()
 
         # now see if the VG can be activated
-        if len(self.parents) == self.pvCount:
+        if self.complete:
             self.setup()
 
     def _removeDevice(self, device):
@@ -2124,6 +2130,10 @@ class LVMVolumeGroupDevice(DMDevice):
         """Check if the vg has all its pvs in the system
         Return True if complete.
         """
+        # vgs with duplicate names are overcomplete, which is not what we want
+        if self.hasDuplicate:
+            return False
+
         return len(self.pvs) == self.pvCount or not self.exists
 
 
-- 
1.7.0.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]