Bug 1698145

Summary: dnf protects certain packages in container, when it should not
Product: Red Hat Enterprise Linux 8 Reporter: Andrei Stepanov <astepano>
Component: dnfAssignee: Pavla Kratochvilova <pkratoch>
Status: CLOSED ERRATA QA Contact: Eva Mrakova <emrakova>
Severity: unspecified Docs Contact: Mariya Pershina <mpershin>
Priority: low    
Version: 8.2CC: amatej, esyr, james.antill, mpershin, nsella, pkratoch
Target Milestone: rcKeywords: FutureFeature, Reopened, Triaged
Target Release: 8.0Flags: pkratoch: needinfo? (astepano)
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: dnf-4.4.2-2.el8 Doc Type: Enhancement
Doc Text:
.The `protect_running_kernel` configuration option is now available. With this update, the `protect_running_kernel` configuration option for the `dnf` and `microdnf` commands has been introduced. This option controls whether the package corresponding to the running version of the kernel is protected from removal. As a result, the user can now disable protection of the running kernel.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 15:00:34 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:
Bug Depends On: Red Hat1887911, Red Hat1887916    
Bug Blocks: 1697963    

Comment 1 Jaroslav Mracek 2019-04-15 14:32:33 UTC
I am sorry but the protection of packages is a feature of dnf. For your user case I would recommend to use "rpm -e kernel kernel-core kernel-modules" or "rpm -e $(dnf repoquery kernel* -q --installed)" commands for a kernel case. To disable protection it also helps to use "--setopt=protected_packages=''", then the systemd could be removed, but not a running kernel. Hope that it helps.

Comment 2 Andrei Stepanov 2019-04-15 15:01:20 UTC
Jaroslav Mracek 

I see bug. And bug is: DNF behaves differently in various namespaces.
Action of DNF is not consistent. For specific example check original bug-report.
We have ci-system. Where main tools id DNF. Of course we can set various `special conditions`. But this is local solution. And more and more people will bump into this.
Please make aware DNF of different namespaces.
Currently DNF is not ready to work in containers.

Comment 3 Daniel Mach 2019-04-29 11:17:11 UTC
We could use systemd-detect-virt to detect if we're inside a container.
Also if we're working with an installroot that is different (realpath!) to '/' we could also allow removing kernel.

Comment 20 errata-xmlrpc 2021-05-18 15:00:34 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.