From 8d5c25023467e5039ffdf32dcc79eb7f171ebce5 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Wed, 5 Apr 2023 18:17:50 +0200 Subject: [PATCH] dnf5: use the logs API to determine transaction problems (#80401) --- changelogs/fragments/dnf5-logs-api.yml | 2 ++ lib/ansible/modules/dnf5.py | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/dnf5-logs-api.yml diff --git a/changelogs/fragments/dnf5-logs-api.yml b/changelogs/fragments/dnf5-logs-api.yml new file mode 100644 index 00000000000..10a19cc8696 --- /dev/null +++ b/changelogs/fragments/dnf5-logs-api.yml @@ -0,0 +1,2 @@ +bugfixes: + - dnf5 - use the logs API to determine transaction problems diff --git a/lib/ansible/modules/dnf5.py b/lib/ansible/modules/dnf5.py index 5e4b3d64ab1..e25c79142d4 100644 --- a/lib/ansible/modules/dnf5.py +++ b/lib/ansible/modules/dnf5.py @@ -629,11 +629,12 @@ class Dnf5Module(YumDnf): if transaction.get_problems(): failures = [] - for log in transaction.get_resolve_logs_as_strings(): - if log.startswith("No match for argument") and self.state in {"install", "present", "latest"}: - failures.append("No package {} available.".format(log.rsplit(' ', 1)[-1])) + for log_event in transaction.get_resolve_logs(): + if log_event.get_problem() == libdnf5.base.GoalProblem_NOT_FOUND and self.state in {"install", "present", "latest"}: + # NOTE dnf module compat + failures.append("No package {} available.".format(log_event.get_spec())) else: - failures.append(log) + failures.append(log_event.to_string()) if transaction.get_problems() & libdnf5.base.GoalProblem_SOLVER_ERROR != 0: msg = "Depsolve Error occurred"