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

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