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 2035577 - sack.query() does not contain full package set
Summary: sack.query() does not contain full package set
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: dnf
Version: 8.5
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: rc
: ---
Assignee: Packaging Maintenance Team
QA Contact: Jan Blazek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-12-24 20:30 UTC by Stefan Bluhm
Modified: 2022-11-08 12:29 UTC (History)
6 users (show)

Fixed In Version: dnf-4.7.0-9.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-11-08 10:47:20 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-106580 0 None None None 2021-12-24 20:33:48 UTC
Red Hat Product Errata RHBA-2022:7712 0 None None None 2022-11-08 10:47:35 UTC

Description Stefan Bluhm 2021-12-24 20:30:46 UTC
I am trying to create a query object in Python 3 to contain all objects from a filled sack. The number of packages differ from the sack and the initial query object. I assume already installed OS packages filtered out (very random guess).


Version-Release number of selected component (if applicable):
dnf 4.7.0-4.el8

How reproducible:
Always on multiple systems

Steps to Reproduce:
import dnf
url="http://ftp.agdsn.de/pub/mirrors/centos/7.9.2009/os/x86_64/"
yumsrc_conf="/etc/rhn/spacewalk-repo-sync/yum.conf"
dnfbase = dnf.Base()
name="test"
repo = dnf.repo.Repo(name,dnfbase.conf)
repo.mirrorlist = url
repo.baseurl = [url]
 
dnfbase.repos.add(repo)
dnfbase.repos[repo.id].load()
dnfbase.fill_sack(load_system_repo=False,load_available_repos=True)
print (len(dnfbase.sack))
# 10072
pkglist = dnfbase.sack.query()
print(len(pkglist))
# 9597


Actual results:
Contents of dnfbase.sack and dnfbase.sack.query() differ. Unsure of the cause of the delta.

Expected results:
Both objects should have an identical number of packages (10072).

Additional info:
I am trying to load contents and information from a single, specific remote repo. Contents of the system repo should be ignored. 
Example here is running on a EL8 system for a CentOS7 repo.

Comment 1 Stefan Bluhm 2021-12-27 16:34:15 UTC
I was able to trace this behaviour back to enabled system modules. If the system has modules enabled, these packages are also ignored for remote repos. Even when "load_system_repo=False" is set.

Comment 2 Stefan Bluhm 2021-12-27 18:08:59 UTC
Workaround:
add repo.module_hotfixes = "true" in the repo configuration of the above reproduction steps.

Comment 3 Marek Blaha 2022-01-03 10:30:03 UTC
The described behavior is correct - modularity excludes some of the sack packages.
You can workaround it also using `flags` parameter of the query constructor:

pkglist = dnfbase.sack.query(flags=hawkey.IGNORE_MODULAR_EXCLUDES)

Now all modular excludes are going to be ignored for the query and all packages will be visible.

Comment 4 Stefan Bluhm 2022-01-03 10:42:25 UTC
Thank you Marek. So this works as designed?

