Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (). If you're a Red Hat customer, please continue to file support cases via the . If you're not, please head to the "" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult . That failing, please send an e-mail to the RH Jira admins at to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1862970

Summary: python3-dnf does not respect cacheonly
Product: Red Hat Enterprise Linux 8 Reporter: Michael Mráka <mmraka>
Component: dnfAssignee: Jaroslav Rohel <jrohel>
Status: CLOSED ERRATA QA Contact: Tomáš Bajer <tbajer>
Severity: unspecified Docs Contact:
Priority: high
Version: 8.2CC: james.antill, jdostal, jrohel, lmiksik, pkratoch, smcdowel, tbajer, tlestach
Target Milestone: rcKeywords: Triaged
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: Unspecified
OS: Unspecified
Whiteboard:
dnf-4.7.0-5.el8 If docs needed, set a value
---
: 2026849 (view as bug list)
2022-05-10 15:23:43 UTC Bug
--- ---
---
---
--- RHEL 7.3 requirements from Atomic Host:
---

Description Michael Mráka 2020-08-03 11:02:42 UTC
Description of problem:
python3-dnf downloads metadata even if cacheonly is set.

Version-Release number of selected component (if applicable):
dnf-4.2.17-7.el8_2.noarch
(and dnf-4.2.23-1.git.9175.126d861.el8.noarch)

How reproducible:
always

Steps to Reproduce:
1. cat >cacheonly.py <<EOF
import dnf
import os
import sys

cacheonly = True if len(sys.argv) > 1 else False
CENTOS='http://mirror.centos.org/centos-8/8/BaseOS/x86_64/os/'

with dnf.base.Base() as base:
 base.conf.module_platform_id = 'platform:el8'
 base.conf.installroot = os.path.abspath('./instalroot')
 base.conf.cachedir = os.path.abspath('./instalroot/var/cache/dnf')
 base.conf.cacheonly = cacheonly
 repo = base.repos.add_new_repo('baseos', base.conf, baseurl=[CENTOS], skip_if_unavailable=True)
 base.fill_sack(load_system_repo=False)
 print("Cacheonly:", base.conf.cacheonly)
 print("Loaded repos:", len(base.repos))
 print("Loaded packages:", len(base.sack.query()))
EOF
2. python3 ./cacheonly.py
3. ls -l instalroot/var/cache/dnf/
4. rm -rf instalroot/var/cache/dnf/*
4. python3 ./cacheonly.py cacheonly
5. ls -ll instalroot/var/cache/dnf/

Actual results:

Cacheonly: False
Loaded repos: 1
Loaded packages: 1675
drwxr-xr-x. 3 michael michael 22 Aug 3 12:56 baseos-7ce9369cf52b8f9b
-rw-rw-r--. 1 michael michael 1299280 Aug 3 12:56 baseos-filenames.solvx
-rw-rw-r--. 1 michael michael 1372757 Aug 3 12:56 baseos.solv

Cacheonly: True
Loaded repos: 1
Loaded packages: 1675
drwxr-xr-x. 3 michael michael 22 Aug 3 12:59 baseos-7ce9369cf52b8f9b
-rw-rw-r--. 1 michael michael 1299280 Aug 3 12:59 baseos-filenames.solvx
-rw-rw-r--. 1 michael michael 1372757 Aug 3 12:59 baseos.solv


Expected results:
Dnf doesn't download metadata in the second case and thus fails to load it.

Additional info:

Comment 7 Jaroslav Rohel 2021-11-05 09:39:54 UTC
PR https://github.com/rpm-software-management/dnf/pull/1792

Comment 16 errata-xmlrpc 2022-05-10 15:23:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (dnf bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2051