feat(pkg-cache): CT130 self-check timer (stop nginx+registry when the cache is unhealthy)

pkg-cache/pkgcache-selfcheck.{sh,service,timer}: every 60 s check rw mounts, write+fsync+delete
and a fresh fetch through nginx; on failure stop nginx + registry so clients fail over to the
origin instantly (connection refused); restart after 3 healthy runs + nginx -t. Never fsck.
Alert = Uptime Kuma monitors 53/54 going DOWN. Deployed on CT130 2026-11-29.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-29 07:23:46 -08:00
1 parent a971412243
commit 8107b29e14
5 files changed
+236

No files matched your search

+8
View File
@@ -250,6 +250,14 @@ report: setup key / route pending).
## Operating the cache (CT130)
- **Self-check (`pkg-cache/`).** `pkgcache-selfcheck.timer` runs `/usr/local/sbin/pkgcache-selfcheck` every 60 s. Background: on 2026-11-26 the CT's ext4 images went `emergency_ro` and nginx answered an empty reply for anything uncached, so clients' dnf failed instead of falling back.
- Checks: `/` and `/srv/cache` mounted rw; write+fsync+delete on both; a refresh fetch through nginx of a tiny metadata file (10 s; one retry).
- On failure: stops nginx and `docker-registry`, so clients get connection refused and fall back within a second. It logs at `daemon.err` (`journalctl -t pkgcache-selfcheck`). If the origin is unreachable too it only warns.
- Alert: Uptime Kuma monitors 53 and 54 (https://100.123.207.73/ and :5000/v2/) go DOWN because the services are stopped. No webhook is configured on CT130.
- Recovery: only for services it stopped. 3 consecutive fully healthy runs and a good `nginx -t`, then it starts them and re-checks the fetch.
- It never runs fsck or remounts. After `emergency_ro` an operator still has to fix the disks (see the 2026-11-26 incident) and the self-check restarts the services on its own.
- Install: copy the script to `/usr/local/sbin/pkgcache-selfcheck` (0755) and the two units to `/etc/systemd/system/`, then `systemctl enable --now pkgcache-selfcheck.timer`. State is in `/run/pkgcache-selfcheck/`.
- **nginx config.**
- `/etc/nginx/conf.d/pkgcache-http.conf` holds the cache zone, maps and log format.
- `/etc/nginx/pkgcache/{server-common,meta,pkg}.conf` hold the shared settings.