Bug 1443344

Summary: dnf removes currently running kernel
Product: [Fedora] Fedora Reporter: Yu Watanabe <watanabe.yu+redhat.bugzilla>
Component: dnfAssignee: rpm-software-management
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: dmach, jmracek, mhatina, packaging-team-maint, rpm-software-management, vmukhame, watanabe.yu+redhat.bugzilla
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-2.5.0-2.fc26 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-06-09 19:06:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Attachments:
Description Flags
Patch to use /lib/modules/$(uname -r)/vmlinuz for detecting the running kernel
none
4.11.0-0.rc7.git0.1.fc26.x86_64.txt
none
4.11.0-0.rc7.git0.1.fc26.x86_64-touch.txt
none
4.11.0-1.fc26.x86_64.txt
none
4.11.0-1.fc26.x86_64-touch.txt none

Description Yu Watanabe 2017-04-19 06:28:07 UTC
Description of problem:

If running kernel is the oldest kernel instelled in the system and 3 (or installonly_limit in dnf.conf) kernel rpms are installed, then dnf removes currently running kernel when kernel is updated. E.g.

$ rpm -q kernel
kernel-4.9.13-201.fc25.x86_64
kernel-4.10.9-200.fc25.x86_64
kernel-4.10.10-200.fc25.x86_64
$ sudo dnf update
Last metadata expiration check: 0:01:02 ago on Wed Apr 19 15:10:12 2017.
Dependencies resolved.
===========================================================
 Package          Arch     Version         Repository Size
===========================================================
Installing:
 kernel           x86_64   4.10.11-200.fc25    koji   98 k
 kernel-core      x86_64   4.10.11-200.fc25    koji   20 M
 kernel-devel     x86_64   4.10.11-200.fc25    koji   11 M
 kernel-modules   x86_64   4.10.11-200.fc25    koji   23 M
Upgrading:
 kernel-headers   x86_64   4.10.11-200.fc25    koji  1.1 M
Removing:
 kernel           x86_64   4.9.13-201.fc25     @koji   0
 kernel-core      x86_64   4.9.13-201.fc25     @koji  53 M
 kernel-modules   x86_64   4.9.13-201.fc25     @koji  22 M

Transaction Summary
===========================================================
Install  4 Packages
Upgrade  1 Package
Remove   3 Packages

Total size: 55 M
Is this ok [y/N]: N
Operation aborted.


Version-Release number of selected component (if applicable):

dnf-1.1.10-6.fc25.noarch

How reproducible:

always

Steps to Reproduce:
1. please see above
2.
3.

Actual results:

dnf removes the oldest kernel regardless of the kernel is running or not.

Expected results:

dnf removes the oldest and not running kernel

Additional info:

Comment 1 Martin Hatina 2017-04-19 11:23:47 UTC
Please, update dnf to dnf-2.3.0, can you try to reproduce this problem with new dnf?

Comment 2 Yu Watanabe 2017-04-20 05:02:21 UTC
I've also tested with dnf-2.3.0-1.fc27.noarch. However, the problem still exist.

Comment 3 Jaroslav Mracek 2017-05-04 11:11:01 UTC
Please can you try it with dnf-2.4 and provide output from:
1. "dnf repoquery --userinstalled kernel*"
2. "dnf repoquery kernel*"
3. "dnf upgrade" # where it tries to remove running kernel
4. also setting of koji repo could help (just to know the origin of packages) (/etc/yum.repos.d/<repo koji>.repo)
5. Please also ensure that that you run certain kernel version and provide exact version of that kernel

I ask so meny questions because I am unable to reproduce the problem on my VM.

Comment 4 Yu Watanabe 2017-05-08 02:13:39 UTC
Sorry for late reply.

1. Now I use dnf-2.4.0-2.fc26.noarch, and it seems not to have the option '--userinstalled'. Are there any rpm I can test with the following commit?
https://github.com/rpm-software-management/dnf/commit/bb5ed9a97588ba8d418bc1b72c9c7de9f0d1b89f

Instead of '--userinstalled', I tried '--installed' option, and the output is
=============
$ sudo dnf repoquery --installed kernel*
kernel-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-0:4.11.0-0.rc7.git0.1.fc26.x86_64
kernel-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-core-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-core-0:4.11.0-0.rc7.git0.1.fc26.x86_64
kernel-core-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-headers-0:4.11.0-1.fc26.x86_64
kernel-modules-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-modules-0:4.11.0-0.rc7.git0.1.fc26.x86_64
kernel-modules-0:4.11.0-0.rc8.git0.1.fc26.x86_64
=============

