neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone

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

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