[dnf] Make behavior/errors compatible for new DNF
Change: Extend the logic for custom error handling in the dnf module, so that on newer DNF (such as DNF that ships with modern Fedora 31 container images, and ships with RHEL 8.2) we report errors consistently with older DNF. Test Plan: Ran dnf integration tests against an old Fedora 31 container image and a brand new Fedora 32 container image; tess passed on both. Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
parent
b437236633
commit
f6cfcba346
3 changed files with 22 additions and 2 deletions
3
changelogs/fragments/dnf-4-2-18.yml
Normal file
3
changelogs/fragments/dnf-4-2-18.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
bugfixes:
|
||||
- dnf - Unified error messages when trying to install a nonexistent package with newer dnf (4.2.18) vs older dnf (4.2.9)
|
||||
- dnf - Unified error messages when trying to remove a wildcard name that is not currently installed, with newer dnf (4.2.18) vs older dnf (4.2.9)
|
|
@ -335,7 +335,10 @@ class DnfModule(YumDnf):
|
|||
For unhandled dnf.exceptions.Error scenarios, there are certain error
|
||||
messages we want to filter in an install scenario. Do that here.
|
||||
"""
|
||||
if to_text("no package matched") in to_text(error):
|
||||
if (
|
||||
to_text("no package matched") in to_text(error) or
|
||||
to_text("No match for argument:") in to_text(error)
|
||||
):
|
||||
return "No package {0} available.".format(spec)
|
||||
|
||||
return error
|
||||
|
@ -346,7 +349,10 @@ class DnfModule(YumDnf):
|
|||
messages we want to ignore in a removal scenario as known benign
|
||||
failures. Do that here.
|
||||
"""
|
||||
if 'no package matched' in to_native(error):
|
||||
if (
|
||||
'no package matched' in to_native(error) or
|
||||
'No match for argument:' in to_native(error)
|
||||
):
|
||||
return (False, "{0} is not installed".format(spec))
|
||||
|
||||
# Return value is tuple of:
|
||||
|
|
|
@ -699,3 +699,14 @@
|
|||
- "'vim-minimal' in rpm_output.stdout"
|
||||
when:
|
||||
- ansible_distribution == 'Fedora'
|
||||
|
||||
- name: Remove wildcard package that isn't installed
|
||||
dnf:
|
||||
name: firefox*
|
||||
state: absent
|
||||
register: wildcard_absent
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- wildcard_absent is successful
|
||||
- wildcard_absent is not changed
|
||||
|
|
Loading…
Reference in a new issue