2.
=============
$ sudo dnf repoquery kernel*
Last metadata expiration check: 0:00:00 ago on Mon May 08 11:02:16 2017 JST.
kernel-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-0:4.11.0-1.fc26.x86_64
kernel-PAE-devel-0:4.11.0-1.fc26.i686
kernel-PAEdebug-devel-0:4.11.0-1.fc26.i686
kernel-core-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-core-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-core-0:4.11.0-1.fc26.x86_64
kernel-cross-headers-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-cross-headers-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-cross-headers-0:4.11.0-1.fc26.x86_64
kernel-debug-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-debug-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-debug-0:4.11.0-1.fc26.x86_64
kernel-debug-core-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-debug-core-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-debug-core-0:4.11.0-1.fc26.x86_64
kernel-debug-devel-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-debug-devel-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-debug-devel-0:4.11.0-1.fc26.i686
kernel-debug-devel-0:4.11.0-1.fc26.x86_64
kernel-debug-modules-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-debug-modules-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-debug-modules-0:4.11.0-1.fc26.x86_64
kernel-debug-modules-extra-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-debug-modules-extra-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-debug-modules-extra-0:4.11.0-1.fc26.x86_64
kernel-devel-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-devel-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-devel-0:4.11.0-1.fc26.x86_64
kernel-headers-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-headers-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-headers-0:4.11.0-1.fc26.x86_64
kernel-modules-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-modules-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-modules-0:4.11.0-1.fc26.x86_64
kernel-modules-extra-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-modules-extra-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-modules-extra-0:4.11.0-1.fc26.x86_64
kernel-rpm-macros-0:63-1.fc26.noarch
kernel-tools-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-tools-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-tools-0:4.11.0-1.fc26.x86_64
kernel-tools-libs-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-tools-libs-0:4.11.0-0.rc8.git0.1.fc26.i686
kernel-tools-libs-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-tools-libs-0:4.11.0-1.fc26.i686
kernel-tools-libs-0:4.11.0-1.fc26.x86_64
kernel-tools-libs-devel-0:4.11.0-0.rc6.git0.1.fc26.x86_64
kernel-tools-libs-devel-0:4.11.0-0.rc8.git0.1.fc26.i686
kernel-tools-libs-devel-0:4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-tools-libs-devel-0:4.11.0-1.fc26.i686
kernel-tools-libs-devel-0:4.11.0-1.fc26.x86_64
kernelshark-0:2.6-4.fc26.x86_64
=============

3. 
=============
$ uname -a
Linux werewolf.vlan.kuins.net 4.11.0-0.rc6.git0.1.fc26.x86_64 #1 SMP Mon Apr 10 19:45:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ sudo dnf upgrade --assumeno
Last metadata expiration check: 0:01:23 ago on Mon May 08 11:02:16 2017 JST.
Dependencies resolved.
================================================================================
 Package          Arch     Version                      Repository         Size
================================================================================
Installing:
 kernel           x86_64   4.11.0-1.fc26                updates-testing    56 k
 kernel-core      x86_64   4.11.0-1.fc26                updates-testing    21 M
 kernel-modules   x86_64   4.11.0-1.fc26                updates-testing    23 M
Removing:
 kernel           x86_64   4.11.0-0.rc6.git0.1.fc26     @koji               0  
 kernel-core      x86_64   4.11.0-0.rc6.git0.1.fc26     @koji              54 M
 kernel-modules   x86_64   4.11.0-0.rc6.git0.1.fc26     @koji              22 M

Transaction Summary
================================================================================
Install  3 Packages
Remove   3 Packages

Total download size: 43 M
Operation aborted.
=============

4. The koji repository stores downloaded rpms from koji.
=============
$ cat /etc/yum.repos.d/koji.repo 
[koji]
name=Fedora $releasever - $basearch - Koji
failovermethod=priority
baseurl=http://www2.yukawa.kyoto-u.ac.jp/~yu.watanabe/repo/koji/$releasever/$basearch/
enabled=1
metadata_expire=6h
gpgcheck=0

[koji-source]
name=Fedora $releasever - Koji Source
failovermethod=priority
baseurl=http://www2.yukawa.kyoto-u.ac.jp/~yu.watanabe/repo/koji/$releasever/SRPMS/
enabled=0
metadata_expire=6h
gpgcheck=0

[koji-rawhide]
name=Fedora Rawhide - $basearch - Koji
failovermethod=priority
baseurl=http://www2.yukawa.kyoto-u.ac.jp/~yu.watanabe/repo/koji/rawhide/$basearch/
enabled=0
metadata_expire=6h
gpgcheck=0

[koji-rawhide-source]
name=Fedora Rawhide - Koji Source
failovermethod=priority
baseurl=http://www2.yukawa.kyoto-u.ac.jp/~yu.watanabe/repo/koji/rawhide/SRPMS/
enabled=0
metadata_expire=6h
gpgcheck=0
=============

5. As already shown in the answer for 3,
=============
$ uname -a
Linux werewolf.vlan.kuins.net 4.11.0-0.rc6.git0.1.fc26.x86_64 #1 SMP Mon Apr 10 19:45:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
=============

