fix(host-status): kernel releases compare the way rpm does (4.36.2) #110

Merged
christianmanivong merged 2 commits from fix/rpm-kernel-version-order into main 2026-11-12 10:08:49 +00:00
Owner

Closes #109

Problem: kernel_reboot_pending ordered kernel releases with _version_key. That function compares the text between the numbers as plain strings, so '.el' > '.' and 6.12.0-208.112.5.el9uek counted as newer than the running 6.12.0-208.112.5.1.el9uek. build-arm-01 asks to reboot into an older kernel, and a reboot never clears it.

Fix: _version_cmp follows rpm's rpmvercmp:

  • A release splits into runs of digits, runs of letters and ~. Everything else only separates them.
  • Numbers compare as numbers, letters as text. A number is newer than letters in the same place.
  • Where one release ends and the other goes on, the longer one is newer, unless its next segment is ~, which comes before anything. That is also how dpkg orders a release candidate.

Tests: three new cases in TestKernelRebootPending:

  • UEK with 112.5.1 running: no reboot.
  • UEK with 112.5 running: reboot into 112.5.1.
  • A ~rc kernel before its release.

The existing Debian, Proxmox, Arch, Raspberry Pi and Fedora cases still pass. Full suite: 1618 passed; ruff and mypy are clean.

Live check: 12 pairs compared on build-arm-01 with rpm.labelCompare give the same results as _version_cmp. The pairs include 112.5.1.el9uek/112.5.el9uek, el9_4/el9, 1.0/1, 1.0a/1.0 and ~rc5.

4.36.2: patch release, no API change.

Closes #109 **Problem:** `kernel_reboot_pending` ordered kernel releases with `_version_key`. That function compares the text between the numbers as plain strings, so `'.el' > '.'` and `6.12.0-208.112.5.el9uek` counted as newer than the running `6.12.0-208.112.5.1.el9uek`. build-arm-01 asks to reboot into an older kernel, and a reboot never clears it. **Fix:** `_version_cmp` follows rpm's `rpmvercmp`: - A release splits into runs of digits, runs of letters and `~`. Everything else only separates them. - Numbers compare as numbers, letters as text. A number is newer than letters in the same place. - Where one release ends and the other goes on, the longer one is newer, unless its next segment is `~`, which comes before anything. That is also how dpkg orders a release candidate. **Tests:** three new cases in `TestKernelRebootPending`: - UEK with `112.5.1` running: no reboot. - UEK with `112.5` running: reboot into `112.5.1`. - A `~rc` kernel before its release. The existing Debian, Proxmox, Arch, Raspberry Pi and Fedora cases still pass. Full suite: 1618 passed; ruff and mypy are clean. **Live check:** 12 pairs compared on build-arm-01 with `rpm.labelCompare` give the same results as `_version_cmp`. The pairs include `112.5.1.el9uek`/`112.5.el9uek`, `el9_4`/`el9`, `1.0`/`1`, `1.0a`/`1.0` and `~rc5`. 4.36.2: patch release, no API change.
christianmanivong added 1 commit 2026-11-12 10:04:03 +00:00
fix(host-status): kernel releases compare the way rpm does (4.36.2)
driver / lint (pull_request) Successful in 13s
driver / standard (pull_request) Failing after 15s
driver / types (pull_request) Successful in 1m5s
driver / test (3.13) (pull_request) Successful in 1m14s
driver / test (3.12) (pull_request) Successful in 1m19s
driver / lowest (pull_request) Successful in 42s
driver / build (pull_request) Successful in 28s
driver / security (pull_request) Successful in 1m3s
CI / driver (pull_request) Failing after 2m32s
driver / publish (pull_request) Skipped
cf555d006d
_version_key compared the text between numbers as plain strings, so
'.el' outranked '.' and 6.12.0-208.112.5.el9uek counted as newer than
the running 6.12.0-208.112.5.1.el9uek: an Oracle Linux host asked to
reboot into an older kernel, and a reboot never cleared it. The
releases now compare like rpmvercmp: separators only separate, a
number is newer than letters in its place, and '~' comes before
anything. Checked against rpm.labelCompare on Oracle Linux 9.

Closes #109
christianmanivong added 1 commit 2026-11-12 10:05:50 +00:00
refactor(host-status): compare one version segment in a helper of its own
driver / standard (pull_request) Successful in 15s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 56s
driver / test (3.12) (pull_request) Successful in 1m8s
driver / test (3.13) (pull_request) Successful in 1m8s
driver / lowest (pull_request) Successful in 40s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 57s
CI / driver (pull_request) Successful in 2m30s
driver / publish (pull_request) Skipped
c736fb30d0
The quality ratchet refused _version_cmp at complexity 12. Comparing one
segment moves to _segment_cmp, which also takes 01 and 1 as equal, as
rpm does.
christianmanivong merged commit a8fedf299a into main 2026-11-12 10:08:49 +00:00
christianmanivong deleted branch fix/rpm-kernel-version-order 2026-11-12 10:08:49 +00:00
Sign in to join this conversation.