Put hosts with unloaded CPU microcode updates in reboot
CI / tests (Python 3.10) (pull_request) Successful in 40s
CI / tests (Python 3.11) (pull_request) Successful in 39s
CI / tests (Python 3.12) (pull_request) Successful in 38s
CI / tests (Python 3.13) (pull_request) Successful in 38s
CI / lint (pull_request) Failing after 3s

On bare metal, needrestart -b reports NEEDRESTART-UCSTA: 2 when the
installed intel-microcode/amd64-microcode is newer than what the CPU
loaded at boot, which only a reboot fixes. The agent dropped those
lines. It now reports needrestart_ucsta, _uccur and _ucexp, and the
server puts the host in reboot with both revisions. Livepatch doesn't
cover it. needrestart skips the check in VMs, so only physical hosts
(debian-homelab today) report it; the host page gets a "CPU microcode"
row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
patrickandClaude Opus 5.5 committed 2026-11-01 15:25:57 -05:00
1 parent 4676942108
commit 8174f1df81
8 files changed
+79 -1

No files matched your search

+14
View File
@@ -136,6 +136,20 @@ class AgentReportTest(AgentCase):
self.assertEqual(r["services_need_restart"], ["nginx.service", "ssh.service"])
self.assertEqual(r["sessions_need_restart"], 1)
def test_needrestart_microcode(self):
self.write_needrestart("NEEDRESTART-KSTA: 1\nNEEDRESTART-UCSTA: 2\n"
"NEEDRESTART-UCCUR: 0x001e\nNEEDRESTART-UCEXP: 0x0020\n")
r = self.report()
self.assertEqual((r["needrestart_ucsta"], r["needrestart_uccur"], r["needrestart_ucexp"]),
(2, "0x001e", "0x0020"))
def test_needrestart_without_microcode_lines(self):
# Virtual machines: needrestart leaves the UC* lines out.
self.write_needrestart("NEEDRESTART-KSTA: 1\n")
r = self.report()
self.assertIsNone(r["needrestart_ucsta"])
self.assertIsNone(r["needrestart_uccur"])
def write_livepatch(self, text, age=60):
d = os.path.join(self.root, "run/kernelwatch")
os.makedirs(d, exist_ok=True)