Bug 1201445

Summary: "dnf autoremove" removes "user-installed" installonly packages installed using "dnf upgrade"
Product: [Fedora] Fedora Reporter: Conley Moorhous <csmoorhous>
Component: dnfAssignee: Michael Mráka <mmraka>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 22CC: ben.r.xiao, csmoorhous, jsilhan, mluscon, mmraka, packaging-team-maint, pnemade, quarry386, rholy, tim.lauridsen
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-plugins-core-0.1.7-1.fc22 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-05-08 07:27:19 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:
Attachments:
Description Flags
The output of a bash script iterating over and listing the info of each dnf transaction
none
dnf history list
none
dnf history userinstalled
none
dnf info kernel none

Description Conley Moorhous 2015-03-12 17:35:52 UTC
Created attachment 1001153 [details]
The output of a bash script iterating over and listing the info of each dnf transaction

Description of problem: Autoremove removes kernel, kernel-core, and kernel-modules, while upgrade installs them (all version 4.0.0-0.rc2.git0.1.fc22). This can be done as many times as you like.


Version-Release number of selected component (if applicable): 0.6.4 2.fc22


How reproducible: Always
Steps to Reproduce:
1. 'dnf autoremove'
2. 'dnf upgrade'
3. 'dnf autoremove'
4. 'dnf upgrade'
5. ...

Actual results: The latest version of kernel, kernel-core, and kernel-modules is autoremoved and installed by "dnf autoremove" and "dnf upgrade" respectively


Expected results: "dnf autoremove" does not autoremove the kernel packages


Additional info: I don't know how to list the info of each historical transaction with dnf, so I ran

for i in {1..40}; do echo -e `sudo dnf history info $i` "\n\n"; done

It is attached as dnf-history-info.

Likewise, "dnf history list" is attached as dnf-history-list and "dnf history userinstalled" is attached as dnf-history-userinstalled. Notably, "kernel" is listed as user installed. I think it may have been listed as a dependency of some program.

Comment 1 Conley Moorhous 2015-03-12 17:36:15 UTC
Created attachment 1001154 [details]
dnf history list

Comment 2 Conley Moorhous 2015-03-12 17:36:45 UTC
Created attachment 1001155 [details]
dnf history userinstalled

Comment 3 Conley Moorhous 2015-03-12 17:55:32 UTC
Also, the kernel in use is 4.0.0-0.rc1.git0.1.fc22. See also "dnf info kernel"

Comment 4 Conley Moorhous 2015-03-12 17:55:53 UTC
Created attachment 1001159 [details]
dnf info kernel

Comment 5 Radek Holy 2015-03-13 12:30:41 UTC
Hello, thank you for the report. It's interesting for me that nobody hit this bug before. It seems that if a user installs a kernel using "dnf upgrade", the kernel is marked as a dependency and thus it can be removed using "dnf autoremove". By default, DNF inherits the "installation reason" from the upgraded package during the upgrade process but "installonly" packages are exceptions because in fact, they do not *replace* another packages.

The question is what is the correct solution. Should we always mark all installonly packages as "user-installed"? Should we ignore "reasons" when considering installonlies for autoremoval? Should we inherit the reason from another installed versions?

Comment 6 Radek Holy 2015-03-13 12:33:13 UTC
I suggest you to install the kernel using "dnf install" as a workaround.

Comment 7 Conley Moorhous 2015-03-13 23:40:19 UTC
Here's what I get:

conley@conley:~$ sudo dnf install kernel
Using metadata from Fri Mar 13 18:30:21 2015
Package kernel-4.0.0-0.rc1.git0.1.fc22.x86_64 is already installed, skipping.
Package kernel-4.0.0-0.rc2.git0.1.fc22.x86_64 is already installed, skipping.
Package kernel-4.0.0-0.rc1.git0.1.fc22.x86_64 is already installed, skipping.
Package kernel-4.0.0-0.rc2.git0.1.fc22.x86_64 is already installed, skipping.
Package kernel-4.0.0-0.rc1.git0.1.fc22.x86_64 is already installed, skipping.
Package kernel-4.0.0-0.rc2.git0.1.fc22.x86_64 is already installed, skipping.
Package kernel-4.0.0-0.rc1.git0.1.fc22.x86_64 is already installed, skipping.
Package kernel-4.0.0-0.rc2.git0.1.fc22.x86_64 is already installed, skipping.
Dependencies resolved.
Nothing to do.

