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
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:
1 parent
4676942108
commit
8174f1df81
8 files changed
+79
-1
No files matched your search
@@ -27,6 +27,9 @@ FIELDS: dict[str, str] = {
|
||||
"kernel_newest_installed": "str",
|
||||
"needrestart_ksta": "int",
|
||||
"needrestart_kexp": "str",
|
||||
"needrestart_ucsta": "int",
|
||||
"needrestart_uccur": "str",
|
||||
"needrestart_ucexp": "str",
|
||||
"services_need_restart": "strlist",
|
||||
"sessions_need_restart": "int",
|
||||
"reboot_required": "bool",
|
||||
|
||||
@@ -30,6 +30,8 @@ LIVEPATCH_HEALTHY_STATES = ("applied", "nothing-to-apply")
|
||||
KSTA_CURRENT = 1
|
||||
KSTA_ABI_UPGRADE = 2
|
||||
KSTA_VERSION_UPGRADE = 3
|
||||
# needrestart's NEEDRESTART-UCSTA: a newer CPU microcode is installed but not loaded.
|
||||
UCSTA_OBSOLETE = 2
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -309,6 +311,11 @@ def evaluate(received_at: int | None, report: dict[str, Any] | None, now: float,
|
||||
status.raise_to("reboot", f"/run/reboot-required{detail}")
|
||||
if livepatch_note and not covered:
|
||||
status.note(livepatch_note)
|
||||
# Microcode loads at boot; Livepatch doesn't cover it.
|
||||
if report.get("needrestart_ucsta") == UCSTA_OBSOLETE:
|
||||
cur, exp = report.get("needrestart_uccur"), report.get("needrestart_ucexp")
|
||||
detail = f" ({cur} → {exp})" if cur and exp else ""
|
||||
status.raise_to("reboot", f"CPU microcode update installed but not loaded{detail}")
|
||||
|
||||
# An agent whose apt simulation failed sends no update counts, so "no security
|
||||
# updates" would be a guess. Agents before 0.5.0 don't send the field.
|
||||
|
||||
@@ -105,6 +105,16 @@ def security_repo_summary(report: dict[str, Any]) -> str | None:
|
||||
return f"{suite}, published {duration(age)} before the report"
|
||||
|
||||
|
||||
def microcode_summary(report: dict[str, Any]) -> str | None:
|
||||
state = {1: "current", 2: "update needs a reboot"}.get(report.get("needrestart_ucsta"))
|
||||
if state is None:
|
||||
return None # unknown, a VM, or no needrestart
|
||||
cur, exp = report.get("needrestart_uccur"), report.get("needrestart_ucexp")
|
||||
revs = f" (loaded {cur}, installed {exp})" if state != "current" and cur and exp else \
|
||||
f" ({cur})" if cur else ""
|
||||
return state + revs
|
||||
|
||||
|
||||
def helper_units_summary(report: dict[str, Any]) -> str | None:
|
||||
units = helper_units(report)
|
||||
if not units:
|
||||
@@ -532,6 +542,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
field("Installed kernels", r.get("kernels_installed"), code=True),
|
||||
field("needrestart", None if r.get("needrestart_ksta") is None else
|
||||
f"KSTA={r['needrestart_ksta']} expected={r.get('needrestart_kexp') or '?'}"),
|
||||
field("CPU microcode", microcode_summary(r)),
|
||||
field("Livepatch", None if r.get("livepatch_state") is None else
|
||||
f"{r['livepatch_state']}, {r.get('livepatch_fix_count') or 0} fixes applied, "
|
||||
f"{r.get('livepatch_supported') or '?'} until {r.get('livepatch_upgrade_required') or '?'}"),
|
||||
|
||||
Reference in new issue
Block a user