Comment 5 Jaroslav Mracek 2017-05-09 08:14:20 UTC
I create patch for kernel removal logic that could help. Please to test it do as follows:
# please start with running the newest kernel.
1. "dnf copr enable rpmsoftwaremanagement/rpm-gitoverlay-1494315254.398449"
# it enable copr repository with patch
2. "sudo dnf --repo rpmsoftwaremanagement-rpm-gitoverlay-1494315254.398449 upgrade dnf libdnf libsolv"
# To upgrade to dnf-2.4.0_1-7gca0f46b.fc25.noarch, libdnf-0.8.2-3gc54f4fd.fc25.x86_64, libsolv-0.6.27-1.fc25.x86_64

3. Try "dnf upgrade --assumeno" to check if transaction is possible with update of new kernel and which kernel is remove.

4. Reboot with oldest kernel and then run again "dnf upgrade --assumeno" 
Expected result:
Install new kernel
Removes oldest kernel that is not running.

I hope that it will work for you, because I cannot reproduce your problem on my side. 

Please report the result of this test.

Comment 6 Yu Watanabe 2017-05-10 06:40:54 UTC
Unfortunately, the copr packages does not fix this issue.
I've tested the procedure written in comment #3 with the copr dnf.
Note that, in the comment #4, I've tested on Fedora 26, however the following results is tested on Fedora 25, because the copr dnf is build for Fedora 25.

1.
=============
$ sudo dnf repoquery --installed kernel*
kernel-0:4.10.13-200.fc25.x86_64
kernel-0:4.10.14-200.fc25.x86_64
kernel-0:4.9.13-201.fc25.x86_64
kernel-core-0:4.10.13-200.fc25.x86_64
kernel-modules-0:4.10.13-200.fc25.x86_64
=============

2.
=============
$ sudo dnf repoquery kernel*
Last metadata expiration check: 0:04:33 ago on Wed May 10 15:28:49 2017 JST.
kernel-0:4.10.13-200.fc25.x86_64
kernel-0:4.10.14-200.fc25.x86_64
kernel-0:4.10.15-200.fc25.x86_64
kernel-0:4.8.6-300.fc25.x86_64
kernel-0:4.9.13-201.fc25.x86_64
kernel-PAE-devel-0:4.10.13-200.fc25.i686
kernel-PAE-devel-0:4.10.14-200.fc25.i686
kernel-PAEdebug-devel-0:4.10.13-200.fc25.i686
kernel-PAEdebug-devel-0:4.10.14-200.fc25.i686
kernel-core-0:4.10.13-200.fc25.x86_64
kernel-core-0:4.10.14-200.fc25.x86_64
kernel-core-0:4.10.15-200.fc25.x86_64
kernel-core-0:4.8.6-300.fc25.x86_64
kernel-core-0:4.9.13-201.fc25.x86_64
kernel-cross-headers-0:4.10.13-200.fc25.x86_64
kernel-cross-headers-0:4.10.14-200.fc25.x86_64
kernel-cross-headers-0:4.10.15-200.fc25.x86_64
kernel-cross-headers-0:4.8.6-300.fc25.x86_64
kernel-cross-headers-0:4.9.13-201.fc25.x86_64
kernel-debug-0:4.10.13-200.fc25.x86_64
kernel-debug-0:4.10.14-200.fc25.x86_64
kernel-debug-0:4.10.15-200.fc25.x86_64
kernel-debug-0:4.8.6-300.fc25.x86_64
kernel-debug-0:4.9.13-201.fc25.x86_64
kernel-debug-core-0:4.10.13-200.fc25.x86_64
kernel-debug-core-0:4.10.14-200.fc25.x86_64
kernel-debug-core-0:4.10.15-200.fc25.x86_64
kernel-debug-core-0:4.8.6-300.fc25.x86_64
kernel-debug-core-0:4.9.13-201.fc25.x86_64
kernel-debug-devel-0:4.10.13-200.fc25.i686
kernel-debug-devel-0:4.10.13-200.fc25.x86_64
kernel-debug-devel-0:4.10.14-200.fc25.i686
kernel-debug-devel-0:4.10.14-200.fc25.x86_64
kernel-debug-devel-0:4.10.15-200.fc25.x86_64
kernel-debug-devel-0:4.8.6-300.fc25.x86_64
kernel-debug-devel-0:4.9.13-201.fc25.x86_64
kernel-debug-modules-0:4.10.13-200.fc25.x86_64
kernel-debug-modules-0:4.10.14-200.fc25.x86_64
kernel-debug-modules-0:4.10.15-200.fc25.x86_64
kernel-debug-modules-0:4.8.6-300.fc25.x86_64
kernel-debug-modules-0:4.9.13-201.fc25.x86_64
kernel-debug-modules-extra-0:4.10.13-200.fc25.x86_64
kernel-debug-modules-extra-0:4.10.14-200.fc25.x86_64
kernel-debug-modules-extra-0:4.10.15-200.fc25.x86_64
kernel-debug-modules-extra-0:4.8.6-300.fc25.x86_64
kernel-debug-modules-extra-0:4.9.13-201.fc25.x86_64
kernel-devel-0:4.10.13-200.fc25.x86_64
kernel-devel-0:4.10.14-200.fc25.x86_64
kernel-devel-0:4.10.15-200.fc25.x86_64
kernel-devel-0:4.8.6-300.fc25.x86_64
kernel-devel-0:4.9.13-201.fc25.x86_64
kernel-headers-0:4.10.13-200.fc25.x86_64
kernel-headers-0:4.10.14-200.fc25.x86_64
kernel-headers-0:4.10.15-200.fc25.x86_64
kernel-headers-0:4.8.6-300.fc25.x86_64
kernel-headers-0:4.9.13-201.fc25.x86_64
kernel-modules-0:4.10.13-200.fc25.x86_64
kernel-modules-0:4.10.14-200.fc25.x86_64
kernel-modules-0:4.10.15-200.fc25.x86_64
kernel-modules-0:4.8.6-300.fc25.x86_64
kernel-modules-0:4.9.13-201.fc25.x86_64
kernel-modules-extra-0:4.10.13-200.fc25.x86_64
kernel-modules-extra-0:4.10.14-200.fc25.x86_64
kernel-modules-extra-0:4.10.15-200.fc25.x86_64
kernel-modules-extra-0:4.8.6-300.fc25.x86_64
kernel-modules-extra-0:4.9.13-201.fc25.x86_64
kernel-rpm-macros-0:44-1.fc25.noarch
kernel-rpm-macros-0:45-1.fc25.noarch
kernel-tools-0:4.10.13-200.fc25.x86_64
kernel-tools-0:4.10.14-200.fc25.x86_64
kernel-tools-0:4.10.15-200.fc25.x86_64
kernel-tools-0:4.8.6-300.fc25.x86_64
kernel-tools-0:4.9.13-201.fc25.x86_64
kernel-tools-libs-0:4.10.13-200.fc25.i686
kernel-tools-libs-0:4.10.13-200.fc25.x86_64
kernel-tools-libs-0:4.10.14-200.fc25.i686
kernel-tools-libs-0:4.10.14-200.fc25.x86_64
kernel-tools-libs-0:4.10.15-200.fc25.x86_64
kernel-tools-libs-0:4.8.6-300.fc25.i686
kernel-tools-libs-0:4.8.6-300.fc25.x86_64
kernel-tools-libs-0:4.9.13-201.fc25.x86_64
kernel-tools-libs-devel-0:4.10.13-200.fc25.i686
kernel-tools-libs-devel-0:4.10.13-200.fc25.x86_64
kernel-tools-libs-devel-0:4.10.14-200.fc25.i686
kernel-tools-libs-devel-0:4.10.14-200.fc25.x86_64
kernel-tools-libs-devel-0:4.10.15-200.fc25.x86_64
kernel-tools-libs-devel-0:4.8.6-300.fc25.i686
kernel-tools-libs-devel-0:4.8.6-300.fc25.x86_64
kernel-tools-libs-devel-0:4.9.13-201.fc25.x86_64
kernelshark-0:2.6-2.1.fc25.x86_64
kernelshark-0:2.6-2.fc25.x86_64
=============

