Bug 1658694

Summary: DNF Python API update_cache() breaks transaction check
Product: [Fedora] Fedora Reporter: Adam Miller <admiller>
Component: dnfAssignee: Jaroslav Mracek <jmracek>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 29CC: admiller, dmach, jmracek, mblaha, mhatina, packaging-team-maint, rpm-software-management, vmukhame
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-4.2.5-1.fc29 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-04-29 02:15:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Adam Miller 2018-12-12 16:51:18 UTC
Description of problem:
If I do an update_cache() via the DNF python API and then install a package, it causes issues with the transaction check.


Example with update_cache:
>>> import dnf
>>> base = dnf.Base()
>>> base.conf.read()
>>> base.read_all_repos()
>>> base.fill_sack()
>>> base.read_comps()
>>> base.update_cache()
True
>>> base.install("git")
1
>>> base.resolve()
True
>>> base.download_packages(base.transaction.install_set)
>>> base.do_transaction()
Error: transaction check vs depsolve:
coreutils-single conflicts with coreutils-8.30-6.fc29.x86_64
libxcrypt-common <= 4.3.3-3 is obsoleted by libxcrypt-4.4.1-1.fc29.x86_64
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/dnf/base.py", line 820, in do_transaction
    raise dnf.exceptions.TransactionCheckError(msg)
dnf.exceptions.TransactionCheckError: libxcrypt-common <= 4.3.3-3 is obsoleted by libxcrypt-4.4.1-1.fc29.x86_64
libxcrypt-common <= 4.3.3-3 is obsoleted by libxcrypt-4.4.1-1.fc29.x86_64


Example without update_cache:
>> import dnf
>>> base = dnf.Base()
>>> base.conf.read()
>>> base.read_all_repos()
>>> base.fill_sack()
<dnf.sack.Sack object at 0x7f685bc0ff68>
>>> base.read_comps()
<dnf.comps.Comps object at 0x7f685bc25f28>
>>> base.install("git")
1
>>> base.resolve()
True
>>> base.download_packages(base.transaction.install_set)
>>> base.do_transaction()
12

Version-Release number of selected component (if applicable):
dnf-4.0.9-1.fc29.noarch

How reproducible:
Always

Comment 1 Daniel Mach 2018-12-17 12:00:26 UTC
Can you run update_cache() before fill_sack()?

The steps should be as follows:
...
base.conf.read()       # read dnf.conf
base.read_all_repos()  # read /etc/yum.repos.d/*.repo
base.update_cache()    # update downloaded repodata cache
base.fill_sack()       # load repodata in memory
...


If that works, I'll keep this bug open as a use case for implementing states and workflow for the Base object.

Comment 2 Adam Miller 2018-12-17 17:52:46 UTC
Confirmed, this does work if the order of operations is changed.

I'm curious, is that expected order of operations documented anywhere?

Comment 3 Jaroslav Mracek 2019-03-04 15:37:02 UTC
Here is an update for documentation of update_metadata (https://github.com/rpm-software-management/dnf/pull/1344). 

New information
```Do not use after :meth:`fill_sack`, because information about packages will be not updated.```


Is it what you asked for?

Comment 4 Adam Miller 2019-03-11 13:45:43 UTC
Yes, thank you.

Comment 5 Fedora Update System 2019-04-25 16:43:33 UTC
dnf-4.2.5-1.fc29 libdnf-0.31.0-2.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-2612a121ba

Comment 6 Fedora Update System 2019-04-26 22:10:10 UTC
dnf-4.2.5-1.fc29, libdnf-0.31.0-2.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-2612a121ba

Comment 7 Fedora Update System 2019-04-29 02:15:10 UTC
dnf-4.2.5-1.fc29, libdnf-0.31.0-2.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.