I am trying to use dnf to evaluate "foreign" repositories, regardless of the used local system (i.e. use a RHEL 8 system to analyse and evaluate dependencies for a RHEL9 repo; also including the RHEL9 module variations. Is this meant to be a (current or future) use case?

The way I understand it now, dnf will always be dependent on/influenced by the local setup and not a generic repository evaluation tool.

Comment 5 Jaroslav Rohel 2022-01-03 11:41:40 UTC
Note:
DNF has 2 types of excludes:
- regular excludes are defined in config file or cli using `exclude` or `excludepkgs`; can be ignored using flag value `hawkey.IGNORE_REGULAR_EXCLUDES`
- modular excludes set by modularity; can be ignored using flag value `hawkey.IGNORE_MODULAR_EXCLUDES`

or flag value `hawkey.IGNORE_EXCLUDES` to ignore all excludes.

Comment 6 Stefan Bluhm 2022-01-03 11:49:05 UTC
Thank you Jaroslav. Is this documented anywhere? I couldn't find it (yet).

Comment 7 Jaroslav Mracek 2022-01-04 09:36:03 UTC
Unfortunately, flags are not documented yet. We will improve the documentation as a solution for this report.

Usage:

base.sack.query(flags=<flag>)

As a flag use one of following: hawkey.IGNORE_EXCLUDES, hawkey.APPLY_EXCLUDES, hawkey.IGNORE_REGULAR_EXCLUDES ,hawkey.IGNORE_MODULAR_EXCLUDES

hawkey.APPLY_EXCLUDES is a default behavior without any flag.

Comment 8 Stefan Bluhm 2022-01-04 09:56:49 UTC
I see. Will you do it? Otherwise I am happy to raise a PR to the documentation git this evening or tomorrow.

Comment 10 Stefan Bluhm 2022-01-17 10:56:10 UTC
Hello, I am not sure on the current status of this ticket.

Can you answer this question?

    "Does this work as designed?

    I am trying to use dnf to evaluate "foreign" repositories, regardless of the used local system (i.e. use a RHEL 8 system to analyse and evaluate dependencies for a RHEL9 repo;
    also including the RHEL9 module variations. Is this meant to be a (current or future) use case?

    The way I understand it now, dnf will always be dependent on/influenced by the local setup and not a generic repository evaluation tool."

1. If it works as designed: Documentation has been updated and ticket can be closed.

2. If not, we would need a fix.

Thank you and best wishes,

Stefan

Comment 11 Jaroslav Mracek 2022-02-15 12:54:00 UTC
I will provide some notes to your code. May be it will help to understand it.

Steps to Reproduce:
import dnf
url="http://ftp.agdsn.de/pub/mirrors/centos/7.9.2009/os/x86_64/"
yumsrc_conf="/etc/rhn/spacewalk-repo-sync/yum.conf"
dnfbase = dnf.Base()
name="test"
repo = dnf.repo.Repo(name,dnfbase.conf)
repo.mirrorlist = url
repo.baseurl = [url]
 
dnfbase.repos.add(repo)

# You do not need to load repo separately (remove following line). It is done by `dnfbase.fill_sack()
dnfbase.repos[repo.id].load()

dnfbase.fill_sack(load_system_repo=False,load_available_repos=True)

#Returns len of packages in sack.
print (len(dnfbase.sack))
# 10072


pkglist = dnfbase.sack.query()
print(len(pkglist))
# 9597
# Query contains not excluded packages therefore it can provides a different number when flag `hawkey.IGNORE_EXCLUDES`is not use for initialization of query.

Thank you very much for your patch, it is great to see community contribution => welcome in DNF community. The patch was merged and I don't see any additional issue, therefore we can mark the bug as resolved.

Comment 12 Stefan Bluhm 2022-02-15 14:13:57 UTC
Hello Jaroslav,

thank you, I do understand your comments and accept that this works as designed.

Unfortunately, I cannot close tickets (or I still haven't figured out how to...). So can you please do it for me?

Best wishes,

Stefan

Comment 15 Jaroslav Mracek 2022-05-06 15:37:29 UTC
AC: It is a documentation update therefore I suggest sanity only.

Comment 16 Stefan Bluhm 2022-05-09 07:32:11 UTC
Hello Jaroslav,

I am a bit confused on the activity on this ticket.

From my point of view, the ticket can be closed as "works as designed".

I just can't close it myself so can you please do it?
If there is a reason to keep open, that is certainly also fine. I just want to avoid you working on it if not necessary.

Best wishes,

Stefan

Comment 17 amatej 2022-05-09 08:32:37 UTC
Hello Stefan,

we are using the bugzilla for some of our processes because it is associated with your docs update PR (https://github.com/rpm-software-management/dnf/pull/1807).
We want to keep it open for now. :)

Comment 23 errata-xmlrpc 2022-11-08 10:47:20 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:7712


Note You need to log in before you can comment on or make changes to this bug.