3.
=============
$ uname -a
Linux hk11.yukawa.kyoto-u.ac.jp 4.9.13-201.fc25.x86_64 #1 SMP Tue Mar 7 23:47:11 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ sudo dnf upgrade --assumeno
Last metadata expiration check: 0:07:26 ago on Wed May 10 15:28:49 2017 JST.
Dependencies resolved.
================================================================================
 Package               Arch          Version                 Repository    Size
================================================================================
Installing:
 kernel                x86_64        4.10.15-200.fc25        koji          99 k
 kernel-core           x86_64        4.10.15-200.fc25        koji          20 M
 kernel-modules        x86_64        4.10.15-200.fc25        koji          23 M
Upgrading:
 kernel-headers        x86_64        4.10.15-200.fc25        koji         1.1 M
Installing dependencies:
 kernel-devel          x86_64        4.10.15-200.fc25        koji          11 M
Removing:
 kernel                x86_64        4.9.13-201.fc25         @koji          0  
 kernel-core           x86_64        4.9.13-201.fc25         @koji         53 M
 kernel-modules        x86_64        4.9.13-201.fc25         @koji         22 M

Transaction Summary
================================================================================
Install  4 Packages
Upgrade  1 Package
Remove   3 Packages

Total size: 55 M
Operation aborted.
=============

Comment 7 Yu Watanabe 2017-05-10 07:11:38 UTC
On Fedora 26, I've tested dnf-2.4.0_1-10gc75dba0.fc26.noarch provided by  rpmsoftwaremanagement/dnf-nightly. However, the situation is the same.

Comment 8 Jaroslav Mracek 2017-05-10 08:27:59 UTC
Ok, please can you provide output from ``ls /boot/ -l``?

I suppose that you performed steps from Comment 5.

