Bug 1921063

Summary: dnf autoremove wants to remove "kernel-modules-extra" if you have a rawhide kernel installed
Product: [Fedora] Fedora Reporter: doubtee
Component: dnfAssignee: Jaroslav Mracek <jmracek>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 33CC: dmach, jmracek, jrohel, mblaha, mhatina, packaging-team-maint, pkratoch, rpm-software-management, vmukhame
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: dnf-4.7.0-1.fc33 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-03 01:48:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description doubtee 2021-01-27 13:21:54 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0
Build Identifier: 

If you have a rawhide kernel installed (https://fedoraproject.org/wiki/RawhideKernelNodebug) and try to run "sudo dnf autoremove" it wants to remove all "kernel-modules-extra" packages. 

Reproducible: Happens sometimes, but not always.

Steps to Reproduce:
1. Install a rawhide kernel:
"sudo dnf config-manager --add-repo=http://dl.fedoraproject.org/pub/alt/rawhide-kernel-nodebug/fedora-rawhide-kernel-nodebug.repo"

"sudo dnf update"

2. Try to run "sudo dnf autoremove"
3. See that dnf prompts you to remove all "kernel-modules-extra" packages that are installed

Actual Results:  
If you press "y" it removes all the "kernel-modules-extra" packages. 

Expected Results:  
dnf autoremove shouldn't have detected the "kernel-modules-extra" packages. 

I have tested this on my own machine and inside a VM. Both had the same issue.

Comment 1 doubtee 2021-01-27 17:19:49 UTC
I got the latest stable kernel update on my machine and updated. I got the same issue but when I tried to update my VM I couldn't reproduce it so I changed the "Reproducible" status to "Happens sometimes, but not always.". 

At this point I am afraid I don't know the root cause of this so I am going to explain in what state my system is, so it may help. Since I figured out I have a kernel issue on the latest versions I decided to use an older kernel and try to use a RC kernel, so that's where it all started. I started to play with kernels update/remove etc. and I noticed this issue. When I got the latest stable kernel update today running "sudo dnf autoremove" wanted to remove "kernel-modules-extra" again. I installed the rawhide kernel again and now dnf autoremove doesn't want to remove "kernel-modules-extra" anymore. I am not sure if I will see this issue again in the next kernel update. 

One more thing I want to add here is I did run "sudo rpm --rebuilddb" on the VM before today's latest stable kernel update could that explain why I couldn't reproduce this on the VM meanwhile I could on my main system?

Comment 2 Jaroslav Mracek 2021-02-01 15:28:10 UTC
Please could you provide an output from:
dnf repoquery 'kernel*'  --qf '%{name}-%{epoch}:%{version}-%{release}.%{arch} %{reason}' --installed

dnf repoquery --whatrequires 'kernel-modules-extra' --installed

Comment 3 doubtee 2021-02-02 12:15:30 UTC
Output from "dnf repoquery 'kernel*'  --qf '%{name}-%{epoch}:%{version}-%{release}.%{arch} %{reason}' --installed":

kernel-0:5.10.12-200.fc33.x86_64 user
kernel-0:5.10.8-200.fc33.x86_64 user
kernel-0:5.11.0-0.rc6.141.fc34.x86_64 user
kernel-core-0:5.10.12-200.fc33.x86_64 user
kernel-core-0:5.10.8-200.fc33.x86_64 user
kernel-core-0:5.11.0-0.rc6.141.fc34.x86_64 user
kernel-headers-0:5.10.11-200.fc33.x86_64 dependency
kernel-modules-0:5.10.12-200.fc33.x86_64 user
kernel-modules-0:5.10.8-200.fc33.x86_64 user
kernel-modules-0:5.11.0-0.rc6.141.fc34.x86_64 user
kernel-modules-extra-0:5.10.12-200.fc33.x86_64 user
kernel-modules-extra-0:5.10.8-200.fc33.x86_64 user
kernel-modules-extra-0:5.11.0-0.rc6.141.fc34.x86_64 user

Output from "dnf repoquery --whatrequires 'kernel-modules-extra' --installed":

(There is no output)

One thing I want to add is when I was running these commands "sudo dnf autoremove" don't wanted to uninstall "kernel-modules-extra" I saved those commands and next time when I can reproduce that "sudo dnf autoremove" wants to remove "kernel-modules-extra" I will share output from that scenario too.

Comment 4 doubtee 2021-02-02 21:19:02 UTC
I removed some of my kernels and downgraded to latest stable and could reproduce it. 

Output from "dnf repoquery 'kernel*'  --qf '%{name}-%{epoch}:%{version}-%{release}.%{arch} %{reason}' --installed":

kernel-0:5.10.11-200.fc33.x86_64 dependency
kernel-0:5.10.8-200.fc33.x86_64 dependency
kernel-core-0:5.10.11-200.fc33.x86_64 dependency
kernel-core-0:5.10.8-200.fc33.x86_64 dependency
kernel-headers-0:5.10.11-200.fc33.x86_64 dependency
kernel-modules-0:5.10.11-200.fc33.x86_64 dependency
kernel-modules-0:5.10.8-200.fc33.x86_64 dependency
kernel-modules-extra-0:5.10.11-200.fc33.x86_64 dependency
kernel-modules-extra-0:5.10.8-200.fc33.x86_64 dependency

Output from "dnf repoquery --whatrequires 'kernel-modules-extra' --installed":

(Still here is no output)

Here is an image: https://i.imgur.com/VrLLaPp.png (can see all the commands + sudo dnf autoremove)
https://i.vgy.me/qJllNS.png (alternative image link in case one hoster as an issue)

Comment 5 Jaroslav Mracek 2021-02-03 06:56:54 UTC
Please could you provide all steps that you performed to get from state from commend 3 to state in comment 4? Minimal reproducer will be very helpful.

To get to state in comment 3 you can run `dnf mark install kernel kernel-core kernel-modules-extra kernel-modules`

Comment 6 Jaroslav Mracek 2021-02-03 07:08:31 UTC
I can confirm that there is an issue in dnf, but a different one that was reported.
When kernels are user installed and I remove one of kernels, the all remaining have reason unknown. But I am unable to reproduce switch from user to dependency reason.

Comment 7 doubtee 2021-02-03 18:36:06 UTC
I could finally reproduce! So the issue is that when you are in unknown state and then install "sudo dnf config-manager --add-repo=http://dl.fedoraproject.org/pub/alt/rawhide-kernel-nodebug/fedora-rawhide-kernel-nodebug.repo" nodebug repository and run "sudo dnf upgrade" it will install the kernel and when you run "dnf repoquery 'kernel*'  --qf '%{name}-%{epoch}:%{version}-%{release}.%{arch} %{reason}' --installed" you then should be in the dependency state. At that point running "sudo dnf autoremove" will try to uninstall "kernel-modules-extra" packages. 

A more step by step:

1) My current state:
kernel-0:5.10.11-200.fc33.x86_64 user
kernel-0:5.10.8-200.fc33.x86_64 user
kernel-0:5.11.0-0.rc6.141.fc34.x86_64 user
kernel-core-0:5.10.11-200.fc33.x86_64 user
kernel-core-0:5.10.8-200.fc33.x86_64 user
kernel-core-0:5.11.0-0.rc6.141.fc34.x86_64 user
kernel-headers-0:5.10.11-200.fc33.x86_64 dependency
kernel-modules-0:5.10.11-200.fc33.x86_64 user
kernel-modules-0:5.10.8-200.fc33.x86_64 user
kernel-modules-0:5.11.0-0.rc6.141.fc34.x86_64 user
kernel-modules-extra-0:5.10.11-200.fc33.x86_64 user
kernel-modules-extra-0:5.10.8-200.fc33.x86_64 user
kernel-modules-extra-0:5.11.0-0.rc6.141.fc34.x86_64 user

