Flag a /boot too full for the next kernel and packages dpkg left unfinished
CI / tests (Python 3.10) (pull_request) Successful in 29s
CI / tests (Python 3.11) (pull_request) Successful in 30s
CI / tests (Python 3.12) (pull_request) Successful in 29s
CI / tests (Python 3.13) (pull_request) Successful in 28s
CI / lint (pull_request) Successful in 4s

A full /boot makes the next kernel's postinst fail: apt is left half-done
and the host quietly stays on its old kernel, which kernelwatch only
noticed indirectly, if at all. The agent now reports the size and free
space of the filesystem holding /boot (df) and the packages dpkg didn't
finish installing (half-installed, unpacked, half-configured, trigger
states or reinst-required, as dpkg --audit counts them).

The server puts a host in update when /boot has less than
boot_min_free_mb (default 200, 0 disables) free, or any package is
unfinished, with the fix in the reason ("run dpkg --configure -a"). The
host page shows both. Agents before 0.6.0 send neither field and are
judged as before. Agent 0.6.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
patrickandClaude Opus 5.5 committed 2026-10-31 18:54:47 -04:00
1 parent 3e2f550414
commit 70272efed5
13 files changed
+173 -5

No files matched your search

+21
View File
@@ -146,6 +146,17 @@ def livepatch_cover(report: dict[str, Any], now: float) -> tuple[bool, str | Non
return True, f"live-patched; kernel upgrade needed by {deadline}"
def boot_space_low(report: dict[str, Any], cfg: Config) -> str | None:
"""Why /boot may be too full for the next kernel, or None. Agents before 0.6.0
don't report it, and a host whose df failed sends null; both count as fine."""
free_kb = report.get("boot_free_kb")
if not cfg.boot_min_free_mb or free_kb is None or free_kb >= cfg.boot_min_free_mb * 1024:
return None
size_kb = report.get("boot_size_kb")
used = f", {100 - free_kb * 100 // size_kb}% used" if size_kb else ""
return f"/boot has {free_kb // 1024} MB free{used}; the next kernel may not fit"
def _kernel_only_reboot_file(report: dict[str, Any]) -> bool:
"""/run/reboot-required exists only because of kernel packages."""
pkgs = report.get("reboot_required_pkgs") or []
@@ -208,6 +219,16 @@ def evaluate(received_at: int | None, report: dict[str, Any] | None, now: float,
if sec := report.get("security_count"):
status.raise_to("update", f"{sec} security update{'s' if sec != 1 else ''} pending")
# dpkg stopped part-way (usually a failed postinst, often from a full /boot), so
# whatever it was installing, maybe a kernel, isn't in place yet.
if unfinished := report.get("dpkg_unfinished_packages"):
n = len(unfinished)
more = f", +{n - 5} more" if n > 5 else ""
status.raise_to("update", f"{n} package{'s' if n != 1 else ''} not fully installed: "
f"{', '.join(unfinished[:5])}{more}; run dpkg --configure -a")
if low := boot_space_low(report, cfg):
status.raise_to("update", low)
if services := report.get("services_need_restart"):
shown = ", ".join(s.removesuffix(".service") for s in services[:5])
more = f", +{len(services) - 5} more" if len(services) > 5 else ""