Flag a /boot too full for the next kernel and packages dpkg left unfinished #25

Merged
patrick merged 1 commits from feat/boot-space-dpkg-audit into main 2026-10-31 23:26:42 +00:00
Owner

Problem

When /boot fills up, the next kernel's install script fails part-way. apt is left half-done, and the host quietly stays on its old kernel. kernelwatch noticed this only indirectly, if at all: the new kernel never shows up as installed, so nothing says a reboot is due.

Changes

Agent (0.6.0) sends three new fields:

  • boot_size_kb / boot_free_kb: from df -Pk /boot. When /boot isn't its own partition, that's the root filesystem. null if df fails or prints something unexpected.
  • dpkg_unfinished_packages: packages in the dpkg status database that are half-installed, unpacked, half-configured, waiting on triggers, or flagged reinst-required. These are the states dpkg --audit reports. Read-only, so it works as the unprivileged agent user.

Server:

  • A host goes to update when /boot has less than boot_min_free_mb free: "/boot has 95 MB free, 81% used; the next kernel may not fit". The new setting defaults to 200; 0 disables it.
  • A host goes to update when any package is unfinished: "N packages not fully installed: …; run dpkg --configure -a".
  • Both show on the host page ("/boot free", "Unfinished dpkg packages").
  • The existing status alert ("in update for status_alert_after_hours") covers both, so no new alert type.
  • Agents before 0.6.0 send neither field and are judged as before.

Docs: README status table, a new section in docs/how-it-works.md with the fix for each (apt autoremove --purge, dpkg --configure -a), and boot_min_free_mb in server.toml.example.

Notes

  • A report taken while apt is mid-install can briefly list packages as unfinished. The next hourly report clears it, and the 24h alert delay keeps it from sending an alert.
  • 200 MB fits a typical Ubuntu kernel plus initramfs (often 100–150 MB together). Raise it if your initramfs images are larger.

Testing

  • make test: 254 tests pass.
  • New tests cover agent df parsing (normal, failure, garbage), each dpkg state (half-configured, unpacked, reinst-required, triggers, and ii/rc correctly ignored), the status reasons and thresholds (including truncation past five packages), boot_min_free_mb validation, and the host page.
  • shellcheck wasn't available locally; CI runs it.

Deploying

Upgrade the server, then run agent/deploy.sh across the fleet. Until each agent is upgraded, its host shows the usual "agent is older" note.

🤖 Generated with Claude Code

## Problem When `/boot` fills up, the next kernel's install script fails part-way. apt is left half-done, and the host quietly stays on its old kernel. kernelwatch noticed this only indirectly, if at all: the new kernel never shows up as installed, so nothing says a reboot is due. ## Changes **Agent (0.6.0)** sends three new fields: - `boot_size_kb` / `boot_free_kb`: from `df -Pk /boot`. When `/boot` isn't its own partition, that's the root filesystem. `null` if df fails or prints something unexpected. - `dpkg_unfinished_packages`: packages in the dpkg status database that are half-installed, unpacked, half-configured, waiting on triggers, or flagged reinst-required. These are the states `dpkg --audit` reports. Read-only, so it works as the unprivileged agent user. **Server**: - A host goes to `update` when `/boot` has less than `boot_min_free_mb` free: "/boot has 95 MB free, 81% used; the next kernel may not fit". The new setting defaults to 200; `0` disables it. - A host goes to `update` when any package is unfinished: "N packages not fully installed: …; run dpkg --configure -a". - Both show on the host page ("/boot free", "Unfinished dpkg packages"). - The existing status alert ("in `update` for `status_alert_after_hours`") covers both, so no new alert type. - Agents before 0.6.0 send neither field and are judged as before. **Docs**: README status table, a new section in `docs/how-it-works.md` with the fix for each (`apt autoremove --purge`, `dpkg --configure -a`), and `boot_min_free_mb` in `server.toml.example`. ## Notes - A report taken while apt is mid-install can briefly list packages as unfinished. The next hourly report clears it, and the 24h alert delay keeps it from sending an alert. - 200 MB fits a typical Ubuntu kernel plus initramfs (often 100–150 MB together). Raise it if your initramfs images are larger. ## Testing - `make test`: 254 tests pass. - New tests cover agent df parsing (normal, failure, garbage), each dpkg state (half-configured, unpacked, reinst-required, triggers, and `ii`/`rc` correctly ignored), the status reasons and thresholds (including truncation past five packages), `boot_min_free_mb` validation, and the host page. - shellcheck wasn't available locally; CI runs it. ## Deploying Upgrade the server, then run `agent/deploy.sh` across the fleet. Until each agent is upgraded, its host shows the usual "agent is older" note. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
patrick added 1 commit 2026-10-31 23:14:38 +00:00
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
70272efed5
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>
patrick merged commit 5a11d31e66 into main 2026-10-31 23:26:42 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: patrick/kernel-automation#25