carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1# The other half of the restore drill. carlos-restore-verify.service proves
2# every database named in /etc/litestream.yml; that config deliberately OMITS
3# hibernating instances, because the activator's embedded litestream owns
4# their replication under its lease and a second replicator on the same WAL
5# would corrupt the replica. The consequence, until this unit existed, was
6# that the fleet's largest set of app databases was the one set nobody ever
7# drilled — the first thing to learn whether a hibernating tenant's replica
8# restores clean was a real user's wake.
9#
10# This restores each of those replicas into a private tmp, integrity-checks
11# it, and publishes a per-host verdict to the deployment bucket
12# (control/restore-verify.json) so the result is readable WITHOUT a session on
13# this box. A damaged replica leaves the unit 'failed'; a replica the pass
14# could not reach is recorded 'unverified' and does not fail the run.
15#
16# Inert until /etc/carlos/host.env carries CARLOS_HIBERNATE_BUCKET — a box
17# with no hibernating instances prints that and exits 0.
18[Unit]
19Description=carlos hibernate-verify (restore-drill the activator-owned replicas)
20After=network-online.target carlos-edge.service
21Wants=network-online.target
22
23[Service]
24Type=oneshot
25# Same host-wide config the edge reads: CARLOS_HIBERNATE_* names the replica
26# set, CARLOS_DEPLOYMENT_BUCKET/_DIR is where the verdict is published.
27# Deliberately NOT /data/litestream.env — those credentials belong to the
28# box-wide replication bucket, and borrowing them here would sign for the
29# wrong store.
30EnvironmentFile=-/etc/carlos/host.env
31ExecStart=/opt/carlos/carlos ops hibernate-verify
32# Disk, not the PrivateTmp tmpfs — see carlos-restore-verify.service's note
33# for the measurements. This drill is where it mattered most: the flagship's
34# largest hibernating tenant is 412M and the first live run peaked at 485.6M
35# against a 512M ceiling. On tmpfs that gap was ~30M of tenant growth away
36# from an OOM kill on the very databases the drill is there to vouch for; on
37# disk the same overrun only slows it down.
38CacheDirectory=carlos-verify
39Environment=TMPDIR=%C/carlos-verify
40User=carlos
41Group=carlos
42CapabilityBoundingSet=
43NoNewPrivileges=yes
44ProtectSystem=strict
45# The registry is opened (read-only in effect, but SQLite wants the file and
46# its directory writable to attach WAL) — the same grant carlos-edge.service
47# holds, for a unit running as the user that already owns /data.
48ReadWritePaths=/data
49ProtectHome=yes
50PrivateTmp=yes
51PrivateDevices=yes
52RestrictAddressFamilies=AF_INET AF_INET6
53MemoryDenyWriteExecute=yes
54# One-at-a-time by construction — lease.VerifyReplica deletes each throwaway
55# copy in a defer — so this needs to clear the largest single tenant, not the
56# fleet. Same ceiling and the same WATCH note as the sibling unit.
57MemoryMax=512M
58