host_status: a reboot is reported when the newest RPM kernel already runs (5.1.el9uek vs 5.el9uek) #109

Closed
opened 2026-11-12 10:01:15 +00:00 by christianmanivong · 0 comments
Owner

What happens

build-arm-01 (Oracle Linux 9.8) reports reboot_required with this reason:

kernel 6.12.0-208.112.5.el9uek.aarch64 installed, 6.12.0-208.112.5.1.el9uek.aarch64 running

The running kernel, …112.5.1, is the newest of the three installed (207.111.5.6, 208.112.5, 208.112.5.1). The host was rebooted at about 09:00 on 2026-11-12, and a reboot does not clear the warning.

Cause

_version_key in host_status.py splits a version into digit runs and the text between them. Python then compares the text parts as plain strings:

6.12.0-208.112.5.el9uek   -> (..., 112, '.', 5, '.el', 9, 'uek')
6.12.0-208.112.5.1.el9uek -> (..., 112, '.', 5, '.', 1, '.el', 9, 'uek')

'.el' > '.', so kernel_reboot_pending takes 112.5 to be newer. rpm's own comparison (rpmvercmp) sees it the other way round: after 5 comes 1 on one side and el on the other, and a numeric segment beats an alpha segment, so 112.5.1 is newer.

Reproduce:

kernel_reboot_pending(
    "6.12.0-208.112.5.1.el9uek.aarch64",
    ["6.12.0-208.112.5.el9uek.aarch64", "6.12.0-208.112.5.1.el9uek.aarch64"],
)  # returns 6.12.0-208.112.5.el9uek.aarch64; should be None

Fix direction

Compare segments the way rpmvercmp does: separators carry no weight, a numeric segment is newer than an alpha one, and when one version runs out of segments it is the older. Debian's kernels (6.8.0-142-generic) keep their order under this rule.

Found while fixing #107.

## What happens build-arm-01 (Oracle Linux 9.8) reports `reboot_required` with this reason: > kernel 6.12.0-208.112.5.el9uek.aarch64 installed, 6.12.0-208.112.5.1.el9uek.aarch64 running The running kernel, `…112.5.1`, is the newest of the three installed (`207.111.5.6`, `208.112.5`, `208.112.5.1`). The host was rebooted at about 09:00 on 2026-11-12, and a reboot does not clear the warning. ## Cause `_version_key` in `host_status.py` splits a version into digit runs and the text between them. Python then compares the text parts as plain strings: ``` 6.12.0-208.112.5.el9uek -> (..., 112, '.', 5, '.el', 9, 'uek') 6.12.0-208.112.5.1.el9uek -> (..., 112, '.', 5, '.', 1, '.el', 9, 'uek') ``` `'.el' > '.'`, so `kernel_reboot_pending` takes `112.5` to be newer. rpm's own comparison (`rpmvercmp`) sees it the other way round: after `5` comes `1` on one side and `el` on the other, and a numeric segment beats an alpha segment, so `112.5.1` is newer. Reproduce: ```python kernel_reboot_pending( "6.12.0-208.112.5.1.el9uek.aarch64", ["6.12.0-208.112.5.el9uek.aarch64", "6.12.0-208.112.5.1.el9uek.aarch64"], ) # returns 6.12.0-208.112.5.el9uek.aarch64; should be None ``` ## Fix direction Compare segments the way rpmvercmp does: separators carry no weight, a numeric segment is newer than an alpha one, and when one version runs out of segments it is the older. Debian's kernels (`6.8.0-142-generic`) keep their order under this rule. Found while fixing #107.
christianmanivong added the
prio
P2
bug
labels 2026-11-12 10:01:15 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-device-types#109