2) "sudo dnf remove kernel-core-5.11.0-0.rc6.141.fc34.x86_64" (this was a locally installed one)

3) Removing that locally installed kernel will make you fall into unknown state. 
kernel-0:5.10.11-200.fc33.x86_64 unknown
kernel-0:5.10.8-200.fc33.x86_64 unknown
kernel-core-0:5.10.11-200.fc33.x86_64 unknown
kernel-core-0:5.10.8-200.fc33.x86_64 unknown
kernel-headers-0:5.10.11-200.fc33.x86_64 dependency
kernel-modules-0:5.10.11-200.fc33.x86_64 unknown
kernel-modules-0:5.10.8-200.fc33.x86_64 unknown
kernel-modules-extra-0:5.10.11-200.fc33.x86_64 unknown
kernel-modules-extra-0:5.10.8-200.fc33.x86_64 unknown

4) "sudo dnf config-manager --add-repo=http://dl.fedoraproject.org/pub/alt/rawhide-kernel-nodebug/fedora-rawhide-kernel-nodebug.repo" and "sudo dnf upgrade" (install the kernel)

5) After installation of the nodebug kernel from the repository you should be in the dependency state.
kernel-0:5.10.11-200.fc33.x86_64 dependency
kernel-0:5.10.8-200.fc33.x86_64 dependency
kernel-0:5.11.0-0.rc6.141.fc34.x86_64 dependency
kernel-core-0:5.10.11-200.fc33.x86_64 dependency
kernel-core-0:5.10.8-200.fc33.x86_64 dependency
kernel-core-0:5.11.0-0.rc6.141.fc34.x86_64 dependency
kernel-headers-0:5.10.11-200.fc33.x86_64 dependency
kernel-modules-0:5.10.11-200.fc33.x86_64 dependency
kernel-modules-0:5.10.8-200.fc33.x86_64 dependency
kernel-modules-0:5.11.0-0.rc6.141.fc34.x86_64 dependency
kernel-modules-extra-0:5.10.11-200.fc33.x86_64 dependency
kernel-modules-extra-0:5.10.8-200.fc33.x86_64 dependency
kernel-modules-extra-0:5.11.0-0.rc6.141.fc34.x86_64 dependency

6) Try to run "sudo dnf autoremove" and see that it will try to remove "kernel-modules-extra"

Hope this one helps. Thanks.

Comment 8 Jaroslav Mracek 2021-02-11 09:29:56 UTC
Thanks a lot for detail information. I can reproduce it and we are looking for a solution.

Comment 9 Jaroslav Mracek 2021-02-12 07:37:05 UTC
I create a patch that helps with the problem (https://github.com/rpm-software-management/ci-dnf-stack/pull/958). It prevents reason change from unknown to dependency, therefore the issue with autoremove will disappear. But there is still a problem with change from user to unknown.

Tests:  rpm-software-management/ci-dnf-stack#958

Comment 10 Jaroslav Mracek 2021-02-15 07:29:38 UTC
Also requires: Requires: https://github.com/rpm-software-management/dnf#1728

Comment 11 Jaroslav Mracek 2021-03-01 09:03:21 UTC
I forget to add a reference for main part of the patch - https://github.com/rpm-software-management/libdnf/pull/1141

Comment 12 Fedora Update System 2021-04-19 16:12:55 UTC
FEDORA-2021-447fb19490 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2021-447fb19490

Comment 13 Fedora Update System 2021-04-19 18:33:44 UTC
FEDORA-2021-447fb19490 has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-447fb19490`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-447fb19490

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 14 Fedora Update System 2021-05-03 01:48:21 UTC
FEDORA-2021-447fb19490 has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.