Bug 2448367 - akmods command: improve the logs, fix exit code
Summary: akmods command: improve the logs, fix exit code
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: akmods
Version: 43
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Nicolas Chauvet (kwizart)
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2026-03-17 14:53 UTC by Francis Montagnac
Modified: 2026-06-22 08:00 UTC (History)
7 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Francis Montagnac 2026-03-17 14:53:29 UTC
The akmods command (akmods-0.6.2-9) doesn't log properly enough:

  - if a build or install of a kmod fails, akmods output to stdout a [ OK ] at the end of the line Checking kmods exist for KERNEL
    this is misleading

  - it doesn't indicate which kmod are checked
  
  - there is no indication of the context in which akmods is called
    that makes /var/log/akmods/akmods.log of little use for debugging

I suggest thus to change the akmods command as follows (example with the kmods: v4l2loopback VirtualBox wl):

from:

    Checking kmods exist for 6.19.7-200.fc43.x86_64 [  OK  ]
    Checking kmods exist for 6.18.16-200.fc43.x86_64 [  OK  ]

to:

    Start checking kmods interactively: ALL
      for kernels: 6.19.7-200.fc43.x86_64 6.18.16-200.fc43.x86_64
      with akmods-VERSION-RELEASE
    Checking kmods exist for 6.19.7-200.fc43.x86_64
      kmod-v4l2loopback-6.19.7-200.fc43.x86_64    0.15.3-1.fc43        I [  OK  ]
      kmod-VirtualBox-6.19.7-200.fc43.x86_64      7.2.6-2.fc43         I [  OK  ]
      kmod-wl-6.19.7-200.fc43.x86_64              6.30.223.271-61.fc43 I [  OK  ]
    Checking kmods exist for 6.18.16-200.fc43.x86_64
      kmod-v4l2loopback-6.18.16-200.fc43.x86_64   0.15.3-1.fc43        I [  OK  ]
      kmod-VirtualBox-6.18.16-200.fc43.x86_64     7.2.6-2.fc43         I [  OK  ]
      kmod-wl-6.18.16-200.fc43.x86_64             6.30.223.271-61.fc43 I [  OK  ]
    End akmods: exit code: 0, elapsed time: 1 seconds, locked for 0 seconds

If called from akmods.service one would have: Start checking kmods from init ...
Similar with from kernel-posttrans ...

Also, add a blank line in /var/log/akmods/akmods.log after each call to akmods.
This will permit to get the traces in error with a simple:

  awk -v RS= -v ORS='\n\n' '/exit code: [^0]/' /var/log/akmods/akmods.log

The I before the [ OK ] means Installed. In case of failure we will output: missing U (for Uninstalled)

In addition akmods-0.6.2-9 always exit 0. Change this to exit 1 if at least one kmod fails to build or install
This will make the akmods.service fail if akmods fails, but this is in fact also better.

Finally, for debugging purpose add a -n,--dry-run option like make does.

Note: This has been initially done in:

  https://src.fedoraproject.org/rpms/akmods/pull-request/32
  https://bugzilla.redhat.com/show_bug.cgi?id=2440497


Reproducible: Always

Comment 1 Francis Montagnac 2026-03-18 10:13:54 UTC
pull-request done: https://src.fedoraproject.org/rpms/akmods/pull-request/33

