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

+12
View File
@@ -134,9 +134,15 @@ NEEDRESTART_MAX_AGE=7200
# Sets NR_* from the results file, if it's there and fresh. KSTA: 0 unknown,
# 1 current, 2 ABI-compatible upgrade pending, 3 version upgrade pending.
# UCSTA (CPU microcode, bare metal only; needrestart skips it in VMs): 0 unknown,
# 1 current, 2 a newer revision is installed but needs a reboot to load. UCCUR
# and UCEXP are the loaded and installed revisions.
NR_OK=0
NR_KSTA=
NR_KEXP=
NR_UCSTA=
NR_UCCUR=
NR_UCEXP=
NR_SVCS=
NR_SESS=0
read_needrestart() {
@@ -148,6 +154,9 @@ read_needrestart() {
case $line in
NEEDRESTART-KSTA:*) NR_KSTA=${line#*: } ;;
NEEDRESTART-KEXP:*) NR_KEXP=${line#*: } ;;
NEEDRESTART-UCSTA:*) NR_UCSTA=${line#*: } ;;
NEEDRESTART-UCCUR:*) NR_UCCUR=${line#*: } ;;
NEEDRESTART-UCEXP:*) NR_UCEXP=${line#*: } ;;
NEEDRESTART-SVC:*) NR_SVCS+=${line#*: }$'\n' ;;
NEEDRESTART-SESS:*) NR_SESS=$((NR_SESS + 1)) ;;
esac
@@ -439,6 +448,9 @@ build_report() {
printf '"kernel_newest_installed":%s,' "$(json_str "$newest")"
printf '"needrestart_ksta":%s,' "$(json_int "$NR_KSTA")"
printf '"needrestart_kexp":%s,' "$(json_str "$NR_KEXP")"
printf '"needrestart_ucsta":%s,' "$(json_int "$NR_UCSTA")"
printf '"needrestart_uccur":%s,' "$(json_str_or_null "$NR_UCCUR")"
printf '"needrestart_ucexp":%s,' "$(json_str_or_null "$NR_UCEXP")"
if ((NR_OK)); then
printf '"services_need_restart":%s,' "$(sort -u <<<"$NR_SVCS" | json_str_array)"
printf '"sessions_need_restart":%s,' "$NR_SESS"