Maintained version: slo-platform
docs/runbook.md. This page is where the principles started and is kept for history; slo-platform's alerts link to its runbook, not here.
What to do when an alert fires or a delivery step fails. Every alert's runbook annotation links to a section here.
- page: users are affected now → act immediately.
- ticket: something is degrading or a safety net is broken → fix within the working day.
Scripts referenced below live in infrastructure-live scripts/
unless noted.
scripts/status.sh: sync / health of every Application and the version each environment serves.scripts/ui.sh: Argo CD (8443), Grafana (3000), Prometheus (9090), Argo Rollouts (3100); passwords in.secrets/.- What changed?
git log -5 --onelinein gitops-manifests (every deployment, promotion and rollback is a commit there) and in the application repository. - If the alert started right after a deployment, roll back first, investigate second (Rollback).
Alerts: ErrorBudgetBurn (Pyrra, from the SLOs in each app.yaml) on an availability or probe SLO, e.g.
slo="api-factory-rpc-availability", slo="api-factory-health-probe", slo="sample-app-hello-availability".
severity: page = fast burn (14× the budget rate over 1h and 5m) or medium burn (7× over 6h and 30m);
severity: ticket = slow burn. SLOMetricAbsent (ticket): the SLI has no data, so the SLO cannot see anything.
The labels say which SLO and environment; the SLO's description (Pyrra UI, or the app's app.yaml) says what counts
as a bad event and what it cannot see. Client errors (invalid_argument, not_found, unauthenticated, 4xx) never count.
- probe SLO burning, in-pod availability quiet: the requests do not reach a pod at all — no ready pod (for
api-factory: the readiness probe pings the database, so a database outage takes every pod out of the Service),
a broken Service. Start with
kubectl -n <ns> get pods,endpointsand the database below. In a database outage the API containers also restart every ~1 min (liveness uses the same database ping): a symptom, not the cause (gitops-manifests experiment api-factory-db-partition: the probe paged after 6.6 min, the in-pod SLIs saw nothing). SLOMetricAbsent: no pod is exporting the metric (all down or restarting), or the metric / label was renamed.
- Grafana dashboard of the app: is it one route / RPC or all of them? One environment or both?
- Logs:
kubectl -n <ns> logs deploy/api-factory --since=15m | grep ERROR(api-factory logs the RPC and the error). - Typical causes and actions:
- recent deployment → Rollback;
- database unreachable (
failed to connect … postgres-rw) →kubectl -n <ns> get cluster postgres; a failover takes 25–49s (database-replication); longer → CloudNativePG operator logs (kubectl -n cnpg-system logs deploy/cnpg-controller-manager); relation … does not exist→ the migrate init container failed:kubectl -n <ns> logs deploy/api-factory -c migrate; after the fixkubectl -n <ns> rollout restart deploy/api-factory.
Alerts: ErrorBudgetBurn on a latency SLO (slo="…-latency", e.g. api-factory-rpc-latency: 99% of RPCs within
100ms; sample-app-hello-latency: 99% of /hello within 250ms). Same severities as
error-budget-burn. A latency SLO counts every request, failed ones included: requests that hang
until a timeout burn it together with the availability SLO.
- Grafana: did latency rise with traffic (capacity) or at a deployment (regression)?
- Regression → Rollback. The canary load test exists to stop exactly this (a lock-contention regression served p95 661ms at 100 rps while looking fine at 2 rps).
- Capacity: CPU throttling / memory (
kubectl top pods -n <ns>), database (kubectl -n <ns> get cluster postgres, slow queries in the Postgres logs). Scale through Git (overlayreplicas), never withkubectl scale: Argo CD would revert it.
Alerts: ErrorBudgetBurn on storefront-order-freshness (an order older than 60s is still pending) or
storefront-order-completeness (orders not processed within 5 minutes) — page; SLOMetricAbsent on them — ticket.
The pipeline: web takes POST /orders and writes them pending into the storefront Postgres; the worker (2 replicas)
claims them (FOR UPDATE SKIP LOCKED), processes, marks them done. web reports the pipeline from the database every
10s (orders_pending, orders_oldest_pending_age_seconds, orders_processed_through_timestamp_seconds), so the
numbers survive a dead worker.
- Grafana / Prometheus:
orders_pending{namespace="<ns>"}growing andorders_oldest_pending_age_secondsrising → nothing is processing; pending flat but old → processing too slowly. - Worker:
kubectl -n <ns> get pods -l app=worker; crash loop →kubectl -n <ns> logs deploy/worker --previous; a recent worker release → Rollback. - Slow processing: worker logs (per-order duration), the database (
kubectl -n <ns> get cluster postgres); more replicas through Git (storefront/worker/values-<env>.yaml), neverkubectl scale. - Only
SLOMetricAbsenton freshness, plus an order-intake page: the database is unreachable (web cannot read the pipeline nor take orders) →kubectl -n <ns> get cluster postgres, CloudNativePG operator logs. - One order fails forever (a poison order) is not handled yet: it would hold freshness down — find it with
SELECT id, created_at FROM orders WHERE status = 'pending' ORDER BY created_at LIMIT 5(read-only).
Alerts: ErrorBudgetBurn on SLO api-factory-recovery-point (page on fast / medium burn), on SLO
api-factory-base-backup (ticket); PostgresWalArchivingFailing (ticket, the cause).
- recovery-point: a WAL segment has waited for archiving 10 minutes on end (
cnpg:wal_archive_keeps_up:bool= 0): WAL is not reaching the object store, so the point-in-time recovery window is not advancing: a loss now would lose everything since the last archived segment, andpg_walkeeps growing until the volume is full (the database stops). An idle database is fine: no WAL is written, nothing is archived, nothing is at risk. - base-backup: the newest base backup is older than 26 hours (last night's
ScheduledBackupfailed or did not run). The recovery point is intact while WAL is archived; a restore just replays more WAL.kubectl -n <ns> get backups(phase, error), then the steps below.
kubectl -n <ns> get cluster postgres -o jsonpath='{.status.conditions[?(@.type=="ContinuousArchiving")]}'- Sidecar logs:
kubectl -n <ns> logs postgres-1 -c plugin-barman-cloud | grep -i errorExpected empty archive: another cluster already archived under the samedestinationPath/ server name (e.g. a re-created cluster). Use a new prefix in the overlay's ObjectStore patch, or clear the old one if it is really obsolete. When re-creating a cluster under a new prefix, delete the old cluster before the new prefix syncs (or clear the new prefix afterwards): the old cluster keeps archiving and would fill the new prefix first (happened on kind, 2026-11-18). A re-created cluster has no tables until an api-factory Pod starts (its migrate init container creates them):kubectl -n <ns> rollout restart deploy/api-factory.- connection / credential errors: object store down (
kubectl -n object-storage get pods) or Secretbackup-s3differs from the object store's identity (both come from infrastructure-livesecrets/<cluster>.sops.yaml:tofu applyfor the Secret,ansible-playbook site.yml --tags seaweedfsfor the laptop's host).
- After the fix, take a base backup right away so PITR does not depend on the gap:
kubectl -n <ns> create -f -with aBackup(methodplugin, pluginConfigurationbarman-cloud.cloudnative-pg.io), or wait for the daily ScheduledBackup. - Prove it:
scripts/restore-drill.sh <ns>(≈1 min).
Alert: ErrorBudgetBurn on SLO api-factory-restore-check (ticket). The nightly CronJob restore-check (prod,
04:30 JST) restores the latest backups into a throwaway cluster, compares it with live and rehearses the next
release's migrations on it; it has not succeeded for 26 hours (or never: SLOMetricAbsent). The live
database is fine; what is in doubt is whether it could be restored.
kubectl -n api-factory-prod get jobs -l batch.kubernetes.io/cronjob-name=restore-checkand the last Job's log: it names the failing step (heartbeat missing = WAL chain broken → see database-backups; a table or row count differs = the base backup or WAL replay is incomplete; not healthy after 90 min = the restore itself).✗ migration rehearsal failed: the migrations of the version dev runs (the next release) failed on a copy of prod's data (the log shows which one and how long each took). Do not promote it; fix forward with a new migration (migrations are append-only) and let the next night's check (or a manual run) prove it.- A leftover
restore-targetcluster is deleted by the next run; delete it by hand if disk is short. - Run once now:
kubectl -n api-factory-prod create job --from=cronjob/restore-check manual-$(date +%s). - Restore time trend:
restore_check:duration_seconds(Prometheus).
Alert: ErrorBudgetBurn on SLO platform-offsite-backup (ticket, laptop only). The hourly CronJob
backup-offsite/offsite-backup copies the object store (all database backups + WAL) to the phone, encrypted by
rclone crypt; it has not succeeded for 3 hours (or never: SLOMetricAbsent).
The local backups are unaffected: this is the "laptop lost / house on fire" copy.
kubectl -n backup-offsite get jobsandkubectl -n backup-offsite logs job/<last>- Phone reachable?
tailscale status | grep <phone>; Termux sshd running (Termux killed by battery optimisation → open Termux,sshd). A host-key error means the phone's sshd key changed: updateknown_hostsin gitops-manifestsplatform/offsite-backuponly after confirming it on the phone itself. - Run once now:
kubectl -n backup-offsite create job --from=cronjob/offsite-backup manual-$(date +%s)
Restore from the phone (the laptop is gone): on any machine with the age key, sops decrypt infrastructure-live/secrets/laptop.sops.yaml gives offsite.crypt_password / crypt_salt; configure an rclone
crypt remote over sftp to the phone's backups/gitops (or copy that directory off the phone first) and
rclone copy <crypt>:cnpg <local object store>; then restore with CloudNativePG bootstrap.recovery as in
"Restore a database". Trash: files deleted at the source stay in trash/<day> for 14 days.
Alert: PostgresReplicationLag (ticket, replica > 30s behind).
A lagging replica means a failover would lose recent writes or take longer.
kubectl -n <ns> get cluster postgres (instances, current primary), replica logs, node pressure.
If a replica is broken beyond repair: delete its Pod and PVC; the operator re-clones it from the primary.
Failover behaviour (measured with scripts/failover-drill.sh): the cluster is healthy again 25–49s after the
primary Pod is deleted, with a short burst of API errors. smartShutdownTimeout: 10 is what makes it fast: with the
default (180s) the API's connection pool held the old primary and failover took 197s.
Alert: ApiFactoryLoadTestFailed (ticket). The PostSync k6 Job in api-factory dev breached a threshold
(per-RPC p95 < 300ms, errors < 1%, 30 rps sustained).
kubectl -n api-factory-dev logs job/load-test: the k6 summary shows which threshold and which RPC.- Do not promote this version to prod. (The promote PR is not blocked automatically: GitHub cannot see the cluster. The reviewer of the promote PR checks this alert / the Argo CD sync result.)
- Fix forward in the app repository, or revert the dev image tag in gitops-manifests.
Not an alert: kubectl argo rollouts get rollout sample-app -n <ns> shows Degraded / RolloutAborted with the
failing metric (error-ratio, p95-latency, or the k6 load-test Job). Traffic is already back on the stable
version. Fix in the app repository, or revert the commit in gitops-manifests that introduced the change; the
Rollout returns to Healthy as soon as its spec matches the stable version again.
Argo CD shows admission webhook "vpol.validate.kyverno.svc-…" denied the request: Policy <name> failed: <message>.
The message names the container and the missing setting (pinned image, resources, readiness probe, non-root,
signature). The same check runs on every pull request (gitops-manifests/scripts/validate.sh), so this normally
only happens for resources created at runtime (operators, hooks, drills).
Fix the manifest. If an exception is really justified, add a PolicyException to
gitops-manifests/platform/policies/exceptions.yaml (namespace kyverno only) naming the policy, the exact
workload and the reason; it goes through review like any change.
Everything is a commit in gitops-manifests:
git revert <commit> # the image-tag bump or the config change
ship.sh "Revert …" # gitops-platform-blueprint/scripts/ship.sh: PR + auto-mergeArgo CD syncs within ~30s (measured: revert → old version serving in ~20s). Never kubectl edit/scale/rollout undo:
self-heal reverts manual changes.
scripts/restore-drill.sh <ns> restores into a separate cluster restore-drill and checks a marker row; use it to
rehearse and to estimate the time (≈1 min for the demo data). For a real recovery:
- Pick the target time (before the bad write / deletion).
- Create a new cluster from the backups with
bootstrap.recoveryandrecoveryTarget.targetTime(the drill's manifest is the template), check the data. - Point the application at it through Git (change the Cluster in the overlay, or the connection secret), sync. Keep the damaged cluster until the restored one is verified.
scripts/rebuild-drill.sh --yes deletes the kind cluster and .secrets/, rebuilds everything from Git and runs
smoke checks, printing the time of each phase. Data is not covered: the object store with the backups runs in
the same cluster and is deleted with it (a cloud version would keep the backups outside the cluster); databases come
back empty and dev is re-seeded.