Comment 9 Jaroslav Mracek 2017-05-10 08:36:47 UTC
Also output of ``sudo dnf repoquery --installed -l kernel-core | grep /boot`` would be handy.

Comment 10 Yu Watanabe 2017-05-11 00:03:42 UTC
> Ok, please can you provide output from ``ls /boot/ -l``?

On Fedora 25 machine,
========
$ ls /boot -l
total 12
drwxr-xr-x 5 root root 4096 May 10 15:25 d0a67e4dcc65405f8fe069407a8e6e54
drwxr-xr-x 4 root root 4096 Feb 12 16:27 EFI
drwxr-xr-x 3 root root 4096 Feb 12 16:27 loader
$ tree /boot
/boot
├── d0a67e4dcc65405f8fe069407a8e6e54
│   ├── 4.10.13-200.fc25.x86_64
│   │   ├── initrd
│   │   └── linux
│   ├── 4.10.14-200.fc25.x86_64
│   │   ├── initrd
│   │   └── linux
│   └── 4.9.13-201.fc25.x86_64
│       ├── initrd
│       └── linux
├── EFI
│   ├── BOOT
│   │   └── BOOTX64.EFI
│   └── systemd
│       └── systemd-bootx64.efi
└── loader
    ├── entries
    │   ├── d0a67e4dcc65405f8fe069407a8e6e54-4.10.13-200.fc25.x86_64.conf
    │   ├── d0a67e4dcc65405f8fe069407a8e6e54-4.10.14-200.fc25.x86_64.conf
    │   └── d0a67e4dcc65405f8fe069407a8e6e54-4.9.13-201.fc25.x86_64.conf
    └── loader.conf

9 directories, 12 files
$ sudo dnf repoquery --installed -l kernel-core | grep /boot
/boot/.vmlinuz-4.10.13-200.fc25.x86_64.hmac
/boot/System.map-4.10.13-200.fc25.x86_64
/boot/config-4.10.13-200.fc25.x86_64
/boot/initramfs-4.10.13-200.fc25.x86_64.img
/boot/vmlinuz-4.10.13-200.fc25.x86_64
/boot/.vmlinuz-4.10.14-200.fc25.x86_64.hmac
/boot/System.map-4.10.14-200.fc25.x86_64
/boot/config-4.10.14-200.fc25.x86_64
/boot/initramfs-4.10.14-200.fc25.x86_64.img
/boot/vmlinuz-4.10.14-200.fc25.x86_64
/boot/.vmlinuz-4.9.13-201.fc25.x86_64.hmac
/boot/System.map-4.9.13-201.fc25.x86_64
/boot/config-4.9.13-201.fc25.x86_64
/boot/initramfs-4.9.13-201.fc25.x86_64.img
/boot/vmlinuz-4.9.13-201.fc25.x86_64
========
and on Fedora 26 machine,
========
$ sudo ls -l /boot
total 16
drwx------ 6 root root 4096 May  9 12:49 7f641fcfd6914589aa994554498907bb
drwx------ 4 root root 4096 Feb 15 16:03 EFI
drwx------ 3 root root 4096 Oct 19  2016 loader
-rwx------ 1 root root   53 Oct 18  2016 loader.conf
$ sudo tree /boot
/boot
├── 7f641fcfd6914589aa994554498907bb
│   ├── 0-rescue
│   │   ├── initrd
│   │   └── linux
│   ├── 4.11.0-0.rc7.git0.1.fc26.x86_64
│   │   ├── initrd
│   │   └── linux
│   ├── 4.11.0-0.rc8.git0.1.fc26.x86_64
│   │   ├── initrd
│   │   └── linux
│   └── 4.11.0-1.fc26.x86_64
│       ├── initrd
│       └── linux
├── EFI
│   ├── BOOT
│   │   └── BOOTX64.EFI
│   └── systemd
│       └── systemd-bootx64.efi
├── loader
│   ├── entries
│   │   ├── 7f641fcfd6914589aa994554498907bb-0-rescue.conf
│   │   ├── 7f641fcfd6914589aa994554498907bb-4.11.0-0.rc7.git0.1.fc26.x86_64.conf
│   │   ├── 7f641fcfd6914589aa994554498907bb-4.11.0-0.rc8.git0.1.fc26.x86_64.conf
│   │   └── 7f641fcfd6914589aa994554498907bb-4.11.0-1.fc26.x86_64.conf
│   └── loader.conf
└── loader.conf

