Report when kernelwatch's own helper units keep failing

kernelwatch-apt-update.service failed hourly on most hosts for weeks
without anything showing it. The agent only Wants= its helper units, so
the report goes out regardless, with stale lists or (for needrestart)
results that quietly turn "unknown".

Each helper (apt-update, needrestart) now runs kernelwatch-unit-result
as its ExecStopPost=, which systemd runs after failed runs too. It
writes "RESULT EXIT_CODE EXIT_STATUS FAILURES" to
/run/kernelwatch/<name>.result, FAILURES counting failed runs in a row.
The agent (0.10.0) reports results from the last two hours as
helper_units. On the server, one or two failures are a note (an admin's
apt can hold the lock now and then); three in a row put the host in
update, naming the unit and its exit status and pointing at journalctl.
The host page gets a "kernelwatch helpers" row.

The Livepatch unit isn't tracked: it fails by design where the snap is
installed but Livepatch isn't enabled, and Livepatch has its own check.

The apt-update unit now has RuntimeDirectory=kernelwatch (preserved,
like the others) for its result file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
patrickandClaude Opus 5.5 committed 2026-11-01 15:23:05 -05:00
1 parent ad310a4948
commit f88261d2f5
18 files changed
+303 -8

No files matched your search

+15 -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, or `/run/reboot-required` exists. |
| `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, the OS release no longer gets security updates, unattended-upgrades is enabled but hasn't succeeded in `unattended_upgrades_stale_after_days`, or the release's security repository is missing from apt or hasn't refreshed in `security_repo_stale_after_days`. |
| `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, 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
@@ -54,6 +54,20 @@ How the agent works it out:
root and a snap cgroup, so like needrestart it runs in its own unit,
`kernelwatch-livepatch.service`, which writes `/run/kernelwatch/livepatch`
before each report. It's skipped when the snap isn't installed.
- **kernelwatch's own helpers**: `kernelwatch-apt-update.service` and
`kernelwatch-needrestart.service` run as root just before each report. The
agent only `Wants=` them, so if they fail the report still goes out, with
stale lists or no needrestart results, and nothing would say why. So each one
records how its run ended (`ExecStopPost=kernelwatch-unit-result`, in
`/run/kernelwatch/<name>.result`), counting failures in a row, and the agent
reports it. One or two failures are a note, since one run can fail now and
then (an admin's apt holding the lock). Three in a row, about three hours,
put the host in `update`: "kernelwatch-apt-update.service failed its last 3
runs (exit status 100); see journalctl -u kernelwatch-apt-update.service".
The host page's "kernelwatch helpers" row shows each one. The Livepatch unit
isn't tracked: it fails by design where the snap is installed but Livepatch
isn't enabled, and Livepatch has its own check. Agents before 0.10.0 don't
report it.
- **Agent version**: each report includes it. Hosts running an older agent
than the server shipped with get a note to run `agent/deploy.sh`; their status
isn't changed.