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 (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" 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 article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com 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 "RHEL project" 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 2026849

Summary: python3-dnf does not respect cacheonly
Product: Red Hat Enterprise Linux 9 Reporter: Tomáš Bajer <tbajer>
Component: dnfAssignee: Jaroslav Rohel <jrohel>
Status: CLOSED ERRATA QA Contact: Eva Mrakova <emrakova>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.0CC: james.antill, mbanas, pkratoch
Target Milestone: rcKeywords: AutoVerified, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-4.10.0-2.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1862970 Environment:
Last Closed: 2022-05-17 15:55:05 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 Tomáš Bajer 2021-11-26 08:33:17 UTC
This bug was initially created as a copy of Bug #1862970

I am copying this bug because: it behaves incorrectly in RHEL9 as well

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 9 errata-xmlrpc 2022-05-17 15:55:05 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 (new packages: dnf), 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:3957