10 directories, 16 files
$ sudo dnf repoquery --installed -l kernel-core | grep /boot
/boot/.vmlinuz-4.11.0-0.rc7.git0.1.fc26.x86_64.hmac
/boot/System.map-4.11.0-0.rc7.git0.1.fc26.x86_64
/boot/config-4.11.0-0.rc7.git0.1.fc26.x86_64
/boot/initramfs-4.11.0-0.rc7.git0.1.fc26.x86_64.img
/boot/vmlinuz-4.11.0-0.rc7.git0.1.fc26.x86_64
/boot/.vmlinuz-4.11.0-0.rc8.git0.1.fc26.x86_64.hmac
/boot/System.map-4.11.0-0.rc8.git0.1.fc26.x86_64
/boot/config-4.11.0-0.rc8.git0.1.fc26.x86_64
/boot/initramfs-4.11.0-0.rc8.git0.1.fc26.x86_64.img
/boot/vmlinuz-4.11.0-0.rc8.git0.1.fc26.x86_64
/boot/.vmlinuz-4.11.0-1.fc26.x86_64.hmac
/boot/System.map-4.11.0-1.fc26.x86_64
/boot/config-4.11.0-1.fc26.x86_64
/boot/initramfs-4.11.0-1.fc26.x86_64.img
/boot/vmlinuz-4.11.0-1.fc26.x86_64
========

Note that I use systemd-boot as the EFI bootloader, not grub2.

> I suppose that you performed steps from Comment 5.

Yes, the outputs in comment #6 are given by dnf-2.4.0_1-7gca0f46b.fc25.noarch from the copr repository rpmsoftwaremanagement-rpm-gitoverlay-1494315254.398449.

Comment 11 Jaroslav Mracek 2017-05-11 12:56:29 UTC
It looks like that your system cannot correctly detect running kernel that is handled by libdnf package. We detect package that provide a running kernel like that - that we looked for pakage that provides file '/boot/vmlinuz- + version of running kernel like '4.10.14-200.fc25.x86_64' therefore we search for string  '/boot/vmlinuz-4.10.14-200.fc25.x86_64'. Please can you try to create such a string with version of running kernel for your computer (like /boot/vmlinuz-4.9.13-201.fc25.x86_64) and try 


sudo dnf repoquery --installed --whatprovides '<string>' 

Also I do not have access to your koji repo, therefore please can you provide kernel packages in oldest version that makes a problem (running kernel that is oldest).

Please can you report version of libdnf and libsolv on your systems?

Hope that I will be able to reproduce your problem on my site.

