Bug 1780370 - versionlock plugin prevents installed packages being removed
Summary: versionlock plugin prevents installed packages being removed
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: dnf-plugins-core
Version: 8.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 8.0
Assignee: Marek Blaha
QA Contact: Jan Blazek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-12-05 19:43 UTC by Frank Hirtz
Modified: 2020-04-28 16:49 UTC (History)
2 users (show)

Fixed In Version: dnf-plugins-core-4.0.12-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-28 16:49:06 UTC
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:1823 None None None 2020-04-28 16:49:22 UTC

Description Frank Hirtz 2019-12-05 19:43:36 UTC
Description of problem:
Locking the version of a specific package prevents it being removed with "dnf remove" when a different version of that package is installed:

<snip>
[root@lab-rhel8-1 fmhirtz]# rpm -q bind-utils
bind-utils-9.11.4-26.P2.el8.x86_64
[root@lab-rhel8-1 fmhirtz]# cat /etc/dnf/plugins/versionlock.list

# Added locks on Thu Dec  5 17:18:33 2019
bind-utils-32:9.11.4-17.P2.el8_0.1.*
[root@lab-rhel8-1 fmhirtz]# yum remove bind-utils
Updating Subscription Management repositories.
No match for argument: bind-utils
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!
</snip>


This behaviour is broken, and it did not exist on RHEL 7. It should be fixed.

Note that bind-utils above was used only as an example - the same problem exists for all packages.

We install our hosts in a completely automated way where all the install/upgrade/remove operations are performed in a single run of "dnf shell", so please do not suggest workarounds like editing the version lock file only after the old version of the package was already removed - such manual workarounds are unacceptable.

The root cause appears to be these lines in the versionlock plugin:

<snip>
        if locked_names:
            all_versions = self.base.sack.query().filter(name__glob=list(locked_names))
            other_versions = all_versions.difference(locked_query)
            excludes_query = excludes_query.union(other_versions)

        if excludes_query:
            self.base.sack.add_excludes(excludes_query)
</snip>

The above code makes all versions other than the one specified in the versionlock file invisible to _all_ package-related queries. But that is wrong, the "remove" operation must always see all installed versions (there may be more, e.g. in case of the kernel), so the exclusion should apply only to "install"/"upgrade".


Version-Release number of selected component (if applicable):
python3-dnf-plugin-versionlock-4.0.8-3.el8.noarch

How reproducible:
Always

Steps to Reproduce:
1. Add/have versionlock entry for an installed package, but at a different version than the currently installed one 
2. Attempt to uninstall said package
3. 

Actual results:

dnf doesn't see the package and can't uninstall it

Expected results:

dnf should be able to uninstall the package

Additional info:

Comment 8 errata-xmlrpc 2020-04-28 16:49:06 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, 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-2020:1823


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