Flag hosts without room on disk for their pending upgrades
CI / tests (Python 3.10) (pull_request) Successful in 43s
CI / tests (Python 3.11) (pull_request) Successful in 44s
CI / tests (Python 3.12) (pull_request) Successful in 43s
CI / tests (Python 3.13) (pull_request) Successful in 42s
CI / lint (pull_request) Successful in 3s

A filesystem that fills up while apt downloads or dpkg unpacks leaves the
upgrade half-done and apt broken, the same failure as a full /boot but on
/ or /var. Nothing caught it until the host's updates stopped.

The agent (0.11.0) now works out what the pending upgrades need. A
simulation doesn't print apt's "Need to get" or "additional disk space"
lines, so it sums the package records from apt-cache show for each version
the simulation would install: Size for each .deb not already in
/var/cache/apt/archives, and the growth in Installed-Size over the
installed versions (from dpkg-query). Removals aren't subtracted, so it
errs high. It also reports free space and the mount point of the
filesystems holding /var/cache/apt/archives and /usr.

The server puts a host in update when the upgrades would leave less than
upgrade_min_free_mb (default 100, 0 disables) on either filesystem. The
download and the install both count when they're on the same one. With
nothing pending there is nothing to check, so this doesn't turn into
general disk monitoring. The host page gets a "Pending upgrades size" row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
patrickandClaude Opus 5.5 committed 2026-11-07 20:16:54 -05:00
1 parent b5be19f85d
commit 15b1f5be4f
13 files changed
+363 -7

No files matched your search

+23 -1
View File
@@ -10,7 +10,7 @@ Each host gets one status. When several apply, the worst one wins:
|----------|---------|
| `stale` | No report in `stale_after_hours` (default 3h), or never. Other data can't be trusted. |
| `reboot` | A newer kernel is installed but not running, `/run/reboot-required` exists, or newer CPU microcode is installed but not loaded. |
| `update` | A kernel or security update is available but not installed, services are running outdated libraries and need a restart, or apt's package lists are too old (`apt_stale_after_hours`) for "no updates" to mean anything. Also when `/boot` has less than `boot_min_free_mb` free, dpkg left packages half-installed, a kernel package is on hold, the OS release no longer gets security updates, unattended-upgrades is enabled but hasn't succeeded in `unattended_upgrades_stale_after_days`, the release's security repository is missing from apt or hasn't refreshed in `security_repo_stale_after_days`, or one of kernelwatch's own helper units has failed three runs in a row. |
| `update` | A kernel or security update is available but not installed, services are running outdated libraries and need a restart, or apt's package lists are too old (`apt_stale_after_hours`) for "no updates" to mean anything. Also when `/boot` has less than `boot_min_free_mb` free, the pending upgrades would leave less than `upgrade_min_free_mb` free where apt downloads or installs them, dpkg left packages half-installed, a kernel package is on hold, the OS release no longer gets security updates, unattended-upgrades is enabled but hasn't succeeded in `unattended_upgrades_stale_after_days`, the release's security repository is missing from apt or hasn't refreshed in `security_repo_stale_after_days`, or one of kernelwatch's own helper units has failed three runs in a row. |
| `ok` | Running the newest installed kernel, with no security or kernel updates pending. |
Each row also lists the reasons behind its status, and clicking a host shows
@@ -106,6 +106,28 @@ How the agent works it out:
`boot_min_free_mb` (default 200) free puts the host in `update` with "/boot has
N MB free". Fix it on the host: `sudo apt autoremove --purge` removes old
kernels.
- **Room for the pending upgrades**: if a filesystem fills up while apt
downloads or dpkg unpacks, the upgrade stops half-way and apt is left broken,
as with a full `/boot`. Under unattended-upgrades, nobody is watching when it
happens. A
simulation doesn't print apt's "Need to get" and "additional disk space"
figures, so the agent works them out from the package records (`apt-cache
show` for each version the simulation would install). The download is the
`Size` of each `.deb` not already in `/var/cache/apt/archives`;
unattended-upgrades often downloads ahead. The install is the growth in
`Installed-Size`: the new versions' minus the installed ones', or all of it
for new packages. Packages the upgrade would remove aren't subtracted, so
the estimate errs high. The agent also reports free space and the mount
point of the filesystems holding `/var/cache/apt/archives` and `/usr`. If
they're the same filesystem, the download and the install both count against
it. A filesystem the upgrades would leave with less than
`upgrade_min_free_mb` (default 100) free puts the host in `update` with
"pending upgrades need N MB on /var (...), M MB free". Nothing pending means
nothing to check, however full the disk is. kernelwatch doesn't monitor disk
usage in general; use your usual monitoring for that. Fix it on the host:
`sudo apt clean` empties the download cache, and `sudo apt autoremove
--purge` removes old kernels' modules from `/usr/lib/modules`. Agents before
0.11.0 don't report it.
- **Unfinished packages**: packages dpkg didn't finish installing, read from its
status database (the same states `dpkg --audit` reports: half-installed,
unpacked, half-configured, waiting on triggers, or reinst-required). These are