Bug 2293047 - akmods wants to process a kernel 3 times
Summary: akmods wants to process a kernel 3 times
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 39
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
Assignee: Nicolas Chauvet (kwizart)
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-06-19 09:07 UTC by customercare
Modified: 2024-08-23 15:25 UTC (History)
21 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-08-23 12:52:44 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description customercare 2024-06-19 09:07:27 UTC
Description of problem:

Kernels with modules:

[root@fileserver modules]# ll
insgesamt 12
drwxr-xr-x. 8 root root 4096 14. Jun 16:03 6.8.11-200.fc39.x86_64
drwxr-xr-x. 8 root root 4096 14. Jun 16:01 6.8.5-201.fc39.x86_64
drwxr-xr-x. 8 root root 4096 18. Jun 02:03 6.9.4-100.fc39.x86_64

Boot :


insgesamt 384456
-rw-r--r--. 1 root root   272188 26. Mai 02:00 config-6.8.11-200.fc39.x86_64
-rw-r--r--. 1 root root   271926 11. Apr 02:00 config-6.8.5-201.fc39.x86_64
-rw-r--r--. 1 root root   274094 12. Jun 02:00 config-6.9.4-100.fc39.x86_64
drwx------. 4 root root     4096  1. Jan 1970  efi
drwxr-xr-x. 2 root root     4096 17. Apr 12:01 extlinux
drwx------. 4 root root     4096  2. Mai 12:57 grub2
-rw-------. 1 root root 83396891 11. Jan 2020  initramfs-0-rescue-b30d1bda8be149adae20f41026fa02d8.img
-rw-------. 1 root root 75559201  1. Jun 12:02 initramfs-6.8.11-200.fc39.x86_64.img
-rw-------. 1 root root 75368152 17. Apr 12:09 initramfs-6.8.5-201.fc39.x86_64.img
-rw-------. 1 root root 75584594 18. Jun 02:02 initramfs-6.9.4-100.fc39.x86_64.img
drwxr-xr-x. 3 root root     4096 11. Jan 2020  loader
drwx------. 2 root root    16384 11. Jan 2020  lost+found
-rw-r--r--. 1 root root   148992  7. Jan 01:00 memtest86+x64.efi
lrwxrwxrwx. 1 root root       46  1. Jun 12:02 symvers-6.8.11-200.fc39.x86_64.xz -> /lib/modules/6.8.11-200.fc39.x86_64/symvers.xz
lrwxrwxrwx. 1 root root       45 17. Apr 12:09 symvers-6.8.5-201.fc39.x86_64.xz -> /lib/modules/6.8.5-201.fc39.x86_64/symvers.xz
-rw-r--r--. 1 root root   163076 18. Jun 02:02 symvers-6.9.4-100.fc39.x86_64.xz
-rw-r--r--. 1 root root  9022570 26. Mai 02:00 System.map-6.8.11-200.fc39.x86_64
-rw-r--r--. 1 root root  8902335 11. Apr 02:00 System.map-6.8.5-201.fc39.x86_64
-rw-r--r--. 1 root root  9043497 12. Jun 02:00 System.map-6.9.4-100.fc39.x86_64
-rwxr-xr-x. 1 root root  9323208 11. Jan 2020  vmlinuz-0-rescue-b30d1bda8be149adae20f41026fa02d8
-rwxr-xr-x. 1 root root 15650632 26. Mai 02:00 vmlinuz-6.8.11-200.fc39.x86_64
-rwxr-xr-x. 1 root root 14860104 11. Apr 02:00 vmlinuz-6.8.5-201.fc39.x86_64
-rwxr-xr-x. 1 root root 15776104 12. Jun 02:00 vmlinuz-6.9.4-100.fc39.x86_64



BUT:

[root@fileserver modules]# akmods-shutdown 
Building modules for all installed kernels.
Checking kmods exist for 6.8.11-200.fc39.x86_64            [  OK  ]
Checking kmods exist for 6.9.4-100.fc39.x86_64             [  OK  ]
Checking kmods exist for 6.8.5-201.fc39.x86_64             [  OK  ]
Checking kmods exist for 6.9.4-100.fc39.x86_64             [  OK  ] <= 
Checking kmods exist for 6.9.4-100.fc39.x86_64             [  OK  ] <= 


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


Name        : akmods
Version     : 0.5.8
Release     : 6.fc39
Architecture: noarch
Install Date: Mi 17 Apr 2024 12:05:29 CEST

Comment 1 Nicolas Chauvet (kwizart) 2024-06-19 18:29:15 UTC
Unless you can come with a solution, I'm more willing to delete the akmods-shutdown script completely. 
I don't get why this is still here and it unsupported mechanism.

Comment 2 customercare 2024-06-22 12:08:41 UTC
It's not the fault of akmods.. 
 
Thanks to you, mentioning that it's a script, I took a look and the script is fine, it's the kernels package fault.

Today i have this different output:


# akmods-shutdown 
Building modules for all installed kernels.
Checking kmods exist for 6.8.11-200.fc39.x86_64            [  OK  ]
Checking kmods exist for 6.9.5-100.fc39.x86_64             [  OK  ]
Kernel 6.8.8-100.fc38.x86_64 not installed
Kernel 6.8.9-100.fc38.x86_64 not installed
Checking kmods exist for 6.9.4-100.fc39.x86_64             [  OK  ]
Checking kmods exist for 6.9.5-100.fc39.x86_64             [  OK  ]
Checking kmods exist for 6.9.5-100.fc39.x86_64             [  OK  ]


