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

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