Successful test with 2 kmods, that gives as /var/log/akmods/akmods.log: (note the locked duration)

    2026/03/18 10:58:40 akmods: Start checking kmods from akmod-posttrans: wl 
    2026/03/18 10:58:40 akmods:   for kernels: 6.19.7-200.fc43.x86_64 6.18.16-200.fc43.x86_64
    2026/03/18 10:58:40 akmods:   with akmods-0.6.2-9.fc43
    2026/03/18 10:58:40 akmods: Checking kmods exist for 6.19.7-200.fc43.x86_64
    2026/03/18 10:58:40 akmods:   Building and installing wl-kmod                                   
    2026/03/18 10:58:40 akmods:     Building rpms using the command '/usr/sbin/akmodsbuild --kernels 6.19.7-200.fc43.x86_64 /usr/src/akmods/wl-kmod.latest'
    2026/03/18 10:58:45 akmods:     Installing newly built rpms
    2026/03/18 10:58:45 akmods:     DNF detected
    2026/03/18 10:58:53 akmods:     Successful.
    2026/03/18 10:58:53 akmods:   kmod-wl-6.19.7-200.fc43.x86_64              6.30.223.271-61.fc43 I
    2026/03/18 10:58:53 akmods: Checking kmods exist for 6.18.16-200.fc43.x86_64
    2026/03/18 10:58:53 akmods:   Building and installing wl-kmod                                   
    2026/03/18 10:58:53 akmods:     Building rpms using the command '/usr/sbin/akmodsbuild --kernels 6.18.16-200.fc43.x86_64 /usr/src/akmods/wl-kmod.latest'
    2026/03/18 10:58:59 akmods:     Installing newly built rpms
    2026/03/18 10:58:59 akmods:     DNF detected
    2026/03/18 10:59:06 akmods:     Successful.
    2026/03/18 10:59:06 akmods:   kmod-wl-6.18.16-200.fc43.x86_64             6.30.223.271-61.fc43 I
    2026/03/18 10:59:06 akmods: Restarting systemd-modules-load.service
    2026/03/18 10:59:07 akmods: End akmods: exit code: 0, elapsed time: 27 seconds, locked for 0 seconds

    2026/03/18 10:59:07 akmods: Start checking kmods from akmod-posttrans: v4l2loopback 
    2026/03/18 10:59:07 akmods:   for kernels: 6.19.7-200.fc43.x86_64 6.18.16-200.fc43.x86_64
    2026/03/18 10:59:07 akmods:   with akmods-0.6.2-9.fc43
    2026/03/18 10:59:07 akmods: Checking kmods exist for 6.19.7-200.fc43.x86_64
    2026/03/18 10:59:07 akmods:   Building and installing v4l2loopback-kmod                         
    2026/03/18 10:59:07 akmods:     Building rpms using the command '/usr/sbin/akmodsbuild --kernels 6.19.7-200.fc43.x86_64 /usr/src/akmods/v4l2loopback-kmod.latest'
    2026/03/18 10:59:10 akmods:     Installing newly built rpms
    2026/03/18 10:59:10 akmods:     DNF detected
    2026/03/18 10:59:17 akmods:     Successful.
    2026/03/18 10:59:17 akmods:   kmod-v4l2loopback-6.19.7-200.fc43.x86_64    0.15.3-1.fc43        I
    2026/03/18 10:59:17 akmods: Checking kmods exist for 6.18.16-200.fc43.x86_64
    2026/03/18 10:59:17 akmods:   Building and installing v4l2loopback-kmod                         
    2026/03/18 10:59:17 akmods:     Building rpms using the command '/usr/sbin/akmodsbuild --kernels 6.18.16-200.fc43.x86_64 /usr/src/akmods/v4l2loopback-kmod.latest'
    2026/03/18 10:59:20 akmods:     Installing newly built rpms
    2026/03/18 10:59:20 akmods:     DNF detected
    2026/03/18 10:59:27 akmods:     Successful.
    2026/03/18 10:59:27 akmods:   kmod-v4l2loopback-6.18.16-200.fc43.x86_64   0.15.3-1.fc43        I
    2026/03/18 10:59:27 akmods: Restarting systemd-modules-load.service
    2026/03/18 10:59:28 akmods: End akmods: exit code: 0, elapsed time: 21 seconds, locked for 27 seconds

The diff (of only the akmods script) is rather big, but I don't want to split this.

I forgot to mention that I also changed the saved kmodlogfile, adding the date before .log (or .failed.log): do not loose any log.

Thoughts ?

Comment 2 Francis Montagnac 2026-03-18 10:21:04 UTC
The dry-run option permits to see trivially and *without* doing any action, the bug when giving more than one --kmod:

OK: kmod-wl-6.18.16-200.fc43.x86_64 has been checked

    akmods -n --kmod wl --kernel $(uname -r)
    Start checking kmods interactively (dry-run): wl 
      for kernels: 6.18.16-200.fc43.x86_64
      with akmods-0.6.2-9.fc43
    Checking kmods exist for 6.18.16-200.fc43.x86_64
      kmod-wl-6.18.16-200.fc43.x86_64             6.30.223.271-61.fc43 I [  OK  ]
    End akmods: exit code: 0, elapsed time: 0 seconds, locked for 0 seconds
    root@fmpc