because, the old kernel packages did not delete theire directories proper:

[root@eve ~]# ls -ls /usr/src/kernels/
insgesamt 20
4 drwxr-xr-x. 25 root root 4096 22. Jun 10:02 6.8.11-200.fc39.x86_64
4 drwxr-xr-x. 25 root root 4096 10. Mai 10:02 6.8.8-100.fc38.x86_64
4 drwxr-xr-x. 25 root root 4096 10. Mai 10:01 6.8.9-100.fc38.x86_64
4 drwxr-xr-x. 25 root root 4096 22. Jun 10:02 6.9.4-100.fc39.x86_64
4 drwxr-xr-x. 25 root root 4096 22. Jun 10:02 6.9.5-100.fc39.x86_64

All the script does it, going throu the list of kernels and call the build procedure and a wrong fully assumption, that the content of /u/s/kernels if ok, which it is clearly not.

kernel-core-6.8.11-200.fc39.x86_64
kernel-core-6.9.4-100.fc39.x86_64
kernel-core-6.9.5-100.fc39.x86_64

I switch the component of this bugreport over to the kernel team which can invest theire post-uninstall script and/or give it the rpm team.

Comment 3 customercare 2024-06-22 12:37:50 UTC
@Nicolas kwizart:

The mentioned triple naming of the new default kernel is caused by this:


init ()
...
        if ! $(echo "${kernels}" | grep -q "${default_kernel}") ; then
                kernels="${kernels} ${default_kernel}"
        fi

it wrongfully adds the default kernel to the list of kernels to check, even if one explicit kernel is given with --kernels options to akmods. 

the argument loop also contains a mistake:

                        # overwrites the default:
                        if [[ ! -n "${kernels}" ]] ; then
                                kernels="${1}"
                        else 
                                kernels="${kernels} ${1}"
                        fi

This code runs before init() is called, which should set "the default" it shall overwrite there. 

Simple fix: move init() before the argument parser loop.

/usr/sbin/akmods

Line 604 a.f.
+# Call INIT to INIT the defaults, that are overwritten in the argument parser!
+init
+
+
# first parse command line options
while [ "${1}" ] ; do

...

# sanity checks
- init
+# init


Proof of Fix:

[root@eve kernels]# /usr/sbin/akmods --kernels 6.9.4-100.fc39.x86_64
Checking kmods exist for 6.9.4-100.fc39.x86_64             [  OK  ]
Checking kmods exist for 6.9.5-100.fc39.x86_64             [  OK  ]
Checking kmods exist for 6.9.4-100.fc39.x86_64             [  OK  ]


@kernelTeam: That does not explain why f38 kernels have been left over in /usr/src/kernels
But i have my feelings this caused all the trouble:

https://bugzilla.redhat.com/show_bug.cgi?id=2280808

Comment 4 Nicolas Chauvet (kwizart) 2024-07-04 07:00:47 UTC
Thanks for the fix. I've push your change into the akmods package (that is the upstream, there is no separate official git remote for this component)

I will push an update for f39+ hopefully in a few...

Comment 5 Nicolas Chauvet (kwizart) 2024-08-21 07:11:01 UTC
Note: this "init move" seems to have caused a regression in the way akmods checks for permissions. (akmods --help now requires perm to access /boot/grub2/grubenv)

I will need to revisit...

Comment 6 Nicolas Chauvet (kwizart) 2024-08-23 12:42:51 UTC
So if I understand correctly, when the --kernels is given, we end in the situation where the same value can be taken from:
- kernels=$(uname -r) 
- default_kernel
- parsed --kernel parameters

Now I don't get why init() would override any default since the default value is empty (kernels= at line44)  and init() should only override to uname -r if no value are parsed. (so if kernels remains empty).

That been said /usr/sbin/akmods --kernels "$(uname -r)" only shows one kernel in my case:
sudo akmods --kernels $(uname -r)
Checking kmods exist for 6.10.5-200.fc40.x86_64

So I'm not reproducing...

Comment 7 Fedora Update System 2024-08-23 12:48:30 UTC
FEDORA-2024-de149af836 (akmods-0.5.10-1.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-de149af836

Comment 8 Fedora Update System 2024-08-23 12:52:44 UTC
FEDORA-2024-de149af836 (akmods-0.5.10-1.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 9 Nicolas Chauvet (kwizart) 2024-08-23 15:14:20 UTC
okay, it seems akmods-shutdown is broken beyound repair

# akmods-shutdown 
Building modules for all installed kernels.
/usr/sbin/akmods --kernels 5.17.3-300.fc36.x86_64
/usr/sbin/akmods --kernels 5.17.3-302.fc36.x86_64
/usr/sbin/akmods --kernels 5.17.5-300.fc36.x86_64
/usr/sbin/akmods --kernels 6.10.4-200.fc40.x86_64
/usr/sbin/akmods --kernels 6.10.5-200.fc40.x86_64
/usr/sbin/akmods --kernels 6.9.10-200.fc40.x86_64

Now It may lead to akmods breaking on kernels without any kernel-devel installed (or even, known broken kernel that will fails the kmod).

If one wants to run on shutdown, I will switch the akmod-shutdown.service to default to use akmod instead.

Comment 10 Fedora Update System 2024-08-23 15:22:08 UTC
FEDORA-2024-b68cf9dd25 (akmods-0.5.10-6.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-b68cf9dd25

Comment 11 Fedora Update System 2024-08-23 15:25:46 UTC
FEDORA-2024-b68cf9dd25 (akmods-0.5.10-6.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.