neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone

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

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