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:
[root@lab-rhel8-1 fmhirtz]# rpm -q bind-utils
[root@lab-rhel8-1 fmhirtz]# cat /etc/dnf/plugins/versionlock.list
# Added locks on Thu Dec 5 17:18:33 2019
[root@lab-rhel8-1 fmhirtz]# yum remove bind-utils
Updating Subscription Management repositories.
No match for argument: bind-utils
No packages marked for removal.
Nothing to do.
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:
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)
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):
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
dnf doesn't see the package and can't uninstall it
dnf should be able to uninstall the package
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.