Skip to content

use dnf needs-restarting for rpm reboot detection - #877

Open
KrBeTect2025 wants to merge 1 commit into
furlongm:mainfrom
KrBeTect2025:fix/864-dnf-needs-restarting
Open

KrBeTect2025 wants to merge 1 commit into
furlongm:mainfrom
KrBeTect2025:fix/864-dnf-needs-restarting

Conversation

@KrBeTect2025

Copy link
Copy Markdown

On RHEL 8/9 /boot/vmlinuz is usually not a symlink, so reboot_required() falls back to ServerCheck, which protocol 2 sends as reboot_required: false. Hosts running an older kernel than the newest installed one show as not needing a reboot.

When dnf is available the client now runs dnf needs-restarting -r. dnf also exits 1 on errors, for example when the needs-restarting plugin is not installed (stock Rocky 9 prints "No such command"), so exit 1 only counts as a reboot when the output says "Reboot is required". dnf runs with LC_ALL=C so the match works on translated systems. Exit 0 means no reboot; anything else falls back to the existing checks.

Tested by running the updated reboot_required() against real dnf in containers:

  • Rocky 9 (dnf 4.14), plugin not installed: ServerCheck, as before
  • Rocky 9, plugin installed, nothing updated since boot: False
  • Rocky 9, after reinstalling glibc: True
  • Fedora 42 (dnf5), nothing updated since boot: False

./manage.py test, flake8 and isort pass.

Fixes #864

On RHEL 8/9 /boot/vmlinuz is often not a symlink, so the client fell
back to ServerCheck, which protocol 2 sends as reboot_required: false.
Hosts running an older kernel than the newest installed one were shown
as not needing a reboot.

When dnf is available, ask `dnf needs-restarting -r`, which also covers
core libraries such as glibc and systemd. dnf exits 1 both when a reboot
is required and on errors such as the needs-restarting plugin not being
installed, so exit 1 only counts when the output says a reboot is
required. Any other result falls back to the existing checks.

Fixes furlongm#864

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RPM reboot detection fails on RHEL 8/9 when /boot/vmlinuz symlink is absent

1 participant