KO: no kmods was checked:

    akmods -n --kmod wl --kmod v4l2loopback --kernel $(uname -r)
    Start checking kmods interactively (dry-run): wl v4l2loopback 
      for kernels: 6.18.16-200.fc43.x86_64
      with akmods-0.6.2-9.fc43
    Checking kmods exist for 6.18.16-200.fc43.x86_64
    End akmods: exit code: 0, elapsed time: 0 seconds, locked for 0 seconds
    root@fmpc

I did fixed that bug in the pre-install-not-as-rpm branch, but will not in this one (improve-logs).

Comment 3 Francis Montagnac 2026-03-19 06:25:01 UTC
@Nicolas Chauvet: are you okay to merge this pull-request ?

https://src.fedoraproject.org/rpms/akmods/pull-request/33

Comment 4 Francis Montagnac 2026-03-19 06:36:57 UTC
I don't see any build for this pull-request. Have I missed something ?

Thanks.

While we are at those cosmetic changes, I would like to add, just after all the functions are defined (just before
parsing the arguments):

  [[ $0 == *bash ]] && return

This permits to debug the functions with:

  ( source ./akmods || exit; FUNC ARGS )

I used that for more than 20 years in many bash system scripts I wrote (when working at Inria).

Do you agree ? Thanks.

Comment 5 Francis Montagnac 2026-03-20 06:22:17 UTC
(In reply to Francis Montagnac from comment #4)
> I don't see any build for this pull-request. Have I missed something ?

Fixed simply by doing a new commit in this branch ... weird.

Changelog:
  * Fri Mar 20 2026 Francis Montagnac <francis.montagnac> - 0.6.2-30
  - akmods: Allow debugging functions with: ( source ./akmods || exit; FUNC
    ARGS )

Builds:
  https://kojipkgs.fedoraproject.org//work/tasks/4314/143534314/akmods-0.6.2-30.fc45.noarch.rpm
  https://kojipkgs.fedoraproject.org//work/tasks/4314/143534314/akmods-0.6.2-30.fc45.src.rpm

I installed akmods-0.6.2-30.fc45.noarch.rpm on F43: it works ... of course.

Comment 6 Francis Montagnac 2026-03-21 11:06:54 UTC
2 more small commits leading to:

  https://kojipkgs.fedoraproject.org//work/tasks/7192/143567192/akmods-0.6.2-32.fc45.noarch.rpm

I don't see other changes to do in the scope of this pull-request.

Comments ?

A next pull-request. may be to wait for the end of the dnf transaction
(as dnf4 did). This is already implemented in the
pre-install-not-as-rpm branch.

Comment 7 Francis Montagnac 2026-03-24 07:05:56 UTC
@Nicolas Chauvet: when do you think to have the time to merge this pull-request ?

  https://src.fedoraproject.org/rpms/akmods/pull-request/33

(no commits since past Saturday)

Comment 8 Francis Montagnac 2026-03-30 09:23:47 UTC
Any updates for this pull-request ?

  https://src.fedoraproject.org/rpms/akmods/pull-request/33

Thanks.

Comment 9 Francis Montagnac 2026-05-10 05:18:56 UTC
May I have an answer about this PR please ?

FWIW This PR would have helped in this rfbz: https://bugzilla.rpmfusion.org/show_bug.cgi?id=7454
The reporter had lost the initial failed.log:
> cannot attach the fail log since I lost it after getting a typo bug during manual patching which completely overrode it.

Ref:
  commit 1fa0f8602f20d279f64398a27e8a83d2ce01783a
  Author: Francis Montagnac <francis.montagnac>
  Date:   Mon Mar 2 07:37:58 2026 +0100

      akmods: buildinstall_kmod: keep all logs with a date suffix before [.failed].log

Comment 10 Francis Montagnac 2026-05-13 10:25:49 UTC
FWIW This PR would have helped also in https://discussion.fedoraproject.org/t/problems-with-upgrade-to-f44-and-nvidia-gtx-970m/191189/41

Comment 11 Francis Montagnac 2026-06-22 08:00:27 UTC
No comments for this RFE for 3 months.
Should I assume that this is a NO-GO ?


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