[rhel7-branch 4/6] If allowing degraded array, attempt to start it (#1202877)

mulkieran installerbot-noreply at redhat.com
Wed Jun 3 22:17:40 UTC 2015


From: mulhern <amulhern at redhat.com>

Resolves: rhbz#1090009
Related: rhbz#1202877

(cherry picked from commit ddb2e1756600d918df9df10384deb3364a9bbc3b)

If we can't get the name for the array, that's probably because the
array is in a state such that udevadm doesn't have the info. Try to
run the array and get the info again.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/devicetree.py | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 9870348..dbcbfd8 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -1148,11 +1148,31 @@ def addUdevDevice(self, info):
         log.info("scanning %s (%s)...", name, sysfs_path)
         device = self.getDeviceByName(name)
         if device is None and udev.device_is_md(info):
-            device = self.getDeviceByName(
-               udev.device_get_md_name(info),
-               incomplete=flags.allow_imperfect_devices)
+
+            # If the md name is None, then some udev info is missing. Likely,
+            # this is because the array is degraded, and mdadm has deactivated
+            # it. Try to activate it and re-get the udev info.
+            if flags.allow_imperfect_devices and udev.device_get_md_name(info) is None:
+                devname = udev.device_get_devname(info)
+                if devname:
+                    try:
+                        mdraid.mdrun(devname)
+                    except MDRaidError as e:
+                        log.warning("Failed to start possibly degraded md array: %s", e)
+                    else:
+                        udev.settle()
+                        info = udev.get_device(sysfs_path)
+                else:
+                    log.warning("Failed to get devname for possibly degraded md array.")
+
+            md_name = udev.device_get_md_name(info)
+            if md_name is None:
+                log.warning("No name for possibly degraded md array.")
+            else:
+                device = self.getDeviceByName(md_name, incomplete=flags.allow_imperfect_devices)
+
             if device and not isinstance(device, MDRaidArrayDevice):
-                # make sure any device we found is an md device
+                log.warning("Found device %s, but it turns out not be an md array device after all.", device.name)
                 device = None
 
         if device and device.isDisk and \


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


More information about the anaconda-patches mailing list