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

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