From 900cd436f750db70613380663e5d11498474909e Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 11 Oct 2021 09:57:07 -0700 Subject: [PATCH] Handle all possible dnf group_install errors dnf has changed what it will raise when trying to group_install a nonexistent group, this adds handling for all of them. Related: rhbz#1947958 --- src/pylorax/api/projects.py | 3 ++- tests/pylorax/test_projects.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pylorax/api/projects.py b/src/pylorax/api/projects.py index 6411e236..04c42fbf 100644 --- a/src/pylorax/api/projects.py +++ b/src/pylorax/api/projects.py @@ -19,6 +19,7 @@ log = logging.getLogger("lorax-composer") from configparser import ConfigParser import dnf +from dnf.exceptions import MarkingError, CompsError from glob import glob import os import time @@ -235,7 +236,7 @@ def _depsolve(dbo, projects, groups): for name in groups: try: dbo.group_install(name, ["mandatory", "default"]) - except dnf.exceptions.MarkingError as e: + except (MarkingError, ValueError, CompsError) as e: install_errors.append(("Group %s" % (name), str(e))) for name, version in projects: diff --git a/tests/pylorax/test_projects.py b/tests/pylorax/test_projects.py index bce7a318..f97965cc 100644 --- a/tests/pylorax/test_projects.py +++ b/tests/pylorax/test_projects.py @@ -219,6 +219,10 @@ class ProjectsTest(unittest.TestCase): self.assertTrue("ctags" in names) # default package self.assertFalse("cmake" in names) # optional package + def test_groups_depsolve_error(self): + with self.assertRaises(ProjectsError): + projects_depsolve(self.dbo, [], ["notagroup"]) + class ConfigureTest(unittest.TestCase): @classmethod