Disaster Recovery from the Mac Mini¶
Kind: how-to (runbook)
This runbook covers what the operational agent ops-agent (persona operator) does when
hetzner-mgmt, Taskbase or Gitea is down, or when the Mac mini cannot reach them. It runs on the Mac
mini in the Lima VM k3s, next to the CI runners. In DR mode the watchdog starts it as a local
session Job that needs no Taskbase. A person with the break-glass files can follow the same steps.
The design and its reasons are in
ADR 0020.
For failures that leave the API, Flux and Gitea working, use the
ops runbook.
Scope: Kubernetes only. By the owner's rule of 2026-10-22, the operator has no Terraform, no
Hetzner access and no Talos access (no talosctl, no talosconfig). Kubernetes and Talos upgrades are
the owner's, done by hand. When a failure is below Kubernetes (nodes, Talos, the Hetzner network or
firewall, volumes at Hetzner) or needs Terraform, the operator does not try to fix it: it records the
evidence in the dr issue and hands over to the owner (A).
Status: installed on the Mac mini (installation). The drill record shows when the chain was last proven.
The setup¶
| What | Where |
|---|---|
| macOS account | agent-ops (standard, not admin). It owns the Lima VM. The mac-mini runner (agent-runner, see the Mac mini rebuild) and the release runner (agent-release-build) cannot read its files. |
| VM | Lima instance k3s (one k3s node, 6 CPU, 9 GiB, 50 GiB disk), shared with the rootless CI runners in the namespace ci (ADR 0022). It is started at boot by the LaunchDaemon io.lima-vm.daemon.k3s, and its template is cluster/mac-mini/lima/k3s.yaml (The k3s VM on the Mac Mini). Flux in it applies ./cluster/mac-mini. |
| Runner | The Deployment ops-agent in the namespace ops-agent: Taskbase runner ops-agent, labels role=ops (dedicated) and dr=mac-mini, 1 slot, Claude large = Opus |
| Watchdog | The CronJob in ops-agent, every minute. Its state is on the PVC ops-agent-dr at /dr. |
| DR session | A Job in ops-agent that the watchdog starts. Only one runs at a time, and the ops-agent Deployment is scaled to 0 meanwhile. Pending reports go to /dr/pending/*.md. |
| Environment check | The LaunchDaemon com.skatzi.ops-env-check, every 5 minutes. It checks the VM, k3s and the watchdog's last tick, and it opens a dr issue when they stay broken. Within 10 minutes of the Mac's or the VM's boot (OPS_ENV_BOOT_GRACE_MINUTES), it counts no failure and never restarts k3s. |
| Break-glass files | The Secret ops-agent-break-glass, mounted read-only, with KUBECONFIG set. It holds kubeconfig (context admin@mgmt-cluster, cluster-admin in Kubernetes, and context webshop for the webshop probes) and github-token (the mirror and its issues). A DR session Job reads both; a dispatched role=ops task run reads only the kubeconfig, not github-token (0. Start). The kubeconfig is the only break-glass access: the owner generates and renews it, and the watchdog warns 30 days before it expires. The source files are in ~agent-ops/.dr/ (mode 0700 and 0600). Never commit them, paste them into a task or issue, or copy them into a workspace. |
| CLIs in the image | kubectl, flux, helm, cilium, gh, git. No talosctl, no terraform. |
| Addresses | kube API https://78.47.74.196:6443, control-plane node 10.0.0.10, workers 10.0.0.20–10.0.0.22 |
| Notification | GitHub issues with the label dr on DunkRing/bootstrap-cluster |
The local environment itself. On the Mac mini, as agent-ops:
limactl list k3s # STATUS Running
k() { limactl shell k3s sudo k3s kubectl "$@"; }
k -n ops-agent get deploy,cronjob,jobs,pods
k -n ops-agent logs job/<dr-session-job> # a DR session's output
limactl shell k3s sudo systemctl restart k3s # what the environment check does
Never run limactl stop k3s: it unloads the boot daemon, and then the VM does not come back after a
reboot. To restart the whole VM, an admin runs
sudo launchctl kickstart -k system/io.lima-vm.daemon.k3s.
Rules in DR mode¶
These add to the ops runbook's rules of engagement, which still apply:
- Never delete PVCs, PVs, Hetzner volumes, buckets, objects in
skatzi-backups, CNPGBackups or snapshots. Never delete a namespace or a CRD. - Roll back first: the last good Git revision, then the backup gates' restore and rollback Jobs.
Use direct
helm rollbackorflux suspend/resumeonly when GitOps itself is broken, and log each command in the run report with why it ran and its result. - Stay in Kubernetes. No Terraform, no Hetzner, no Talos (owner rule). Node rebuilds, firewall changes, floating-IP moves, Talos and Kubernetes upgrades and anything on a node are the owner's.
- Below Kubernetes, hand over; do not repair. Collect the evidence, put it in the
drissue, and end the session (A). - No Kubernetes minor downgrade, and no etcd member removal.
- One write at a time, and check after each one.
- Issues hold no secrets. Do not paste kubeconfig content, tokens or
Secretdata. - Give up cleanly. When this page is exhausted, comment on the issue what was tried, the current state and 2–4 options. Leave the issue open and end the session. The watchdog's cap (3 sessions in 6 hours) stops new sessions after that.
- Application data: one row, after a backup. The only write to an application's own data a
session makes alone is the one-row fix of the
crash-loop case, step 4: one row by its primary key,
after its on-demand CNPG
Backuphas completed, with the old values and the exact statement in thedrissue before it runs (owner, 2026-11-15, platform task #3215). Any other data write is the owner's.
Procedure¶
flowchart TD
S["Watchdog starts a DR session Job"] --> I{"This machine reaches independent internet hosts repeatedly?"}
I -->|no or lossy| M["0. Mac mini network: evidence, hand over"]
I -->|yes| L["Read the prompt, open or reuse the dr issue"]
L --> R{"A runner pod was still finishing a run?"}
R -->|yes| W["Read its changes first"]
W --> F
R -->|no| F{"6443 times out, gateway answers?"}
F -->|yes| FW["Firewall or home IP: comment, hand over"]
F -->|no| A{"Kube API ready?"}
A -->|no| T["A. Below Kubernetes: evidence, hand over"]
A -->|yes| ND{"Nodes NotReady, or volumes failing at Hetzner?"}
ND -->|yes| T
ND -->|no| N{"Pods cannot reach each other or the gateway?"}
N -->|yes| C["B. Network add-on broken"]
N -->|no| X{"Flux controllers healthy?"}
X -->|no| FL["C. Flux broken"]
X -->|yes| G{"Gitea down?"}
G -->|yes| GD["D. Git when Gitea is down"]
G -->|no| TB["E. Taskbase down, or another stuck rollout: ops runbook"]
T --> H["Owner takes over; the dr issue stays open"]
M --> MH["Owner takes over; local report awaits a working channel"]
C --> V["Verify, record, close"]
FL --> V
GD --> V
TB --> V
0. Start¶
In the session Job, KUBECONFIG already points at the break-glass kubeconfig.
First, check whether this machine reaches the internet at all. Repeat both controls: a single
success can hide packet loss. 200 from Cloudflare and 204 from Google are expected; 000, a
timeout or a DNS error counts as a failure.
for attempt in 1 2 3; do
curl -s -o /dev/null -m 8 -w 'cloudflare %{http_code}\n' https://1.1.1.1/cdn-cgi/trace
curl -s -o /dev/null -m 8 -w 'google %{http_code}\n' https://www.google.com/generate_204
done
If either independent control fails repeatedly or intermittently alongside the watchdog's platform
probes, follow the Mac mini network path before treating a
platform probe failure as a cluster outage. When the link permits it, confirm the cluster's view
through the Kubernetes API and the Prometheus Service proxy. Retry timeouts; they are evidence of
the lossy path, not a zero metric value. These kubectl commands require the break-glass kubeconfig.
for attempt in 1 2 3; do
kubectl --context admin@mgmt-cluster --request-timeout=10s get --raw '/readyz' && break
sleep 2
done
prometheus='/api/v1/namespaces/monitoring/services/http:monitoring-kube-prometheus-prometheus:9090/proxy/api/v1/query?query='
prom_query() {
for attempt in 1 2 3; do
kubectl --context admin@mgmt-cluster --request-timeout=10s get --raw "${prometheus}$1" && return 0
sleep 2
done
return 1
}
prom_query 'min_over_time%28probe_success%7Binstance%3D%22https%3A%2F%2Ftaskbase.skatzi.com%2Fapi%2Fhealth%22%7D%5B15m%5D%29'
prom_query 'up%7Bjob%3D%22apiserver%22%7D'
The two PromQL expressions are
min_over_time(probe_success{instance="https://taskbase.skatzi.com/api/health"}[15m]) and
up{job="apiserver"}. A returned value of 1 for both supports that hetzner-mgmt is healthy;
an empty result or failed proxy request does not prove that it is down. The Service name comes
from components/prometheus-stack/grafana/ingress.yaml; the Service proxy form is used by
cluster/mac-mini/host/ops-env-check.sh.
Only after this check, open or reuse the dr issue for a platform fault. First check that this
session can read the GitHub token, without printing it:
GH_TOKEN_FILE="$(dirname "$KUBECONFIG")/github-token"
head -c0 "$GH_TOKEN_FILE" 2>/dev/null && echo token-readable || echo token-denied
The check opens the file and reads 0 bytes. Do not use test -r: it looks only at the file's
mode, which allows the read, so in a dispatched ops task run on 0.5.31 it prints token-readable
while the sandbox refuses the open (platform task #2135, 2026-10-29).
Expect token-readable in a DR session Job. All six session Jobs for webshop/flux on
2026-10-29 and 2026-10-30, with the ops agent on 0.5.31, printed it and commented on dr issue
5 with gh (incident report).¶
A dispatched role=ops task run on 0.5.31 still gets token-denied: there the job sandbox grants
only the kubeconfig file named by KUBECONFIG, not the rest of the break-glass Secret
(ADR-0006, Job sandbox,
bullet The ops kubeconfig; #2135). The ops agent runs 0.5.31 (cluster/mac-mini/ops-agent/oci-repository.yaml,
read 2026-10-30).
If it prints token-denied, skip the gh commands for the rest of the session. Do not try
other paths to the token, and do not ask for a grant on the whole /break-glass directory. Instead:
- Write at the top of the run report in
/dr/pending/that nodrissue was opened because the token is denied, then go on with the repair. The report becomes the incident task once Taskbase is up (Verify, record, close). ops-env-checkstill opensdrissues, but only for what it checks: the VM's k3s and/readyz, the watchdog's last tick, Alertmanager through the API server's Service proxy, and an activeWatchdogalert (Host environment check). While the token is denied, any other platform fault (for example the Taskbase API going down) notifies nobody. A person on the Mac mini can open the issue with~agent-ops/.dr/github-token, using the commands below.- D. Git when Gitea is down also needs the token, so a pushed fix is a person's step too.
A session that prints token-readable, or a person, opens or reuses the issue:
export GH_TOKEN="$(cat "$GH_TOKEN_FILE")"
gh issue list -R DunkRing/bootstrap-cluster -l dr --state open
gh issue create -R DunkRing/bootstrap-cluster -l dr \
--title "DR $(date -u +%Y-%m-%dT%H:%MZ): <failing probes>" \
--body "<probes and first-failure times from the prompt; Gitea state; what happens next>"
Reuse an open dr issue for the same fault rather than opening a second one.
A runner pod was still finishing a run. If the prompt says so, find out what that run changed
before you change anything, so you do not undo its work. Read the pod's own log and events first.
The session's mac-mini context reads the pods, their logs and events in ops-agent (owner,
2026-11-15, platform task #3216; Role ops-agent/ops-agent-read,
cluster/mac-mini/ops-agent/role.yaml), with no exec, no Secrets and no writes:
kubectl --context mac-mini -n ops-agent get pods # the pod's name
kubectl --context mac-mini -n ops-agent get events --sort-by=.lastTimestamp | tail -20
kubectl --context mac-mini -n ops-agent logs <pod> --tail=200 # the run, if the pod still runs
kubectl --context mac-mini -n ops-agent logs <pod> --previous --tail=200 # the run, if the pod restarted
Name the pod from get pods. logs deploy/ops-agent does not work here: it reads the Deployment
first, and the Role does not grant apps/deployments.
The session Job scales the ops-agent Deployment to 0 (The setup), so the pod may be
gone by the time you look, and its log goes with it. If the pod's log is gone or does not say what
the run wrote, read its footprint on hetzner-mgmt and in Git instead, as the 20:42Z session did on
2026-11-14 (task #3173):
git log --since=6.hours --author=ops-agent --format='%h %an %ad %s' origin/main # in the workspace clone
flux --context admin@mgmt-cluster get sources git -A # the revision each source applies
kubectl --context admin@mgmt-cluster get events -A --sort-by=.lastTimestamp | tail -30
kubectl --context admin@mgmt-cluster -n <namespace> get <kind> <name> --show-managed-fields -o yaml \
| grep -E 'manager:|operation:|time:'
The ops-agent Gitea account commits as ops-agent. In the managed fields, a recent Update or
Apply by a manager other than a controller (for example kubectl-client-side-apply,
kubectl-scale or kubectl-patch) is a direct write; status-only entries are not. Check the objects
of the failing service. If you find a recent direct write you cannot explain, record it in the
issue and do not revert it. The footprint commands were not run for this page; their form is from
the ops runbook and the 2026-11-14 sessions.
Before the Role was merged, only its refusals could be checked with kubectl auth can-i: every
check, the reads included, returned no. The granted reads (yes for pods, pods/log and events)
are checked after the merge in platform task #3241
(read access). The logs commands
were not run in a DR session for this page.
Is it the firewall? The Hetzner firewall admits 6443 only from admin_ip.
nc -z -G 5 78.47.74.196 6443
curl -s -o /dev/null -m 10 -w '%{http_code}\n' https://taskbase.skatzi.com/api/health
If nc times out (rather than being refused) while the gateway answers on 443, this machine's public
IP has most likely left admin_ip. Comment exactly that, change nothing, and end the session. The
firewall is Terraform, so the owner updates admin_ip in 1-bootstrap/terraform.tfvars and applies
it.
The Mac mini's network is down or lossy¶
If the independent controls fail alongside the platform probes, change nothing in any cluster.
Record each control's result and time, the watchdog trigger and first failure, and any successful or
failed /readyz and Prometheus queries from 0. Start. A cluster-side value of 1 for
both queries supports a local outbound fault. Do not infer which part of the path is broken: the Lima
VM network, the Mac and the home uplink are the owner's to inspect under
ADR 0020 §7.
Write the run report to /dr/pending/<UTC time>.md and hand its evidence to the owner when a channel
works. If GitHub is reachable, open or update the dr issue; if Taskbase is reachable, use the
incident task. While the uplink is down, neither a dr issue nor ops-env-check can notify the owner.
Keep the local report for delivery after connectivity returns, and end the session. The
watchdog control-probe change was
unmerged when this page was checked on 2026-10-26; until it lands, a local network fault can still
start a DR session.
Webshop sessions¶
Besides hetzner-mgmt, the watchdog probes the webshop cluster through the context webshop of the
break-glass kubeconfig (a ServiceAccount token). webshop/kube-api triggers after 5 minutes and
webshop/flux after 60 minutes. A session for it is the Job ops-agent-dr-webshop-<time>. In it,
name the context in every command, and never run a write without it, since the default context is
hetzner-mgmt. kubectl and flux take --context webshop; helm takes --kube-context webshop
and fails on --context with unknown flag: --context. The commands on this page name
admin@mgmt-cluster; in a webshop session, replace it with webshop in each of them:
kubectl --context webshop get nodes
flux --context webshop get helmreleases -A
helm --kube-context webshop -n shop-demo history shop
While no probe answers at all, the watchdog holds the webshop triggers back as a likely Mac mini network fault (see above). Failures below Kubernetes on webshop go to the owner, as in A.
A. Below Kubernetes: collect evidence and hand over¶
This covers an API that does not answer, nodes that are NotReady, and volumes that fail to attach
at Hetzner, and any fault whose fix needs Terraform, Hetzner or Talos. The operator has no access
there and does not try to repair it. It collects what it can see from Kubernetes and from outside,
read-only:
nc -z -G 5 78.47.74.196 6443 # refused, timed out, or open
curl -sk -m 10 -w '%{http_code}\n' https://78.47.74.196:6443/livez -o /dev/null
kubectl --context admin@mgmt-cluster get --raw '/readyz?verbose' --request-timeout=10s
kubectl --context admin@mgmt-cluster get nodes -o wide
kubectl --context admin@mgmt-cluster describe nodes | grep -A8 -E '^Conditions:'
kubectl --context admin@mgmt-cluster get events -A --sort-by=.lastTimestamp | tail -50
kubectl --context admin@mgmt-cluster get volumeattachments; kubectl --context admin@mgmt-cluster get pvc -A | grep -v Bound
Commands that time out are evidence too; record them with their error. Then comment on the dr
issue, without secrets:
- what failed and since when (the probes and their first-failure times);
- each command above, with its output or error, shortened to what matters;
- the last changes in Git (
git log --since=6.hoursonmain) and any recent Kubernetes or Talos upgrade that the owner may have run; - what the session did not try, and why: "below Kubernetes, the owner's (ADR 0020 §7)".
Leave the issue open, write the run report, and end the session. When Taskbase is up, the incident task carries the same evidence. Do not run a Kubernetes minor downgrade, remove etcd members, or revert a Kubernetes or Talos version in Git: those upgrades are the owner's.
B. Network add-on broken (Cilium, MetalLB, hcloud-csi)¶
The API answers, but pods cannot reach each other, the gateway, or their volumes. Flux cannot repair this itself, because its controllers need the same network to reach Git. If the volumes fail at Hetzner rather than in the CSI driver (the driver is healthy but attach calls fail), that is A.
cilium --context admin@mgmt-cluster status --wait --wait-duration 2m
kubectl --context admin@mgmt-cluster -n kube-system get pods -o wide | grep -v Running
flux --context admin@mgmt-cluster get helmreleases -A | grep -v True
helm --kube-context admin@mgmt-cluster list -A | grep -E 'cilium|metallb|csi'
helm --kube-context admin@mgmt-cluster -n <namespace> history <release> --max 5
- Find the HelmRelease whose revision changed last (
helm --kube-context admin@mgmt-cluster history, its Git revision influx --context admin@mgmt-cluster get). - Stop Flux from reapplying it:
flux --context admin@mgmt-cluster -n <namespace> suspend helmrelease <name>. helm --kube-context admin@mgmt-cluster -n <namespace> rollback <release> <last good revision> --wait --timeout 10m.- Check:
cilium --context admin@mgmt-cluster status, the gateway answers (curl https://taskbase.skatzi.com/api/health), andkubectl --context admin@mgmt-cluster get pods -A | grep -v -E 'Running|Completed'gets shorter. - Revert the version bump in Git: in Gitea if it is up, else see D.
Resume the HelmRelease only after Git names the old version:
flux --context admin@mgmt-cluster -n <namespace> resume helmrelease <name>.
If the chart brings CRDs, read the CRD sections of the ops runbook before the rollback: Helm does not revert CRDs.
C. Flux broken¶
flux --context admin@mgmt-cluster check
kubectl --context admin@mgmt-cluster -n flux-system get pods
flux --context admin@mgmt-cluster get helmreleases -n flux-system
helm --kube-context admin@mgmt-cluster -n flux-system history flux2 --max 5
Flux upgrades itself (flux2 HelmRelease in flux-system, see
Flux: safe change workflow).
When its controllers do not run, nothing applies a revert from Git. Roll back with Helm
(helm --kube-context admin@mgmt-cluster -n flux-system rollback flux2 <last good revision> --wait). When the controllers are up again,
revert the bump in Git so the next reconcile keeps the old version.
D. Git when Gitea is down¶
Flux falls back to the GitHub mirror DunkRing/bootstrap-cluster. The script, its guards and the hold
are described under Flux: switching to the fallback and back.
From the Mac mini, use the by-hand commands on that page with the break-glass kubeconfig. They
work even when Jobs cannot start.
1. Switch Flux to GitHub. Follow step 1 of the by-hand commands. GitHub's commit must equal, or
be ahead of, gitea-platform's last artifact. Then follow step 2, which sets the source and the hold.
2. Push a fix to the mirror. GitHub has no branch protection by design. The push needs GH_TOKEN
from 0. Start; when the session's check printed token-denied, write the fix into the run
report and leave the push to a person. Check before you push, and keep the clone until the end:
git clone https://x-access-token:$GH_TOKEN@github.com/DunkRing/bootstrap-cluster.git ~/dr-git
cd ~/dr-git && git log -1 --format=%H # must equal bootstrap-cluster's artifact SHA in Flux
# make the revert or fix, commit with "dr: <what>" and the issue number, then:
git push origin HEAD:main
flux --context admin@mgmt-cluster reconcile source git bootstrap-cluster -n flux-system
3. Switch back once Gitea is healthy. As soon as Gitea pushes its mirror again, it
force-overwrites GitHub's main with Gitea's, and the fix disappears. Do these steps in order, right
after https://gitea.prod.skatzi.com/api/healthz answers 200:
- Push the fix commits to Gitea on a branch, and open and merge a pull request into
main:
The commits are descendants of Gitea's main, so the merge keeps them. The ops-agent Gitea user
pushes with its PAT, which is the runner's own Gitea credential.
2. Wait until both main branches name the same SHA, and check that the fix is in it:
git ls-remote https://gitea.prod.skatzi.com/Skatzi/platform.git refs/heads/main
git ls-remote https://github.com/DunkRing/bootstrap-cluster.git refs/heads/main
- Follow step 3 of the by-hand commands (back to
gitea-platform, which clears the hold).
If the mirror overwrote GitHub before step 1, Flux applies Gitea's older main again. Merge the pull
request from the kept clone at once. That clone is the only copy of the fix.
E. Taskbase down, or a stuck rollout¶
Taskbase is a Flux Kustomization taskbase-prod from Skatzi/taskbase deploy/prod. It runs the
Deployments platform-tasks-api and platform-tasks-ui in tasks-prod.
flux --context admin@mgmt-cluster get kustomizations taskbase-prod -n flux-system
kubectl --context admin@mgmt-cluster -n tasks-prod get deploy,pods
kubectl --context admin@mgmt-cluster -n tasks-prod get cluster # CloudNativePG database
kubectl --context admin@mgmt-cluster -n tasks-prod logs deploy/platform-tasks-api --tail 100
- The Kustomization is suspended:
flux --context admin@mgmt-cluster resume kustomization taskbase-prod -n flux-system. This is the drill's fault. - A new image fails: revert its tag in
Skatzi/taskbase, by pull request in Gitea. - The database is down: follow the CloudNativePG pages. Never delete its PVC.
-
/api/healthanswers, but database calls hang. The watchdog'staskbaseprobe names the failing database read (agent-runner task #2393), and the API log showscontext canceledon most requests./api/healthdoes not query the database, so it stays200. On 2026-11-03 (task #2378) the API's database pool deadlocked: connections that held the incident advisory lock waited for pool connections, which were all taken by requests waiting for the same lock. See who holds and who waits. These queries only read:kubectl --context admin@mgmt-cluster -n tasks-prod exec tasks-prod-db-1 -c postgres -- psql -d taskbase -c \ "select pid, state, wait_event_type, wait_event, now() - state_change as for, left(query, 60) as query from pg_stat_activity where datname = 'taskbase' order by state_change" kubectl --context admin@mgmt-cluster -n tasks-prod exec tasks-prod-db-1 -c postgres -- psql -d taskbase -c \ "select l.pid, l.granted, a.state, a.wait_event, now() - a.state_change as for, left(a.query, 60) as query from pg_locks l join pg_stat_activity a using (pid) where l.locktype = 'advisory' order by l.granted desc, a.state_change"If the waiters are Alertmanager notifications (
alertmanager webhook: apply notificationin the API log), first add a silence on the alerts that keep coming. Give it an end time and a comment that names the dr issue. Then end the backend that holds the lock (granted = t) withselect pg_terminate_backend(<pid>). This rolls back that session's transaction and loses no committed data. Log both steps. If the deadlock moves to the next waiter, a pod restart or another termination will not fix it, and the fix is in Taskbase's code (Skatzi/taskbase #677 sized the pool). Record it and hand it to the owner. - The database crash-loops on one query: see below.
A CNPG database crash-loops on one query¶
Signs. The CNPG instance pod (for Taskbase tasks-prod-db-1) restarts every few minutes. In
kubectl --context admin@mgmt-cluster -n <namespace> logs <pod> -c postgres --previous, the server
logs database system is ready to accept connections, then about 8–18 s later
client backend (PID …) was terminated by signal 11: Segmentation fault with the statement it ran,
then shutting down because "restart_after_crash" is off. The same statement in every cycle means a
client sends it within seconds of each start, so the database never stays up. On 2026-11-14 that was
Taskbase's queue sweep (every 15 s), and Taskbase was down for 2 h 29 min
(incident report, unmerged on 2026-11-14).
Who may do what. The rules and the ops runbook's rules of engagement cover cluster writes, not writes to an application's own data. Read with them, the steps stand as follows:
| Step | DR session alone? | Why |
|---|---|---|
| 1. Find and confirm the statement | yes | read-only (rules of engagement, rule 2) |
| 2. Scale the client to 0 | yes, logged | a recovery write that Flux undoes from Git (rules of engagement, rule 2) |
3. On-demand Backup |
yes, logged | a recovery write (apply) that adds a backup and changes no data (rules of engagement, rule 2) |
| 4. Data fix | yes, logged, only on one row by its primary key, after step 3's Backup is completed, and after the row's old values and the exact statement are in the dr issue |
the owner's decision of 2026-11-15 (platform task #3215); otherwise it is the owner's |
5. flux reconcile and verify |
yes, logged | a recovery write (rules of engagement, rule 2) |
So a session takes the steps alone, in order, and stops the crash loop with steps 1–3 before it
writes any data. Step 4 is the session's own only when all three of its conditions hold. When one
does not (the fix needs more than one row, the row has no primary key to address it by, or the
Backup does not complete), the session stops after step 3. It comments on the dr issue with the
statement, the row and the proposed fix, and hands step 4 to the owner. The scale-down holds only
until the next reconcile of the client's Kustomization (within 5 minutes for taskbase-prod, see
step 2), and the session may not suspend Flux (rule 2). So once the session
hands over and ends (rule 8), Flux restores the client and the crash loop comes
back. Say so in the dr issue. Whoever runs step 4 first scales the client to 0 again, as in step 2,
and checks that the restart count holds steady before the fix.
The commands below were not run for this page. They are the 2026-11-14 recovery's steps, recorded in
the incident report and in tasks #3042 and #3173; the Backup manifest is the one in
CNPGBackupStale. Replace the
Taskbase names for another database.
1. Find and confirm the statement. Take it from the --previous log above. Check it in an up
window, read-only and with a timeout. Run it without its row lock (FOR UPDATE …), because the full
statement is what crashes the server. Check whether JIT is involved: with jit = off the plan's
total cost should also be below jit_above_cost.
kubectl --context admin@mgmt-cluster -n tasks-prod exec -i tasks-prod-db-1 -c postgres -- psql -d taskbase <<'SQL'
BEGIN READ ONLY;
SET LOCAL statement_timeout = '3s';
SET LOCAL jit = off;
SHOW jit_above_cost;
EXPLAIN <the statement without FOR UPDATE …>;
<the statement without FOR UPDATE …>;
ROLLBACK;
SQL
Find the row it trips on: on 2026-11-14 it was the only open task with model_escalation > 0
(#3001, escalated 17 s before the first crash). Note the row's current values, so the fix can be
reversed.
2. Stop the client that sends it. Scale its Deployment to 0, then wait for the instance to come back and check that its restart count stays put:
kubectl --context admin@mgmt-cluster -n tasks-prod scale deploy platform-tasks-api --replicas=0
kubectl --context admin@mgmt-cluster -n tasks-prod get pod tasks-prod-db-1 \
-o jsonpath='{.status.containerStatuses[?(@.name=="postgres")].restartCount}{"\n"}'
Flux puts the replicas back from Git, so this is a recovery write, not a lasting change. It may do so
before you are done: taskbase-prod has interval: 5m0s
(cluster/hetzner-mgmt/taskbase-prod/kustomization.yaml), and on 2026-11-14 the scheduled reconcile
restored the API 16 minutes after the scale-down. If the crashes start again before step 4, scale to
0 again. Do not flux suspend the Kustomization: GitOps itself is not broken
(rule 2).
3. Take an on-demand backup, named and annotated with the task or dr issue, and wait until its
phase is completed:
kubectl --context admin@mgmt-cluster -n tasks-prod apply -f - <<YAML
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
name: tasks-prod-db-incident-<task>
annotations:
skatzi.com/reason: "<task or dr issue>: fresh backup before the data fix"
spec:
cluster:
name: tasks-prod-db
method: plugin
pluginConfiguration:
name: barman-cloud.cloudnative-pg.io
YAML
kubectl --context admin@mgmt-cluster -n tasks-prod get backup tasks-prod-db-incident-<task> -o jsonpath='{.status.phase}{"\n"}'
On 2026-11-14 tasks-prod-db-incident-3042 completed 15 s after it started.
4. The data fix. The session makes it alone, under the owner's three conditions of 2026-11-15 (platform task #3215). If any of them does not hold, hand step 4 to the owner as above.
- One row, addressed by its primary key. The statement's
WHEREnames the primary key (id = <n>) and nothing else, and the transaction showsUPDATE 1before the commit. Anything else,ROLLBACK. - Only after step 3's
Backupiscompleted. Read its phase again just before the fix. - Old values and the exact statement in the
drissue first. Comment on the issue with the row's current values from step 1, the exact statement, and the statement that reverts it, before you run it. Without adrissue (token-deniedat 0. Start), write them at the top of the run report in/dr/pending/first.
Make the smallest reversible change that keeps the row away from the crashing path. On 2026-11-14 that was:
kubectl --context admin@mgmt-cluster -n tasks-prod get backup tasks-prod-db-incident-<task> -o jsonpath='{.status.phase}{"\n"}' # completed
kubectl --context admin@mgmt-cluster -n tasks-prod exec -i tasks-prod-db-1 -c postgres -- psql -d taskbase <<'SQL'
SELECT id, model_escalation FROM tasks WHERE id = 3001; -- the old values, as in the dr issue
BEGIN;
SET LOCAL statement_timeout = '3s';
UPDATE tasks SET model_escalation = 0 WHERE id = 3001; -- expect UPDATE 1, else ROLLBACK
COMMIT;
SQL
The revert is the same UPDATE with the old values. Log the fix like the other writes, and comment
on the dr issue that it ran and its result.
The cause stays in the code: record a task for the fix in the client's repository (on 2026-11-14,
3210 in Skatzi/taskbase).¶
5. Bring the client back and verify. Reconcile its Kustomization, which restores the replicas from Git, then check the health endpoint, that the restart count has not moved for several sweep intervals, and that no new segfault is in the log:
flux --context admin@mgmt-cluster reconcile kustomization taskbase-prod -n flux-system
curl -s -o /dev/null -w '%{http_code}\n' https://taskbase.skatzi.com/api/health # 200
kubectl --context admin@mgmt-cluster -n tasks-prod get pod tasks-prod-db-1 \
-o jsonpath='{.status.containerStatuses[?(@.name=="postgres")].restartCount}{"\n"}'
kubectl --context admin@mgmt-cluster -n tasks-prod logs tasks-prod-db-1 -c postgres --since=15m | grep -c 'signal 11' # 0
Then verify, record, close. Log every write of steps 2–5 in the run report with the command, why and the result: on 2026-11-14 none was logged, so the incident report could not say who ran them.
For any other root that stays not Ready (the watchdog's Flux trigger), follow the ops runbook's triage order.
Verify, record, close¶
- All watchdog probes are green, and
flux --context admin@mgmt-cluster get kustomizations -A | grep -v Truelists nothing unexpected. - Write the run report to
/dr/pending/<UTC time>.md: the trigger, every command with why and its result, the Git commits and pull requests, and the state at the end. - Once Taskbase is up, the report becomes an incident task in the Platform project. A normal
role=opsrun then writes the incident report by pull request (persona rules #1343, #1349). - Comment the result and the incident task on the GitHub issue. Close it when the incident report is merged, or leave it open after a give-up. Without the token (0. Start), put the result in the run report instead.
- If Flux is still on
bootstrap-cluster, switch it back (D, step 3) before you close.
DR drill¶
The drill proves the whole chain once: an outage is seen from outside the cluster, a session starts without Taskbase, and the session repairs and records it. It breaks Taskbase's API for about 10 minutes.
Before. All probes are green. No run is in progress on the Runs tab, because runs lose Taskbase during the drill. Nobody is mid-deploy. During the drill, Gitea webhooks to Taskbase and Flux alerts fail, and they are not resent.
Arm. A Taskbase task assigned to operator with required_labels: ["role=ops", "dr=mac-mini"]
runs this in the ops-agent runner pod, which mounts /dr. A person can run it instead with
k -n ops-agent exec deploy/ops-agent -- … on the Mac mini (k as above):
Then the run ends. The watchdog, not the run, then does this with the break-glass kubeconfig, in its
current context admin@mgmt-cluster (quoted as the watchdog runs them; do not run them by hand):
kubectl -n tasks-prod annotate deploy platform-tasks-api platform.skatzi.com/dr-drill="$(date -u +%Y-%m-%dT%H:%M:%SZ)" --overwrite
flux suspend kustomization taskbase-prod -n flux-system
kubectl -n tasks-prod scale deploy platform-tasks-api --replicas=0
Expected.
| Step | Pass if |
|---|---|
| Detection | The watchdog starts a DR session at most 7 minutes after the scale to 0 (5 minutes N, plus up to 2 minutes of probe ticks) |
| Notification | A dr issue opens on DunkRing/bootstrap-cluster within a minute of the session start. The session Job reads github-token on agent-runner 0.5.31 (0. Start); if its check prints token-denied, this step fails and the run report says why. |
| Repair | The session finds the drill annotation, resumes taskbase-prod, and /api/health answers 200 within 20 minutes of the session start |
| Restraint | The run report lists no write beyond the resume, a flux reconcile, the removed annotation and the issue. Git sets replicas: 1 (Skatzi/taskbase deploy/prod/api-deployment.yaml), so the resume alone brings the API back. |
| Recording | An incident task exists after Taskbase is back, and its incident report pull request adds a row to the drill record below |
| No loop | The watchdog starts no second session |
The session removes the annotation at the end:
kubectl --context admin@mgmt-cluster -n tasks-prod annotate deploy platform-tasks-api platform.skatzi.com/dr-drill-.
If it fails, a person restores Taskbase with the two commands from E and records the failed drill below with what was missing.
Drill record¶
| Date (UTC) | Target | Detection | Repaired after | Result | Incident report |
|---|---|---|---|---|---|
| 2026-10-25 | taskbase |
7 min after the scale to 0 (06:27:00 → session 06:34:00) | 2 min 5 s after the session start (/api/health 200 at 06:36:05) |
passed: detection, notification, repair, restraint and no loop held; recording did not, the record was written by hand (#1573, fix #1574) | 2026-10-25 |
Open questions¶
Read on 2026-10-29 from ADR-0006 Job sandbox, ADR 0020 and the 2026-10-25 drill report, and on 2026-10-30 from the demo shop incident report and agent-runner task #2134.
- Can a DR session read
github-tokentoday? Answered for the DR session Job (agent-runner run --local-task): yes. The six session Jobs forwebshop/flux(2026-10-29 19:44, 20:24, 20:58; 2026-10-30 05:52, 06:25, 07:00), with the ops agent on 0.5.31, each printedtoken-readableat the 0. Start check and commented ondrissue DunkRing/bootstrap-cluster#5 withgh, for example the sixth session's comment (incident report). So the session Job is not under the 0.5.31 token block. A dispatched Taskbase ops task run still is: on the Mac miniops-agentrunner on 0.5.31 (platform task #2135, 2026-10-29), the kubeconfig opened,/readyzreturnedok, and openinggithub-tokenfailed withPermission denied, as ADR-0006 says, whiletest -rstill printedtoken-readable. Why the session Job is not blocked is not documented in ADR-0006; #2134 step 1 is to confirm and document it. Those sessions only commented on an issue that was already open; none rangh issue create. - Who opens the
drissue for a platform fault? ADR 0020 §8 rule 6 says every DR session opens or reuses one, and the watchdog only comments "needs a person" and warns about certificate expiry. Agent-runner task #2134 (open on 2026-10-30) either grants the session thegithub-tokenfile alone, or moves opening the issue to the watchdog. Today the session Job can read the token and opens or reuses the issue itself; the open part is whether that holds by design. When #2134 lands, update 0. Start, D and the drill's Notification row.
Read on 2026-11-14 from the incident report in pull request #1460 (unmerged), tasks #3042 and #3173,
and cluster/mac-mini/ops-agent/service-account.yaml:
- May a DR session make a data fix alone? Answered by the owner on 2026-11-15 (platform task
#3215): yes, one row by its primary key, only after its on-demand CNPG
Backuphas completed, and only after the old values and the exact statement are in thedrissue. Step 4 of the crash-loop case now says so. The persona's own wording (Skatzi/skatzi-agentspersonas/operator.md) was not read for this page. - Should the DR session read the
ops-agentnamespace? Answered by the owner on 2026-11-15 (platform task #3216): yes, pods,pods/logand events, with no exec, no Secrets and no writes (cluster/mac-mini/ops-agent/role.yaml). 0. Start reads the pod first and keeps the footprint check as a fallback.