fix order of dnf api operations so transactions don't fail (#50038)
* fix order of dnf api operations so transactions don't fail Previously dnf.base.fill_sack() was called before dnf.base.update_cache() which apparently breaks dnf transaction logic as per https://bugzilla.redhat.com/show_bug.cgi?id=1658694 Fixes #49060 Signed-off-by: Adam Miller <admiller@redhat.com> * add changelog and test case Signed-off-by: Adam Miller <admiller@redhat.com>pull/4420/head
parent
4c473ecef4
commit
ca084889c7
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- "dnf - fix update_cache combined with install operation to not cause dnf transaction failure"
|
|
@ -588,6 +588,15 @@ class DnfModule(YumDnf):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass # older versions of dnf didn't require this and don't have these methods
|
pass # older versions of dnf didn't require this and don't have these methods
|
||||||
try:
|
try:
|
||||||
|
if self.update_cache:
|
||||||
|
try:
|
||||||
|
base.update_cache()
|
||||||
|
except dnf.exceptions.RepoError as e:
|
||||||
|
self.module.fail_json(
|
||||||
|
msg="{0}".format(to_text(e)),
|
||||||
|
results=[],
|
||||||
|
rc=1
|
||||||
|
)
|
||||||
base.fill_sack(load_system_repo='auto')
|
base.fill_sack(load_system_repo='auto')
|
||||||
except dnf.exceptions.RepoError as e:
|
except dnf.exceptions.RepoError as e:
|
||||||
self.module.fail_json(
|
self.module.fail_json(
|
||||||
|
@ -601,15 +610,6 @@ class DnfModule(YumDnf):
|
||||||
if self.security:
|
if self.security:
|
||||||
key = {'advisory_type__eq': 'security'}
|
key = {'advisory_type__eq': 'security'}
|
||||||
base._update_security_filters = [base.sack.query().filter(**key)]
|
base._update_security_filters = [base.sack.query().filter(**key)]
|
||||||
if self.update_cache:
|
|
||||||
try:
|
|
||||||
base.update_cache()
|
|
||||||
except dnf.exceptions.RepoError as e:
|
|
||||||
self.module.fail_json(
|
|
||||||
msg="{0}".format(to_text(e)),
|
|
||||||
results=[],
|
|
||||||
rc=1
|
|
||||||
)
|
|
||||||
|
|
||||||
return base
|
return base
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
dnf:
|
dnf:
|
||||||
name: sos
|
name: sos
|
||||||
state: present
|
state: present
|
||||||
|
update_cache: True
|
||||||
register: dnf_result
|
register: dnf_result
|
||||||
|
|
||||||
- name: check sos with rpm
|
- name: check sos with rpm
|
||||||
|
|
Loading…
Reference in New Issue