Trust the build check over needrestart when it's conclusive

needrestart run unprivileged (the agent's DynamicUser) can't read
Ubuntu's root-only /boot images and reported a false ABI-compatible
upgrade (KSTA=2) on a 24.04 HWE host whose running build matched its
installed package. When the uname -v / package-version comparison is
conclusive, decide from it plus the newest-installed comparison and
ignore needrestart; fall back to needrestart only for unrecognised
build formats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
patrickandClaude Opus 5.5 committed 2026-10-17 11:31:28 -04:00
1 parent 818a2e7a1c
commit a430a13fc8
2 files changed
+37 -11

No files matched your search

+20
View File
@@ -100,6 +100,26 @@ class EvaluateTest(unittest.TestCase):
kernel_build=build, kernel_running_pkg_version=pkg)
self.assertEqual(self.level(rep).level, "ok", self.level(rep).reasons)
def test_conclusive_build_overrides_needrestart(self):
# Real 24.04.4 HWE host: needrestart (unprivileged) claimed KSTA=2, build matches.
rep = report(kernel_running="7.0.0-38-generic", kernel_newest_installed="7.0.0-38-generic",
kernel_build="#38~24.04.4-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 14 16:37:11 UTC 2",
kernel_running_pkg_version="7.0.0-38.38~24.04.4", needrestart_ksta=2)
self.assertEqual(self.level(rep).level, "ok", self.level(rep).reasons)
rep["needrestart_ksta"] = 3
self.assertEqual(self.level(rep).level, "ok")
# ...but a newer installed kernel still counts.
rep["kernel_newest_installed"] = "7.0.0-40-generic"
self.assertIn("7.0.0-40-generic installed", self.level(rep).reasons[0])
def test_mixed_ga_and_hwe_kernels(self):
# GA 6.8 kernels installed alongside a running HWE 7.0: 7.0 is newest, so no kernel flag.
rep = report(kernel_running="7.0.0-38-generic", kernel_newest_installed="7.0.0-38-generic",
kernels_installed=["6.8.0-147-generic", "7.0.0-38-generic"],
kernel_build="#38~24.04.4-Ubuntu SMP", kernel_running_pkg_version="7.0.0-38.38~24.04.4",
needrestart_ksta=0)
self.assertEqual(self.level(rep).level, "ok")
def test_unrecognised_build_falls_back(self):
rep = report(needrestart_ksta=None, kernel_build="#1 SMP custom",
kernel_running_pkg_version="1.0", kernel_newest_installed="6.12.60+deb13-amd64")