Blame SOURCES/0009-Improve-error-message-printed-for-missing-dependecie.patch

3709d2
From 46335861073882b7162221fc0995dc1df3c67749 Mon Sep 17 00:00:00 2001
3709d2
From: Vojtech Trefny <vtrefny@redhat.com>
3709d2
Date: Fri, 6 Aug 2021 16:37:51 +0200
3709d2
Subject: [PATCH] Improve error message printed for missing dependecies
3709d2
3709d2
The existing error message can be confusing for people that don't
3709d2
know internals of blivet and libblockdev and the information what
3709d2
is actually broken or not installed on the system is missing
3709d2
completely. Example for LVM VDO with missing kvdo module:
3709d2
3709d2
Before:
3709d2
3709d2
device type lvmvdopool requires unavailable_dependencies:
3709d2
libblockdev lvm plugin (vdo technology)
3709d2
3709d2
After:
3709d2
3709d2
device type lvmvdopool requires unavailable_dependencies:
3709d2
libblockdev lvm plugin (vdo technology):
3709d2
libblockdev plugin lvm is loaded but some required technologies
3709d2
are not available (BD_LVM_TECH_VDO: Kernel module 'kvdo' not
3709d2
available)
3709d2
---
3709d2
 blivet/deviceaction.py       | 2 +-
3709d2
 blivet/tasks/availability.py | 4 ++--
3709d2
 2 files changed, 3 insertions(+), 3 deletions(-)
3709d2
3709d2
diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py
3709d2
index 56e29215..0458e4be 100644
3709d2
--- a/blivet/deviceaction.py
3709d2
+++ b/blivet/deviceaction.py
3709d2
@@ -173,7 +173,7 @@ class DeviceAction(util.ObjectID):
3709d2
     def _check_device_dependencies(self):
3709d2
         unavailable_dependencies = self.device.unavailable_dependencies
3709d2
         if unavailable_dependencies:
3709d2
-            dependencies_str = ", ".join(str(d) for d in unavailable_dependencies)
3709d2
+            dependencies_str = ", ".join("%s:\n%s" % (str(d), ", ".join(d.availability_errors)) for d in unavailable_dependencies)
3709d2
             raise DependencyError("device type %s requires unavailable_dependencies: %s" % (self.device.type, dependencies_str))
3709d2
 
3709d2
     def apply(self):
3709d2
diff --git a/blivet/tasks/availability.py b/blivet/tasks/availability.py
3709d2
index 1fd80590..1537f3f5 100644
3709d2
--- a/blivet/tasks/availability.py
3709d2
+++ b/blivet/tasks/availability.py
3709d2
@@ -224,7 +224,7 @@ class BlockDevMethod(Method):
3709d2
             try:
3709d2
                 self._tech_info.check_fn(tech, mode)
3709d2
             except GLib.GError as e:
3709d2
-                errors.append(str(e))
3709d2
+                errors.append("%s: %s" % (tech.value_name, e.message))
3709d2
         return errors
3709d2
 
3709d2
     def availability_errors(self, resource):
3709d2
@@ -242,7 +242,7 @@ class BlockDevMethod(Method):
3709d2
             tech_missing = self._check_technologies()
3709d2
             if tech_missing:
3709d2
                 return ["libblockdev plugin %s is loaded but some required "
3709d2
-                        "technologies are not available:\n%s" % (self._tech_info.plugin_name, tech_missing)]
3709d2
+                        "technologies are not available (%s)" % (self._tech_info.plugin_name, "; ".join(tech_missing))]
3709d2
             else:
3709d2
                 return []
3709d2
 
3709d2
-- 
3709d2
2.31.1
3709d2