Bug 1497188

Summary: hy_subject_get_best_solution() does not consider architecture whitelist set by dnf_sack_set_arch()
Product: [Fedora] Fedora Reporter: Alex Kanavin <ak>
Component: libdnfAssignee: rpm-software-management
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 29CC: ak, dmach, igor.raits, jmracek, rpm-software-management
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-09-30 17:05:48 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 Alex Kanavin 2017-09-29 12:24:48 UTC
When creating queries from package specs, hy_subject_get_best_solution() does not filter the results according to what package architectures are allowed (which was previously set via dnf_sack_set_arch()).

Normally this is not an issue, as packages with an incorrect architecture will later be rejected anyway through checks happening in libsolv, but in Yocto project we found a scenario where it does lead to an incorrect decision.

Specifically:

1. The system architecture is set to "correct-arch".

2. The installation repository contains two packages:
- package "abc.incorrect-arch"
- package "xyz.correct-arch", with "provides: abc"

3. What then happens is that hy_subject_get_best_solution() will pick "abc" package for the installation (because the code that would consider packages with "provides: abc" is not even reached). Then later the "abc" package will be rejected by libsolv, even though the correct solution would've been to pick "xyz".

More info here:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=12025

I have considered various ways to fix this, but I can't decide which would be the optimal one. This is something for libdnf maintainer to ponder, I guess:

1) Add HY_ONLY_INSTALLABLE to _hy_query_flags, use it in hy-query.c init_result() to filter the package set with the help of pool_installable() from libsolv.

2) Add hy_query_filter_installable() funtcion to hy-query.c, which would use the same pool_installable() to filter the package set. Call it from  hy_subject_get_best_solution().

3) Add HY_PKG_INSTALLABLE type of filter, otherwise similar to solution 2.

4) in hy_subject_get_best_solution() get the list of allowed architectures (libsolv or libdnf do not provide a convenience function for it, but it can be done). 
Then issue:
    hy_query_filter_in(query, HY_PKG_ARCH, HY_EQ, allowed_arches);


Thoughts?

Comment 2 Fedora End Of Life 2018-02-20 15:34:08 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 28 development cycle.
Changing version to '28'.

Comment 3 Jan Kurik 2018-08-14 10:17:40 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 29 development cycle.
Changing version to '29'.

Comment 4 Jaroslav Mracek 2018-09-27 10:15:12 UTC
The similar problem we used to have with src arch. Now they are filtered out using with_src=false.

Please is still your request relevant?

Comment 5 Alex Kanavin 2018-09-28 09:06:01 UTC
Not really relevant anymore. We have meanwhile implemented repo setup in such a way that packages with incorrect architectures never make it to the repo (via whitelisting). So there's no way to even easily verify this anymore.

Comment 6 Jaroslav Mracek 2018-09-30 17:05:48 UTC
Thanks a lot for response.