1
0
Fork 0
Commit graph

7 commits

Author SHA1 Message Date
c178285651 raise forgejo_down alert duration from 5 to 15 min
The nightly reboot at 04:30 UTC takes ~7 min of downtime (cloud-init,
image pulls, container startup) and was tripping the 5-min alert. Jason
is fine with longer downtime overnight and prefers no page for it.

15 min still catches a stuck reboot or a real outage with reasonable
latency.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 09:08:01 -04:00
0890a62b46 forgejo-stack: stop fighting docker's restart policy; add watchdog
The two recent outages had two distinct root causes, both stemming from
`--restart=unless-stopped` on the three containers:

1. rm/run race: container metadata under /var/lib/docker/containers
   persists across reboot. The daemon restores it asynchronously after
   docker.service reports active, so the service's ExecStartPre rm -f
   ran in a window where the containers were invisible to the daemon
   (no-op), then `docker run --name caddy` later collided with the
   just-restored container.
2. Bind-mount-before-mount race: docker's auto-restart of the previously
   running containers happened *before* the mount unit activated
   /mnt/disks/forgejo-data. The forgejo container ended up with `/data`
   bind-mounted to the empty underlying mount-point directory on the
   root fs, shadowed once the disk finally mounted -- presenting the
   fresh-install setup screen despite the real DB sitting untouched on
   /dev/sdb.

Drop --restart=unless-stopped and let systemd be the single owner of the
container lifecycle. Add --rm so containers don't persist on disk after
exit. Replace docker's mid-day auto-restart with a 1-minute watchdog
timer that restarts forgejo-stack.service if any container goes missing.
Add OnFailure=forgejo-stack-recover.service so a boot-time failure
self-heals after a 60s delay instead of waiting for me to notice.

Note: /etc on COS is overlayfs with upperdir on tmpfs, so the May 9
patch never took effect on reboot -- /etc/systemd/system/* is wiped
each boot and cloud-init re-renders from the metadata user-data. The
only durable path to changing units on this VM is terraform apply.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 10:55:37 -04:00
bcf9e098a6 forgejo-stack: wait for docker container restoration before rm -f
Last night's reboot still failed because commit 71c056f's rm -f changes
were authored but never deployed to the running VM (terraform was not
re-applied after the commit). Even with that fix in place, there is a
narrow race on COS: docker.service can report active before the daemon
finishes restoring persisted containers from disk, in which case the
ExecStartPre rm -f is a no-op and the subsequent docker run collides
with the just-restored container.

Add a wait-loop ExecStartPre that polls docker ps -a for up to 30s and
breaks as soon as any of caddy/forgejo/watchtower appears. Once one is
visible, the daemon has finished restoration and rm -f reliably wins.
On a clean first boot it spins the full 30s once, then proceeds.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 09:28:30 -04:00
71c056f625 fix forgejo-stack reboot loop: rm -f containers on start and stop
The original ExecStop=docker stop left containers in Exited state, so the
next boot's ExecStart=docker run -d --name caddy collided with the still-
existing container and the unit failed at status=125. Site stayed down
across the first nightly reboot until manual cleanup.

- ExecStartPre=docker rm -f (idempotent; leading - ignores not-found)
- ExecStop=docker rm -f (actually removes on shutdown, not just stops)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 07:45:11 -04:00
af57959480 add uptime check and four alert policies
- uptime check probes https://forge.kontain.me/api/v1/version every 60s
- alert: Forgejo is down (uptime fails 5+ min)
- alert: TLS cert expiring (<7 days remaining)
- alert: data disk >80% full (hourly disk-check.timer writes DISK_HIGH to journal; log-based metric)
- alert: container logs match panic/FATAL (cos_containers log-based metric)
- all alerts email admin_email via the existing notification channel

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 21:35:43 -04:00
15ea287728 add budget alert and nightly OS-update reboot
- $10/month project budget via google_billing_budget, alerts to admin_email
- forgejo-reboot.timer at 04:30 UTC applies staged COS updates
- relocate cloud-init scripts to /var/lib/google/forgejo (COS noexec on /var)
- runbook: updated zone, script paths, added "How updates work" section

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 20:35:58 -04:00
4dc1b58f2f initial commit
Signed-off-by: Jason Hall <imjasonh@gmail.com>
2026-05-07 20:02:59 -04:00