Comment 8 Conley Moorhous 2015-03-14 01:39:25 UTC
Not sure if this is related or should be a different bug, but "yum upgrade" gave me a bunch of potential updates but then had a failed dependency resolution. "dnf upgrade" reported "nothing to do." After asking on IRC, I was told to try "dnf clean all" After this, dnf found all the upgrades and was able to install them.

Comment 9 Michael Mráka 2015-03-16 08:28:09 UTC
(In reply to Radek Holy from comment #5)
> The question is what is the correct solution. Should we always mark all
> installonly packages as "user-installed"? Should we ignore "reasons" when
> considering installonlies for autoremoval? Should we inherit the reason from
> another installed versions?

It seem to me the correct solution is to inherit the reason from previously installed version.

Comment 10 Radek Holy 2015-03-16 13:17:54 UTC
(In reply to Conley Moorhous from comment #7)
> Here's what I get:
> 
> conley@conley:~$ sudo dnf install kernel
> Using metadata from Fri Mar 13 18:30:21 2015
[...]
> Package kernel-4.0.0-0.rc2.git0.1.fc22.x86_64 is already installed, skipping.
> Dependencies resolved.
> Nothing to do.

So far, "dnf install kernel" checks if there is any version of "kernel" and if there is, it considers the request as satisfied, otherwise it installs the latest version. We are working on changing the behavior so that "dnf install kernel" should check if there is *the latest* version of "kernel" installed...

My suggestion was to use "dnf install kernel-4.0.0-0.rc2.git0.1.fc22" as the workaround.

(In reply to Conley Moorhous from comment #8)
> Not sure if this is related or should be a different bug, but "yum upgrade"
> gave me a bunch of potential updates but then had a failed dependency
> resolution. "dnf upgrade" reported "nothing to do." After asking on IRC, I
> was told to try "dnf clean all" After this, dnf found all the upgrades and
> was able to install them.

See http://dnf.readthedocs.org/en/latest/user_faq.html#why-do-i-get-different-results-with-dnf-upgrade-vs-yum-update . You can also use "dnf --refresh upgrade" as a shortcut. If there is an issue, let's discuss it somewhere else.

Comment 11 Conley Moorhous 2015-03-16 14:33:02 UTC
(In reply to Radek Holy from comment #10)
> (In reply to Conley Moorhous from comment #7)
> > Here's what I get:
> > 
> > conley@conley:~$ sudo dnf install kernel
> > Using metadata from Fri Mar 13 18:30:21 2015
> [...]
> > Package kernel-4.0.0-0.rc2.git0.1.fc22.x86_64 is already installed, skipping.
> > Dependencies resolved.
> > Nothing to do.
> 
> So far, "dnf install kernel" checks if there is any version of "kernel" and
> if there is, it considers the request as satisfied, otherwise it installs
> the latest version. We are working on changing the behavior so that "dnf
> install kernel" should check if there is *the latest* version of "kernel"
> installed...
> 
> My suggestion was to use "dnf install kernel-4.0.0-0.rc2.git0.1.fc22" as the
> workaround.

I can't seem to get it to work:

conley@conley:~$ sudo dnf install kernel-4.0.0-0.rc3.git0.1.fc22.x86_64
Using metadata from Sun Mar 15 19:06:08 2015
Package kernel-4.0.0-0.rc3.git0.1.fc22.x86_64 is already installed, skipping.
Package kernel-4.0.0-0.rc3.git0.1.fc22.x86_64 is already installed, skipping.
Dependencies resolved.
Nothing to do.
conley@conley:~$ sudo dnf upgrade-to kernel-4.0.0-0.rc3.git0.1.fc22.x86_64
Using metadata from Sun Mar 15 19:06:08 2015
Dependencies resolved.
Nothing to do.
conley@conley:~$ sudo dnf reinstall kernel-4.0.0-0.rc3.git0.1.fc22.x86_64
Using metadata from Sun Mar 15 19:06:08 2015
Dependencies resolved.
================================================================================
 Package    Arch       Version                        Repository           Size
================================================================================
Reinstalling:
 kernel     x86_64     4.0.0-0.rc3.git0.1.fc22        updates-testing      59 k

Transaction Summary
================================================================================

Total download size: 59 k
Is this ok [y/N]: y
Downloading Packages:
kernel-4.0.0-0.rc3.git0.1.fc22.x86_64.rpm        46 kB/s |  59 kB     00:01    
--------------------------------------------------------------------------------
Total                                            27 kB/s |  59 kB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Reinstalling: kernel-4.0.0-0.rc3.git0.1.fc22.x86_64                       1/2 
  Erasing     : kernel-4.0.0-0.rc3.git0.1.fc22.x86_64                       2/2 
  Verifying   : kernel-4.0.0-0.rc3.git0.1.fc22.x86_64                       1/2 
  Verifying   : kernel-4.0.0-0.rc3.git0.1.fc22.x86_64                       2/2 

Reinstalled:
  kernel.x86_64 4.0.0-0.rc3.git0.1.fc22                                         

Complete!
conley@conley:~$ sudo dnf remove kernel
Using metadata from Sun Mar 15 19:06:08 2015
Dependencies resolved.
Error: The operation would result in removing the booted kernel: kernel-core-4.0.0-0.rc1.git0.1.fc22.x86_64.
conley@conley:~$ sudo dnf remove kernel-core-4.0.0-0.rc1.git0.1.fc22.x86_64
Using metadata from Sun Mar 15 19:06:08 2015
Dependencies resolved.
Error: The operation would result in removing the booted kernel: kernel-core-4.0.0-0.rc1.git0.1.fc22.x86_64.
conley@conley:~$

Comment 12 Radek Holy 2015-03-16 14:39:46 UTC
OK, let me describe the suggestion...
I assumed that you are in a state where kernel-4.0.0-0.rc1.git0.1.fc22 is running and no other kernel is installed.
I assumed that your goal is to install kernel-4.0.0-0.rc2.git0.1.fc22 in such a way that it won't be removed by "dnf autoremove".
As the workaround in the meantime, this can be achieved by "dnf install kernel-4.0.0-0.rc2.git0.1.fc22" instead of "dnf upgrade".

Comment 13 Conley Moorhous 2015-03-16 14:47:20 UTC
Oh, I get it. Yes, that resolves this issue. Apparently there is another bug with dnf or something because I cannot make F22 run the latest version of the kernel, even after dnf installs it;

uname -a still reports that I'm running rc1

Comment 14 Conley Moorhous 2015-03-17 17:31:35 UTC
My dumb mistake, I hadn't installed GRUB so naturally the new kernels were not being booted. Sorry for clogging up this bug report

Comment 15 Michael Mráka 2015-04-20 06:33:13 UTC
*** Bug 1213043 has been marked as a duplicate of this bug. ***

Comment 16 Michael Mráka 2015-04-20 07:27:15 UTC
Fixed in upstream by
https://github.com/rpm-software-management/dnf/pull/257

Comment 17 Fedora Update System 2015-05-02 13:49:43 UTC
dnf-plugins-core-0.1.7-1.fc22,hawkey-0.5.5-1.fc22,dnf-1.0.0-1.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/dnf-plugins-core-0.1.7-1.fc22,hawkey-0.5.5-1.fc22,dnf-1.0.0-1.fc22

Comment 18 Fedora Update System 2015-05-03 17:24:39 UTC
Package dnf-plugins-core-0.1.7-1.fc22, hawkey-0.5.5-1.fc22, dnf-1.0.0-1.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-plugins-core-0.1.7-1.fc22 hawkey-0.5.5-1.fc22 dnf-1.0.0-1.fc22'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-7483/dnf-plugins-core-0.1.7-1.fc22,hawkey-0.5.5-1.fc22,dnf-1.0.0-1.fc22
then log in and leave karma (feedback).

Comment 19 Fedora Update System 2015-05-08 07:27:19 UTC
dnf-plugins-core-0.1.7-1.fc22, hawkey-0.5.5-1.fc22, dnf-1.0.0-1.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 20 Vitaly Sulimov 2015-07-13 14:11:34 UTC
(In reply to Michael Mráka from comment #16)
> Fixed in upstream by
> https://github.com/rpm-software-management/dnf/pull/257

I still have a problem with dnf. When performing 
# dnf autoremove
I get an error "Error: The operation would result in removing the booted kernel: kernel-core-4.0.7-300.fc22.x86_64."

dnf and plugins-core versions:
dnf-1.0.1-2.fc22.noarch
dnf-plugins-core-0.1.9-1.fc22.noarch

Comment 21 Benjamin Xiao 2016-11-02 08:39:25 UTC
Still seeing this issue on Fedora 24 with kernel-modules-extra. This is not related to the autoremove bug from Fedora 23.