Comment 12 Yu Watanabe 2017-05-12 08:38:40 UTC
(In reply to Jaroslav Mracek from comment #11)
> It looks like that your system cannot correctly detect running kernel that
> is handled by libdnf package. We detect package that provide a running
> kernel like that - that we looked for pakage that provides file
> '/boot/vmlinuz- + version of running kernel like '4.10.14-200.fc25.x86_64'
> therefore we search for string  '/boot/vmlinuz-4.10.14-200.fc25.x86_64'.

Oh, I got it. The function running_kernel() in hy-iutil.c 
https://github.com/rpm-software-management/libdnf/blob/master/libdnf/hy-iutil.c#L362
is I guess not suitable for my systems.

If the machine does not use grub2, more precisely, grubby is not installed, then /boot/vmlinuz-$(uname -r) does not exist. The file is created by the post-install script of kernel-core.rpm only if grubby is installed. If grubby is not installed, post-install script creates /boot/$(cat /etc/machine-id)/$(uname -r)/linux and the corresponding initrd. But the file is not detected by libdnf.

So, actually, by touching /boot/vmlinuz-$(uname -r), updating kernel works as expected. See the following outputs.
===========
$ rpm -q dnf libdnf libsolv
dnf-2.4.1-1.fc26.noarch
libdnf-0.8.2-1.fc26.x86_64
libsolv-0.6.27-1.fc26.x86_64

$ rpm -q kernel
kernel-4.11.0-0.rc7.git0.1.fc26.x86_64
kernel-4.11.0-0.rc8.git0.1.fc26.x86_64
kernel-4.11.0-1.fc26.x86_64

$ sudo dnf repoquery --installed --whatprovides /boot/vmlinuz-4.11.0-0.rc7.git0.1.fc26.x86_64
kernel-core-0:4.11.0-0.rc7.git0.1.fc26.x86_64

$ uname -r
4.11.0-0.rc7.git0.1.fc26.x86_64

$ sudo ls -l /boot
total 16
drwx------ 6 root root 4096 May  9 12:49 7f641fcfd6914589aa994554498907bb
drwx------ 4 root root 4096 Feb 15 16:03 EFI
drwx------ 3 root root 4096 Oct 19  2016 loader
-rwx------ 1 root root   53 Oct 18  2016 loader.conf

$ sudo dnf update --assumeno
Last metadata expiration check: 0:04:08 ago on Fri May 12 17:16:42 2017 JST.
Dependencies resolved.
================================================================================
 Package          Arch     Version                     Repository          Size
================================================================================
Installing:
 kernel           x86_64   4.11.0-2.fc26               updates-testing     56 k
 kernel-core      x86_64   4.11.0-2.fc26               updates-testing     21 M
 kernel-modules   x86_64   4.11.0-2.fc26               updates-testing     23 M
Upgrading:
 kernel-headers   x86_64   4.11.0-2.fc26               updates-testing    1.1 M
Removing:
 kernel           x86_64   4.11.0-0.rc7.git0.1.fc26    @updates-testing     0  
 kernel-core      x86_64   4.11.0-0.rc7.git0.1.fc26    @updates-testing    54 M
 kernel-modules   x86_64   4.11.0-0.rc7.git0.1.fc26    @updates-testing    22 M

Transaction Summary
================================================================================
Install  3 Packages
Upgrade  1 Package
Remove   3 Packages

Total download size: 45 M
Operation aborted.

$ sudo touch /boot/vmlinuz-$(uname -r)
$ sudo ls -l /boot
total 16
drwx------ 6 root root 4096 May  9 12:49 7f641fcfd6914589aa994554498907bb
drwx------ 4 root root 4096 Feb 15 16:03 EFI
drwx------ 3 root root 4096 Oct 19  2016 loader
-rwx------ 1 root root   53 Oct 18  2016 loader.conf
-rwx------ 1 root root    0 May 12 17:22 vmlinuz-4.11.0-0.rc7.git0.1.fc26.x86_64

$ sudo dnf update --assumeno
Last metadata expiration check: 0:06:43 ago on Fri May 12 17:16:42 2017 JST.
Dependencies resolved.
================================================================================
 Package          Arch     Version                     Repository          Size
================================================================================
Installing:
 kernel           x86_64   4.11.0-2.fc26               updates-testing     56 k
 kernel-core      x86_64   4.11.0-2.fc26               updates-testing     21 M
 kernel-modules   x86_64   4.11.0-2.fc26               updates-testing     23 M
Upgrading:
 kernel-headers   x86_64   4.11.0-2.fc26               updates-testing    1.1 M
Removing:
 kernel           x86_64   4.11.0-0.rc8.git0.1.fc26    @updates-testing     0  
 kernel-core      x86_64   4.11.0-0.rc8.git0.1.fc26    @updates-testing    54 M
 kernel-modules   x86_64   4.11.0-0.rc8.git0.1.fc26    @updates-testing    22 M

Transaction Summary
================================================================================
Install  3 Packages
Upgrade  1 Package
Remove   3 Packages

Total download size: 45 M
Operation aborted.
============

Comment 13 Yu Watanabe 2017-05-12 08:46:47 UTC
(In reply to Jaroslav Mracek from comment #11)
> Also I do not have access to your koji repo, therefore please can you
> provide kernel packages in oldest version that makes a problem (running
> kernel that is oldest).

I enabled indexes option in my repository, so now you can access my koji repo.
http://www2.yukawa.kyoto-u.ac.jp/~yu.watanabe/repo/koji/26/x86_64/
But all the rpm files are just retrieved from
https://koji.fedoraproject.org/koji/packageinfo?packageID=8
by using koji command. So, I guess the reproductivity of the problem is not related to the repository.

Comment 14 Yu Watanabe 2017-05-12 09:08:02 UTC
The file /boot/vmlinuz-$(uname -r) is labeled as %ghost file in the kernel-core package. Instead of the file, how about using /lib/modules/$(uname -r)/vmlinuz ?
The file is identical to /boot/vmlinuz-$(uname -r) and /boot/$(cat /etc/machine-id)/$(uname -r)/linux if they exist.

Comment 15 Yu Watanabe 2017-05-12 09:17:31 UTC
Created attachment 1278113 [details]
Patch to use /lib/modules/$(uname -r)/vmlinuz for detecting the running kernel

Comment 16 Jaroslav Mracek 2017-05-12 16:19:44 UTC
Thanks for the patch, but still dont know the root of your problem. 
I create a special testing version of libdnf just for you (dnf copr enable jmracek/kernel-test). Please install from that repo libdnf and python3-hawkey both in version 0.8.2-1.git.1511.8b133bf.fc25 or 0.8.2-1.git.1511.8b133bf.fc26.
Then try in case whet it removes running kernel and provide output from it, and uname -a as attachment.  
(filename )

Also output from script could help, but replace <filename> with string from ``/boot/vmlinuz-$(uname -r)``

#!/usr/bin/python3 -tt

import dnf, 
base = dnf.Base()
base.read_all_repos()
base.fill_sack()
print(base.sack.query().installed().filter(file=<filename>).run())



Thanks a lot. I guess that file ``/boot/vmlinuz-$(uname -r)`` is provided by two installed packages therefore the first package in query could be not running kernel.

Comment 17 Yu Watanabe 2017-05-13 06:59:01 UTC
Created attachment 1278389 [details]
4.11.0-0.rc7.git0.1.fc26.x86_64.txt

Comment 18 Yu Watanabe 2017-05-13 06:59:34 UTC
Created attachment 1278390 [details]
4.11.0-0.rc7.git0.1.fc26.x86_64-touch.txt

Comment 19 Yu Watanabe 2017-05-13 07:00:05 UTC
Created attachment 1278391 [details]
4.11.0-1.fc26.x86_64.txt

Comment 20 Yu Watanabe 2017-05-13 07:00:26 UTC
Created attachment 1278392 [details]
4.11.0-1.fc26.x86_64-touch.txt

Comment 21 Yu Watanabe 2017-05-13 07:04:01 UTC
The above 4 files contain the output of 'dnf update' with libdnf-0.8.2-1.git.1511.8b133bf.fc26.x86_64. The file its name ends with -touch.txt is the case /boot/vmlinuz-$(uname -r) exists.

Comment 22 Jaroslav Mracek 2017-05-14 18:26:49 UTC
Thanks a lot. The problem is in hy-iutils.c line 364.:
```
if (access(fn, F_OK)) {
        g_debug("running_kernel(): no matching file: %s.", fn);
        return -1;

```

It checks if file is there. It is possible to solve it by using your solution or by removal of this part. Thanks a lot for your cooperation and i believe it will be fixed soon.

Comment 23 Jaroslav Mracek 2017-05-15 11:14:22 UTC
I created patch that should help https://github.com/rpm-software-management/libdnf/pull/285. 
Please if you can test it here is copr repo with patch - libdnf ("dnf copr enable  rpmsoftwaremanagement/rpm-gitoverlay-1494835397.199814" )

Thanks for cooperation.

Comment 24 Yu Watanabe 2017-05-16 08:47:19 UTC
Thanks a lot! It seems to work fine for me.
==========
$ uname -r
4.9.13-201.fc25.x86_64
$ rpm -q kernel
kernel-4.9.13-201.fc25.x86_64
kernel-4.10.14-200.fc25.x86_64
kernel-4.10.13-200.fc25.x86_64
$ rpm -q dnf libdnf libsolv
dnf-2.4.1_1-1ge909bc4.fc25.noarch
libdnf-0.8.2-6g2031d90.fc25.x86_64
libsolv-0.6.27-2gd947474.fc25.x86_64
$ sudo dnf update --assumeno
Last metadata expiration check: 0:01:24 ago on Tue May 16 17:42:18 2017 JST.
Dependencies resolved.
================================================================================
 Package            Arch       Version                Repository           Size
================================================================================
Installing:
 kernel             x86_64     4.10.15-200.fc25       updates-testing      99 k
 kernel-core        x86_64     4.10.15-200.fc25       updates-testing      20 M
 kernel-modules     x86_64     4.10.15-200.fc25       updates-testing      23 M
Upgrading:
 kernel-headers     x86_64     4.10.15-200.fc25       updates-testing     1.1 M
Installing dependencies:
 kernel-devel       x86_64     4.10.15-200.fc25       updates-testing      11 M
Removing:
 kernel             x86_64     4.10.13-200.fc25       @updates              0  
 kernel-core        x86_64     4.10.13-200.fc25       @updates             53 M
 kernel-modules     x86_64     4.10.13-200.fc25       @updates             22 M

Transaction Summary
================================================================================
Install  4 Packages
Upgrade  1 Package
Remove   3 Packages

Total size: 55 M
Operation aborted.

Comment 25 Fedora Update System 2017-05-22 12:42:28 UTC
dnf-plugins-extras-2.0.1-1.fc26 dnf-plugins-core-2.1.0-1.fc26 libdnf-0.9.0-1.fc26 dnf-2.5.0-1.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-92e5a01da8

Comment 26 Fedora Update System 2017-05-22 16:40:46 UTC
dnf-2.5.0-1.fc26, dnf-plugins-core-2.1.0-1.fc26, dnf-plugins-extras-2.0.1-1.fc26, libdnf-0.9.0-1.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-92e5a01da8

Comment 27 Fedora Update System 2017-05-24 08:33:27 UTC
dnf-2.5.0-1.fc26 dnf-plugins-core-2.1.0-1.fc26 dnf-plugins-extras-2.0.1-1.fc26 dnfdaemon-0.3.17-3.fc26 libdnf-0.9.0-1.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-92e5a01da8

Comment 28 Fedora Update System 2017-05-24 14:34:01 UTC
dnf-2.5.0-2.fc26 dnf-plugins-core-2.1.0-1.fc26 dnf-plugins-extras-2.0.1-1.fc26 dnfdaemon-0.3.18-1.fc26 libdnf-0.9.0-1.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-92e5a01da8

Comment 29 Fedora Update System 2017-05-25 19:18:20 UTC
dnf-2.5.0-2.fc26, dnf-plugins-core-2.1.0-1.fc26, dnf-plugins-extras-2.0.1-1.fc26, dnfdaemon-0.3.18-2.fc26, libdnf-0.9.0-1.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-92e5a01da8

Comment 30 Fedora Update System 2017-06-09 19:06:57 UTC
dnf-2.5.0-2.fc26, dnf-plugins-core-2.1.0-1.fc26, dnf-plugins-extras-2.0.1-1.fc26, dnfdaemon-0.3.18-2.fc26, libdnf-0.9.0-1.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.