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>
54 lines
2.2 KiB
Desktop File
54 lines
2.2 KiB
Desktop File
[Unit]
|
|
Description=Refresh apt package lists (for kernelwatch)
|
|
# Pulled in by kernelwatch-agent.service before each report, so updates show up
|
|
# within the hour instead of whenever apt-daily next refreshes the lists (on
|
|
# Debian, by default, never). Enabled by `install.sh --with-apt-update`.
|
|
ConditionPathExists=/etc/kernelwatch/apt-update
|
|
Wants=network-online.target
|
|
After=network-online.target
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
# Same as `apt-get update`: downloads lists, installs nothing. A failure (no
|
|
# network, lock held by an admin's apt run) fails this unit but not the report,
|
|
# since kernelwatch-agent.service only Wants= it. The stamp then stops moving
|
|
# and the dashboard flags the lists as old.
|
|
ExecStart=/usr/bin/apt-get -q update
|
|
# Reached only when apt succeeded. It's the stamp Ubuntu's update-notifier hook
|
|
# writes after every successful apt update, and the agent reads it as the lists'
|
|
# age; Debian has nothing else that writes it. lists/partial, the agent's last
|
|
# resort, changes even when the update fails.
|
|
ExecStartPost=/bin/sh -c 'mkdir -p /var/lib/apt/periodic && touch /var/lib/apt/periodic/update-success-stamp'
|
|
# Records how the run ended, success or not, so the agent can report failures,
|
|
# which are otherwise silent while apt-daily keeps the lists fresh.
|
|
ExecStopPost=/usr/local/sbin/kernelwatch-unit-result apt-update
|
|
RuntimeDirectory=kernelwatch
|
|
RuntimeDirectoryMode=0755
|
|
RuntimeDirectoryPreserve=yes
|
|
UMask=0022
|
|
TimeoutStartSec=5min
|
|
Nice=10
|
|
IOSchedulingClass=idle
|
|
|
|
# apt needs root to write /var/lib/apt and drops to _apt for downloads, so this
|
|
# runs as root (the default) but loses everything apt update doesn't touch.
|
|
# Don't add User=root: with it, NoNewPrivileges and any of the seccomp-based
|
|
# options below, apt 2.7+ (Ubuntu 24.04, Debian 13) can't switch to _apt
|
|
# ("seteuid 42 failed - seteuid (1: Operation not permitted)") and every update
|
|
# fails.
|
|
NoNewPrivileges=yes
|
|
ProtectHome=yes
|
|
PrivateTmp=yes
|
|
PrivateDevices=yes
|
|
ProtectKernelTunables=yes
|
|
ProtectKernelModules=yes
|
|
ProtectKernelLogs=yes
|
|
ProtectControlGroups=yes
|
|
ProtectClock=yes
|
|
ProtectHostname=yes
|
|
RestrictNamespaces=yes
|
|
RestrictRealtime=yes
|
|
LockPersonality=yes
|
|
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
|
|
SystemCallArchitectures=native
|