Zitadel Auth Errors — Admin Runbook
When Grafana pages or something looks broken, look up the symptom
here, follow the response steps. Covers every alert in
tools/monitoring/grafana-auth-alerts.prom.yaml plus Vault sealed-
state recovery using the saved Shamir shards.
This document is a response playbook. For initial setup, see:
media/admin-customer-onboarding-runbook.md— onboarding new customersmedia/vault-deployment-runbook.md— first-time Vault inittools/monitoring/SETUP-blackbox.md— monitoring infrastructureCLAUDE.md— cluster topology + failover matrix
0. Topology quick-reference
| Site | IP | What it runs |
|---|---|---|
| A | 10.60.12.31 |
etcd-a · pg_a · HAProxy · Zitadel · Login UI · CF Tunnel · idp-hook · onboard-proxy · Vault raft |
| B | 10.60.21.31 |
etcd-b · pg_b · HAProxy · Zitadel · Login UI · CF Tunnel · idp-hook · onboard-proxy · Vault raft |
| C | 10.60.12.205 |
etcd-c · pg_c · HAProxy (tie-breaker) · Vault raft · Vault seal (port 8210) |
Quorum is the hard limit: etcd + Vault Raft are 3-node systems, quorum=2. Tolerate 1 node down for continued writes. Losing 2 = read-only.
1. Patroni / Postgres alerts
1.1 AuthDBNodeDown (critical)
patroni_postgres_running < 1 for 2m
What it means: one Postgres node has stopped. Could be: container crashed, OOM kill, disk full, network partition, planned restart that went over budget.
Response:
# Identify which node from the alert label {{ name }} (pg_a / pg_b / pg_c)
SITE=a # or b / c
SITE_HOST=10.60.12.31 # 10.60.21.31 / 10.60.12.205
ssh root@$SITE_HOST "docker ps -a --filter name=auth-${SITE}-pgsql --format '{{.Names}} {{.Status}}'"
ssh root@$SITE_HOST "docker logs auth-${SITE}-pgsql --tail 50 2>&1"
If container exited:
Wait 30s, recheck Patroni state from Site A:
If node has been gone > maximum_lag_on_failover (32 MB) of WAL behind, it can't auto-catch up — rebuild:
1.2 AuthDBHasNoLeader (critical)
sum(patroni_primary) < 1 for 1m
What it means: no node currently reports primary=1. Brief during failover (5–15 s normal). Sustained = quorum lost OR all Patroni members crashed.
Response:
# Check etcd first — Patroni needs DCS to coordinate
tools/auth-etcd-cluster-state site-a/
# If etcd is up but Patroni still leaderless, restart Patroni members
# on each site (in series, NOT parallel)
ssh root@10.60.12.31 "docker compose -f /root/auth/site-a/docker-compose.yml restart db"
sleep 15
ssh root@10.60.21.31 "docker compose -f /root/auth/site-b/docker-compose.yml restart db"
sleep 15
ssh root@10.60.12.205 "docker compose -f /root/auth/site-c/docker-compose.yml restart db"
If etcd lost quorum, fix that first (§2.2).
1.3 AuthReplicaLagHigh (warning)
leader_position − replica_position > 32 MB for 3m
What it means: a replica is too far behind to safely promote.
Patroni's maximum_lag_on_failover is 32 MB — past it the replica
is ineligible until rebuilt.
Response:
# 1. Identify the lagging replica from the alert ({{ name }})
# 2. Check WAL streaming state
tools/auth-patroni-db-cluster-state site-a/
# 3. Force-rebuild from leader (drops local WAL, re-syncs cleanly)
docker exec auth-<site>-pgsql patronictl reinit zitadel-cluster <member> --force
Live example: the pg_b 9-day-stuck incident in May 2026 was resolved exactly this way.
1.4 AuthReplicaNotStreaming (warning)
patroni_postgres_streaming == 0 on a replica role for 5m
What it means: replica is alive but the walreceiver isn't pulling WAL. Lag will widen until the high-lag alert fires.
Response: identical to §1.3 — patronictl reinit. Catch it
early; once it crosses 32 MB the replica is unusable until rebuilt.
1.5 AuthSyncStandbyLost (warning)
sum(patroni_sync_standby) < 1 for 3m
What it means: synchronous replication has degraded to async. Writes still go through but a failover could lose recent commits.
Response:
# Confirm DCS still has synchronous_mode enabled
docker exec auth-a-pgsql patronictl edit-config zitadel-cluster -p
# Look for synchronous_mode: true
# Check which standby dropped out
tools/auth-patroni-db-cluster-state site-a/
# Often resolves itself within minutes as Patroni promotes the
# other replica to sync standby. If not:
docker exec auth-<lagged_replica>-pgsql patronictl reinit zitadel-cluster <name> --force
2. etcd alerts
2.1 AuthEtcdMemberDown (warning)
count(up{job="auth-etcd"} == 1) < 3 for 1m
What it means: one of 3 etcd nodes is unreachable. Cluster still operates with 2/3 quorum, but if a second goes down DCS dies + Patroni demotes the primary to read-only. Fix before second loss.
Response:
tools/auth-etcd-cluster-state site-a/
# Identify the down node
ssh root@<down_node_ip> "docker ps -a --filter name=auth-<site>-etcd"
ssh root@<down_node_ip> "docker logs auth-<site>-etcd --tail 50"
# Restart if stopped
ssh root@<down_node_ip> "docker compose -f /root/auth/site-<site>/docker-compose.yml up -d etcd"
2.2 AuthEtcdNoLeader (critical)
max(etcd_server_has_leader) < 1 for 1m
What it means: etcd lost quorum (≥2 of 3 down). Patroni can't coordinate → primary demotes to read-only → Vault read-only → fresh external logins fail.
Response:
# 1. Find which etcd containers are alive
for ip in 10.60.12.31 10.60.21.31 10.60.12.205; do
ssh root@$ip "docker ps --filter name=auth-.-etcd --format '{{.Names}} {{.Status}}'"
done
# 2. Start any stopped ones
ssh root@<ip> "docker compose -f /root/auth/site-<site>/docker-compose.yml up -d etcd"
# 3. If a member's data is corrupted (refuses to join), wipe + rejoin
# DO NOT do this lightly — see CLAUDE.md §"Common commands" for the
# member-remove + member-add dance. Easier to ask Datasciences SRE.
3. Generic infrastructure alert
3.1 AuthScrapeTargetDown (warning)
up{job=~"auth-patroni|auth-etcd"} < 1 for 2m
What it means: Prometheus can't reach a specific scrape target. Could be the service is down (preceded by a more specific alert) OR the network path from Prometheus host to the auth cluster is broken.
Response: check if a more specific alert is also firing
(AuthDBNodeDown / AuthEtcdMemberDown). If yes, follow that one.
If only this is firing → network issue between Prometheus host and
the affected node:
4. Vault + blackbox alerts
4.1 AuthVaultSealed (critical)
probe_success{job="auth-vault-health"} < 1 for 1m
What it means: at least one Vault raft node returned a non-2xx
(or non-standby) response to /sys/health. Most likely: it crashed +
restarted + couldn't auto-unseal because EITHER the seal Vault on
Site C is sealed/unreachable, OR the transit token Vault uses to
talk to the seal Vault was revoked.
This is the worst alert in the system. Hook + onboard-proxy depend on Vault; sealed Vault = external logins start failing on next login.
Frequent triggers (so you can pattern-match quickly):
- The whole VM/node hosting a Vault crashed or was rebooted, AND the
transit token has since been revoked → §5.4 (most common cause —
see Refraime/TForge incident on 2026-06-25).
- The seal Vault on Site C was restarted without being unsealed
afterwards (e.g. someone recreated auth-c-vault-seal container)
→ §5.2.
- A raft Vault on its own crashed and is just restarting → §5.1 (just
let it auto-unseal, or restart it manually).
Response: see §5 (Vault sealed-state recovery) below — start with the symptom map at the top of §5.
Quick triage first:
# Which raft node(s) are sealed?
for ip in 10.60.12.31 10.60.21.31 10.60.12.205; do
curl -sS --max-time 3 http://$ip:8200/v1/sys/health 2>/dev/null | \
python3 -c "import json,sys;d=json.load(sys.stdin);print(f'$ip sealed={d[\"sealed\"]} init={d[\"initialized\"]} standby={d[\"standby\"]}')" 2>&1
done
# Is the seal Vault itself sealed?
ssh root@10.60.12.205 'curl -sS http://127.0.0.1:8210/v1/sys/seal-status' | python3 -m json.tool
If the raft nodes are sealed but the seal Vault is healthy → §5.1 (just restart the raft Vault containers, they'll auto-unseal via transit). If §5.1 doesn't fix it within ~30 s → token is dead → §5.4.
If the seal Vault is sealed → §5.2.
4.2 AuthIdpHookDown (critical)
probe_success{job="auth-idp-hook"} < 1 for 2m
What it means: idp-hook /healthz not responding from one or
both sites. The Actions v2 target on Zitadel calls the hook via
http://10.60.12.31:9090/idp/postauth — if that endpoint is down,
fresh external logins fail (interruptOnError=true).
Existing sessions keep working (tokens cached). Local-user logins work (hook fires but skips when no IdP link).
MOST common cause: the underlying VM/node hosting the failing site crashed or rebooted, AND Vault on that site can't auto-unseal because the transit token was revoked. The hook depends on Vault, so it crash-loops waiting for a Vault that can't come up.
If you see AuthIdpHookDown AND AuthVaultSealed firing together,
that's the pattern → jump straight to §5.4. Don't waste time on
hook-only triage.
Response:
# Status both sites
docker ps --filter name=auth-a-idp-hook --format '{{.Status}}'
ssh root@10.60.21.31 'docker ps --filter name=auth-b-idp-hook --format "{{.Status}}"'
# Logs — what crashed?
docker logs auth-a-idp-hook --tail 30
ssh root@10.60.21.31 'docker logs auth-b-idp-hook --tail 30'
# Common causes + responses (in order of likelihood):
# 1. "vault login: ... connection refused" -> Vault on that site is down → §5.4
# (this is the host-crashed + token-revoked pattern from 2026-06-25)
# 2. "vault: signing key for ... not found" -> §6.1 (signing key in Vault gone)
# 3. "no idp creds available" -> §6.2 (DSC Entra creds in Vault missing)
# 4. "config: PROJECT_ID required" -> .env on that site missing IDP_HOOK_PROJECT_ID
# (often because someone overwrote site-X/.env with scp — see §5.4 sub-problem)
# 5. exit code != 0 on /healthz, no obvious upstream cause → rebuild + restart:
docker compose -f /root/auth/site-a/docker-compose.yml up -d --force-recreate idp-hook
ssh root@10.60.21.31 'docker compose -f /root/auth/site-b/docker-compose.yml up -d --force-recreate idp-hook'
5. Vault sealed-state recovery
The most painful failure mode. You don't need to be a Vault expert to work through this section — follow the symptoms-to-section map below and run the exact commands. Each step has a "what this means" line so you understand what's happening.
What is Vault in our setup?
We use Vault to store secrets that must be encrypted at rest:
- Customer IdP credentials (Entra/Google client secrets per customer org)
- Service tokens (the idp-hook's PAT for talking to Zitadel)
- The HMAC signing key Zitadel uses to sign hook webhook payloads
- Onboarding ticket state (which customer is mid-onboarding)
Vault is built from TWO separate Vault processes:
| Vault | Where | What it holds | How it locks/unlocks |
|---|---|---|---|
| Raft cluster (3 nodes, port 8200 on each site) | Sites A + B + C | All the application secrets above | Auto-unlocks on startup by asking the seal Vault for help — no human needed |
| Seal Vault (1 node, port 8210, Site C only) | Site C | A single tiny encryption key — the one that unlocks the raft cluster's master keys | Manually unlocked with 3 of 5 Shamir keys held by operators |
In normal operation, the seal Vault is unlocked once after a reboot and then forgotten about — the raft cluster talks to it automatically via a machine token called the transit token.
Symptom → section map
| What's broken | Go to |
|---|---|
Raft Vaults are sealed but curl http://10.60.12.205:8210/v1/sys/seal-status returns sealed=false |
§5.1 — just restart raft Vaults |
curl http://10.60.12.205:8210/v1/sys/seal-status returns sealed=true |
§5.2 — unseal seal Vault with 3 Shamir shards |
Grafana fires AuthIdpHookDown AND hook logs say vault login: ... connection refused OR permission denied / invalid token |
§5.4 — transit token has been revoked, mint a new one |
| Shamir shards lost and the cluster is broken | §5.3 — full wipe + re-init (last resort, data loss) |
5.1 Raft cluster sealed, seal Vault is healthy
Restart the raft Vault containers — they'll auto-unseal via the transit token on startup:
docker compose -f /root/auth/site-a/docker-compose.yml restart vault
ssh root@10.60.21.31 'docker compose -f /root/auth/site-b/docker-compose.yml restart vault'
ssh root@10.60.12.205 'docker compose -f /root/auth/site-c/docker-compose.yml restart vault'
# Verify within ~30 s
for ip in 10.60.12.31 10.60.21.31 10.60.12.205; do
curl -sS http://$ip:8200/v1/sys/health | python3 -c "import json,sys;d=json.load(sys.stdin);print(f'$ip sealed={d[\"sealed\"]}')"
done
If a node keeps sealing immediately after restart → transit token expired or rotated. Re-issue:
# Need VAULT_SEAL_ROOT_TOKEN from the saved init-seal output
export VAULT_SEAL_ROOT_TOKEN=hvs.…
tools/auth-vault-init issue-transit-token # writes new token to .deploy-state + .env
# Then push the updated server-*.hcl to B + C
scp shared/config/vault/server-b.hcl root@10.60.21.31:/root/auth/shared/config/vault/server-b.hcl
scp shared/config/vault/server-c.hcl root@10.60.12.205:/root/auth/shared/config/vault/server-c.hcl
# Restart raft Vaults again
5.2 Seal Vault sealed (the bad one)
This is what bit us on 2026-06-09. The seal Vault on Site C (port 8210) holds the transit key that wraps the raft cluster's master keys. If it's sealed, the raft Vaults can't auto-unseal and the whole stack starts failing.
Pre-requisite: you must have the saved init-seal output file
with keys_base64 (5 Shamir shards). If you don't, the data is
unrecoverable — recover by full re-init (§5.3).
# 1. Confirm seal Vault state
ssh root@10.60.12.205 'curl -sS http://127.0.0.1:8210/v1/sys/seal-status' | python3 -m json.tool
# expect: "sealed": true, "t": 3, "n": 5, "progress": 0
# 2. Unseal with 3 of the 5 shards. Run on your laptop / a host
# that has network reach to 10.60.12.205:8210. Use silent input
# so shards never hit shell history or argv on the remote.
export HISTCONTROL=ignorespace
read -rsp "Key 1: " K; echo
ssh root@10.60.12.205 "curl -sS -X PUT --data-binary @- http://127.0.0.1:8210/v1/sys/unseal" <<< "{\"key\":\"$K\"}"
unset K
read -rsp "Key 2: " K; echo
ssh root@10.60.12.205 "curl -sS -X PUT --data-binary @- http://127.0.0.1:8210/v1/sys/unseal" <<< "{\"key\":\"$K\"}"
unset K
read -rsp "Key 3: " K; echo
ssh root@10.60.12.205 "curl -sS -X PUT --data-binary @- http://127.0.0.1:8210/v1/sys/unseal" <<< "{\"key\":\"$K\"}"
unset K
# Each call returns:
# {"sealed":true, "progress":1, "t":3, ...} ← first shard
# {"sealed":true, "progress":2, "t":3, ...} ← second
# {"sealed":false, "progress":0, "t":3, ...} ← third — unsealed!
# 3. Once seal Vault is unsealed, raft Vaults auto-unseal within
# ~30 s of next health-check (they crash-loop until transit
# is reachable). Watch:
for ip in 10.60.12.31 10.60.21.31 10.60.12.205; do
curl -sS http://$ip:8200/v1/sys/health | python3 -c "import json,sys;d=json.load(sys.stdin);print(f'$ip sealed={d[\"sealed\"]}')"
done
5.3 Seal Vault unrecoverable (shards lost)
Last resort. Data in raft Vault is gone (encrypted with a transit key we can't recreate). Full re-init:
# Stop all Vault-dependent services first
docker compose -f /root/auth/site-a/docker-compose.yml stop idp-hook onboard-proxy
ssh root@10.60.21.31 'docker compose -f /root/auth/site-b/docker-compose.yml stop idp-hook onboard-proxy'
# Stop all Vault containers
docker compose -f /root/auth/site-a/docker-compose.yml stop vault
ssh root@10.60.21.31 'docker compose -f /root/auth/site-b/docker-compose.yml stop vault'
ssh root@10.60.12.205 'docker compose -f /root/auth/site-c/docker-compose.yml stop vault vault-seal'
# Wipe Vault data (PRESERVES Zitadel Postgres + Patroni / etcd — only Vault)
rm -rf /root/auth/site-a/data/vault-data/* /root/auth/site-a/data/vault-data/.[!.]*
ssh root@10.60.21.31 'rm -rf /root/auth/site-b/data/vault-data/* /root/auth/site-b/data/vault-data/.[!.]*'
ssh root@10.60.12.205 'rm -rf /root/auth/site-c/data/vault-data/* /root/auth/site-c/data/vault-data/.[!.]* /root/auth/site-c/data/vault-seal-data/* /root/auth/site-c/data/vault-seal-data/.[!.]*'
# Re-init seal Vault, get new Shamir shards (SAVE THESE PROPERLY)
ssh root@10.60.12.205 'docker compose -f /root/auth/site-c/docker-compose.yml up -d vault-seal'
sleep 10
curl -sS -X POST http://10.60.12.205:8210/v1/sys/init \
-H "Content-Type: application/json" \
-d '{"secret_shares":5,"secret_threshold":3}' > /root/vault-init-seal-$(date +%s).json
# IMMEDIATELY save the file to 1Password, then `shred -u` it
# Unseal (use 3 shards from what you just saved)
# ... same pattern as §5.2
# Re-enable transit, issue token, init cluster, configure backends,
# create policies, create approles. Run sequentially:
export VAULT_SEAL_ROOT_TOKEN=hvs.… # from new init-seal output
tools/auth-vault-init enable-transit
tools/auth-vault-init issue-transit-token
# Push new .hcl + .env to B + C
scp /root/auth/shared/config/vault/server-b.hcl root@10.60.21.31:/root/auth/shared/config/vault/server-b.hcl
scp /root/auth/shared/config/vault/server-c.hcl root@10.60.12.205:/root/auth/shared/config/vault/server-c.hcl
# Start raft Vaults
docker compose -f /root/auth/site-a/docker-compose.yml up -d vault
ssh root@10.60.21.31 'docker compose -f /root/auth/site-b/docker-compose.yml up -d vault'
ssh root@10.60.12.205 'docker compose -f /root/auth/site-c/docker-compose.yml up -d vault'
# Init the cluster (Site A is the bootstrap leader)
curl -sS -X POST http://10.60.12.31:8200/v1/sys/init \
-H "Content-Type: application/json" \
-d '{"recovery_shares":5,"recovery_threshold":3}' > /root/vault-init-cluster-$(date +%s).json
# Save → 1Password → shred
# Raft join B + C
ssh root@10.60.21.31 'docker exec auth-b-vault vault operator raft join -address=http://127.0.0.1:8200 http://10.60.12.31:8200'
ssh root@10.60.12.205 'docker exec auth-c-vault vault operator raft join -address=http://127.0.0.1:8200 http://10.60.12.31:8200'
# Finish: backends + policies + approles
export VAULT_ROOT_TOKEN=hvs.… # from new init-cluster output
tools/auth-vault-init configure-backends
tools/auth-vault-init create-policies
tools/auth-vault-init create-approles
# Re-issue onboard-proxy AppRole
tools/auth-vault-onboard-proxy-init
# Re-create Actions v2 target (rotates HMAC signing key)
# (you'll need to delete the old one first if Zitadel still has the record)
tools/auth-target-entra-add --force-recreate
# migrate-secrets pushes signing key + idp-hook PAT back into Vault
tools/auth-vault-init migrate-secrets
# Restart idp-hook + onboard-proxy
docker compose -f /root/auth/site-a/docker-compose.yml up -d --force-recreate idp-hook onboard-proxy
ssh root@10.60.21.31 'docker compose -f /root/auth/site-b/docker-compose.yml up -d --force-recreate idp-hook onboard-proxy'
# Restore DSC Entra creds in Vault for the hook (you'll need the
# current Entra client_secret — rotate one in the Entra portal)
bash /root/auth/tools/auth-entra-rotate
What's lost in a full re-init:
- All onboard tickets (issue new ones if any customer onboardings were in flight)
- All customer IdP credentials in Vault → customer logins via Entra/Google fail until each customer re-onboards (their wizard ticket can be re-issued; the IdP record on Zitadel postgres survives)
- AppRole secret-ids (re-issued automatically)
- Transit + seal root + cluster root tokens — new ones from this re-init
What survives because it's in Postgres / Patroni:
- All Zitadel users, projects, orgs, grants
- All login policies + IdP records (but their credentials in Vault must be re-pushed)
- All user memberships + Authorizations
5.4 Transit token revoked / expired (host crashed + Vault can't auto-unseal)
This is the bug that hit us on 2026-06-25. You don't lose any data here — it's the most common Vault-related outage you'll see and the recovery is mechanical. Walk through every step in order; do not skip.
Which Grafana alerts fire for this
You'll usually see two or three of these going off together:
| Grafana alert | What's actually happening |
|---|---|
AuthIdpHookDown |
Hook on the affected site can't talk to its local Vault → /healthz fails |
AuthVaultSealed |
Blackbox probe to the affected Vault returns 5xx or no response |
AuthScrapeTargetDown (sometimes) |
Prometheus also can't reach Patroni/etcd on the affected site if the whole host is still booting |
The Telegram message titles match the Grafana rule names — search the
notification for AuthIdpHookDown / AuthVaultSealed and follow the
chain back here.
Why this happens, in plain language
The common trigger is: the underlying VM/node hosting one of the Vault sites crashed or was rebooted. That alone shouldn't break anything — Vault is designed to auto-unseal after a restart. But:
- Vault on Site A/B/C boots up after the host reboot.
- It needs the master key to unlock its database.
- The master key is encrypted by the seal Vault on Site C.
- The raft Vault asks the seal Vault: "please decrypt my master key for me — here's a token to prove I'm allowed to ask."
- If the token has been revoked or has expired, the seal Vault says "no" → raft Vault crashes → restarts → tries again → infinite loop.
The token in step 4 is the transit token. It's a long-lived "periodic" token that auto-renews while in use. If something happens that revokes it (manual operator action, seal Vault wipe, very long period without renewal, sometimes a vault-seal container restart), every restart of a raft Vault hits this crash loop.
Already-running Vaults at other sites keep working because they cached the unsealed master key in memory — but they'll crash on the NEXT restart too. So you can have a "limping" cluster where one Vault is crash-looping while the others keep working — until you reboot another site and lose more nodes.
Additional layer: the same VM-crash that triggered the Vault problem can also kill the docker daemon itself (Go panic in dockerd seen on Site B 2026-06-25). The docker daemon must be running before you can recreate any container. See the docker sub-problem below.
How you know it's this problem
Grafana fires AuthIdpHookDown (because the hook depends on Vault).
Or you notice failed logins for customers landing on whichever site's
Vault is down.
Confirm:
# 1. Check Vault state at each site
for ip in 10.60.12.31 10.60.21.31 10.60.12.205; do
curl -sS --max-time 3 http://$ip:8200/v1/sys/health 2>/dev/null \
| python3 -c "import json,sys;d=json.load(sys.stdin);print(f' $ip: sealed={d[\"sealed\"]} standby={d[\"standby\"]}')" \
|| echo " $ip: UNREACHABLE (probably restarting)"
done
If at least one site shows UNREACHABLE, look at its Vault logs:
You're looking for either of these lines:
URL: PUT http://10.60.12.205:8210/v1/transit/encrypt/vault-autounseal
Code: 403. Errors: permission denied / invalid token
or
vault login: approle login: Post "http://vault:8200/v1/auth/approle/login":
dial tcp 172.17.0.7:8200: connect: connection refused
The first line is the smoking gun — token revoked. The second is the hook complaining about its own crashed Vault (consequence, not cause).
Sanity test the token directly. The token is the same value in
/root/auth/.deploy-state on Site A — try using it to encrypt something:
TOKEN=$(grep VAULT_TRANSIT_SEAL_TOKEN /root/auth/.deploy-state | cut -d'=' -f2- | tr -d '"')
curl -sS -X POST -H "X-Vault-Token: $TOKEN" \
-d '{"plaintext":"dGVzdA=="}' \
http://10.60.12.205:8210/v1/transit/encrypt/vault-autounseal
If response is {"errors":["permission denied / invalid token"]} →
token is dead → continue to recovery below.
Recovery walkthrough
You will need:
- The seal Vault root token (
VAULT_SEAL_ROOT_TOKEN) from your password manager. It was captured during the original cluster init or the 2026-06-09 wipe-and-reinit — looks likehvs.X0t6y4h36...(28 characters). - SSH access to all 3 sites as root.
The recovery is 4 steps. Open an SSH session to Site A on your laptop — do NOT run the seal root token through any other tool/chat/AI:
Step 1 — Mint a new transit token (Site A)
In your Site A SSH session:
# Tell bash to skip history for lines starting with a space
export HISTCONTROL=ignorespace
# Paste your seal root token with a LEADING SPACE so bash doesn't
# record it in .bash_history. The space is important.
export VAULT_SEAL_ROOT_TOKEN='hvs.PASTE_YOUR_SEAL_ROOT_TOKEN_HERE'
# Run the tool. It will:
# - Mint a new periodic token from the seal Vault
# - Save it into /root/auth/.deploy-state
# - Inject it into the 3 Vault config files at
# /root/auth/shared/config/vault/server-{a,b,c}.hcl
cd /root/auth
tools/auth-vault-init issue-transit-token
# Clean up the env variable so it's not lying around
unset VAULT_SEAL_ROOT_TOKEN
The tool prints a "Re-source it and restart Raft peers" block at the end — that block is just guidance; the next steps spell it out.
Step 2 — Push the new config to Site B + C
Still in your Site A SSH session:
NEW=$(grep VAULT_TRANSIT_SEAL_TOKEN /root/auth/.deploy-state | cut -d'=' -f2- | tr -d '"')
# Update site-a/.env in-place (compose substitutes from .env at startup)
sed -i "s|^VAULT_TRANSIT_SEAL_TOKEN=.*|VAULT_TRANSIT_SEAL_TOKEN=$NEW|" /root/auth/site-a/.env
# Push the new HCL config + update Site B's .env IN PLACE
# (do NOT scp Site A's local site-b/.env to Site B — that wipes
# all the Site-B-specific values like CURRENT_HOST_IP. Edit in
# place via ssh+sed.)
scp /root/auth/shared/config/vault/server-b.hcl \
root@10.60.21.31:/root/auth/shared/config/vault/server-b.hcl
ssh root@10.60.21.31 \
"sed -i 's|^VAULT_TRANSIT_SEAL_TOKEN=.*|VAULT_TRANSIT_SEAL_TOKEN=$NEW|' /root/auth/site-b/.env"
# Same for Site C
scp /root/auth/shared/config/vault/server-c.hcl \
root@10.60.12.205:/root/auth/shared/config/vault/server-c.hcl
ssh root@10.60.12.205 \
"sed -i 's|^VAULT_TRANSIT_SEAL_TOKEN=.*|VAULT_TRANSIT_SEAL_TOKEN=$NEW|' /root/auth/site-c/.env"
Why edit in place vs scp: The
site-{a,b}/.envfile on Site A is NOT the same as thesite-b/.envfile on Site B's host. Site A holds a stub used at deploy time; Site B holds the live operational copy with all itsCURRENT_HOST_IP,IDP_HOOK_PROJECT_ID, etc. If youscpthe wrong direction you will WIPE Site B's real env. Usesedoversshto surgically replace only the transit token line.
Step 3 — Recreate the Vault container on the failed site first
Whichever site is currently crash-looping (most often the one that just rebooted):
# Pick the failed site:
SITE=b
SITE_HOST=10.60.21.31
ssh root@$SITE_HOST \
"docker compose -f /root/auth/site-$SITE/docker-compose.yml up -d --force-recreate vault"
# Wait for it to come up (~30 seconds usually)
sleep 20
# Confirm it unsealed cleanly
ssh root@$SITE_HOST 'docker ps --filter name=auth-'$SITE'-vault --format "{{.Status}}"'
# expect: Up X seconds (healthy)
If the container still crash-loops, look at its logs again — you may have a separate issue layered on top (see §5.4 sub-problems below).
Step 4 — Recreate the other Vaults too
This is important. Even if Site A's Vault container is currently working (it cached the old unseal state), its NEXT restart will hit the same dead-token problem you just fixed. Recreate now while you have working failover.
# Site A — do this LAST or during a quiet window; brief 15s blip
# while it re-elects raft leadership. CF will route traffic to
# Site B if A is briefly unavailable.
docker compose -f /root/auth/site-a/docker-compose.yml up -d --force-recreate vault
# Site C — pure standby, no user traffic, recreate any time
ssh root@10.60.12.205 \
"docker compose -f /root/auth/site-c/docker-compose.yml up -d --force-recreate vault"
Verify all 3 unsealed cleanly:
for ip in 10.60.12.31 10.60.21.31 10.60.12.205; do
curl -sS --max-time 3 http://$ip:8200/v1/sys/health 2>/dev/null \
| python3 -c "import json,sys;d=json.load(sys.stdin);print(f' $ip: sealed={d[\"sealed\"]} standby={d[\"standby\"]}')"
done
All three should show sealed=False. Exactly one will show
standby=False (the active leader); the other two show
standby=True (followers).
Sub-problem: docker daemon panicked at the failed site
Sometimes the same reboot that triggered the Vault problem also takes down the docker daemon itself (Go panic on Site B's host, 2026-06-25).
Symptom: when you try to recreate the Vault container, you get
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Fix:
ssh root@$FAILED_SITE_HOST 'systemctl restart docker; systemctl is-active docker'
# expect: "active"
# Containers are usually still up via orphaned containerd shims; bring
# them back into docker's view:
ssh root@$FAILED_SITE_HOST 'docker ps -a --format "{{.Names}} {{.Status}}" | grep auth-'
# Re-up the whole stack (compose is idempotent — already-running
# containers are left alone)
ssh root@$FAILED_SITE_HOST 'docker compose -f /root/auth/site-'$SITE'/docker-compose.yml up -d'
Sub-problem: you accidentally wiped Site B's .env with scp
If Site B .env is now missing variables like IDP_HOOK_PROJECT_ID or
IDP_HOOK_PAT (you'll see the hook crash-loop with
config: PROJECT_ID required), restore by appending from Site A's
copies of those (the IDP_HOOK_* values are identical on A and B per
design — see CLAUDE.md):
ADD=""
for k in IDP_HOOK_PROJECT_ID IDP_HOOK_LOG_LEVEL IDP_HOOK_PAT ONBOARD_PROXY_PAT \
ADMIN_EMAIL ADMIN_USER ADMIN_PASSWORD DEFAULT_ORGANIZATION; do
v=$(grep "^${k}=" /root/auth/site-a/.env | cut -d= -f2-)
[[ -n "$v" ]] && ADD="${ADD}${k}=${v}"$'\n'
done
echo "$ADD" | ssh root@10.60.21.31 'cat >> /root/auth/site-b/.env'
# Restart the affected containers
ssh root@10.60.21.31 'docker compose -f /root/auth/site-b/docker-compose.yml up -d'
After recovery — verify
# All 3 Vaults unsealed?
for ip in 10.60.12.31 10.60.21.31 10.60.12.205; do
curl -sS http://$ip:8200/v1/sys/health \
| python3 -c "import json,sys;d=json.load(sys.stdin);print(f' $ip: sealed={d[\"sealed\"]}')"
done
# Hooks reachable?
curl -sS -o /dev/null -w "hook A: %{http_code}\n" http://10.60.12.31:9090/healthz
curl -sS -o /dev/null -w "hook B: %{http_code}\n" http://10.60.21.31:9090/healthz
# Public auth landing page?
curl -sS -o /dev/null -w "auth: %{http_code}\n" https://auth.datasciencescorporation.co.za/ui/v2/login
# Grafana alert clears within ~2 min on next eval cycle.
If all of those are clean, you're done. The Vault raft leader may have changed (Site C often takes over after a Site A restart) — that's normal and doesn't affect customer traffic, because Site C doesn't run Zitadel, only the Vault raft layer.
6. Application-specific failure modes
6.1 Hook says "vault: signing key for entra-role-mapper: secret not found"
The Actions v2 target's HMAC signing key isn't in Vault at
secret/data/idp-hook/targets/entra-role-mapper. Either Vault was
wiped + secret never migrated back, OR the target was recreated and
the key wasn't pushed.
# Recreate target (rotates signing key, writes to both .env)
tools/auth-target-entra-add --force-recreate
# Migrate the new key into Vault
export VAULT_ROOT_TOKEN=hvs.… # from saved init-cluster output
tools/auth-vault-init migrate-secrets
6.2 Hook says "no idp creds available"
The DSC Entra credentials at secret/data/idp/<idp_id>/credentials
are missing. Hook can't call Microsoft Graph → users get
"unknown error" at login.
# Rotate creds + write to Vault under the live IdP id
bash /root/auth/tools/auth-entra-rotate
# Prompts for tenant_id / client_id / client_secret. Uses the
# onboard-proxy AppRole — no root token needed.
6.3 Customer can't log in via their IdP
# Tail both hook logs while they retry
docker logs -f auth-a-idp-hook | grep -E "user=|req-trigger|authz|error"
ssh root@10.60.21.31 'docker logs -f auth-b-idp-hook | grep -E "user=|req-trigger|authz|error"'
| Log fragment | Cause | Fix |
|---|---|---|
groups=0 authz +0 ~0 -0 |
User isn't in any matching Entra group (or it's Google → no groups by design) | Customer admin assigns roles manually via Console |
no idp creds available |
Customer IdP credentials not in Vault | Re-onboard the customer (issue fresh ticket) |
AADSTS650053: scope X doesn't exist |
Customer's IdP config requests a bogus scope | Edit the IdP record via Console, drop the bad scope |
interruptOnError: true blocked login |
Hook returned non-2xx | Investigate hook crash via §6.1/§6.2 |
7. Shamir shards reference
There are two independent sets of 5 shards each stored in your password manager:
| Set | Where it lives | What you do with it |
|---|---|---|
Seal Vault Shamir (5 × keys_base64 from init-seal) |
1Password / similar | Unseal the seal Vault on Site C port 8210 after a restart (§5.2). Need 3 of 5. |
Raft cluster recovery (5 × recovery_keys_base64 from init-cluster) |
1Password / similar | Generate a NEW raft root token if you lose the current one (vault operator generate-root flow). Need 3 of 5. Does NOT unseal — auto-unseal handles that via transit. |
Also stored separately, as plaintext tokens (not split):
- Seal Vault root token (
hvs.<24+chars>) — used byauth-vault-initforenable-transit/issue-transit-token - Raft cluster root token (
hvs.<24+chars>) — Vault admin ops (policies, AppRoles, mounts) - Transit periodic token (
hvs.<long>) — auto-regenerable viaauth-vault-init issue-transit-token, lives in.deploy-state+.env+shared/config/vault/server-*.hcl
If you've lost the seal Vault root token but still have the seal Shamir shards:
# Use the shards to regenerate a root token via the standard Vault
# generate-root flow against the seal Vault directly.
# Run on a host that can reach 10.60.12.205:8210.
docker exec auth-c-vault-seal vault operator generate-root -init -address=http://127.0.0.1:8200
# Returns OTP + nonce. Save the OTP.
# For each of 3 shards:
read -rsp "Shard: " S
echo "{\"key\":\"$S\",\"nonce\":\"<nonce>\"}" | docker exec -i auth-c-vault-seal vault operator generate-root -address=http://127.0.0.1:8200 -nonce=<nonce> -
unset S
# Final call returns encoded token
docker exec auth-c-vault-seal vault operator generate-root -decode=<encoded> -otp=<otp> -address=http://127.0.0.1:8200
# That's your new seal root token. Save it.
Same procedure with raft recovery keys against the raft cluster
(http://10.60.12.31:8200) if you lose the raft root token.
8. Common cluster reboots / drains
8.1 Planned reboot of one site
Tolerated. Steps:
SITE=b # or c — NOT a (Site A is the bootstrap leader for several things)
SITE_HOST=10.60.21.31
# Silence Grafana alerts for the duration
# Alerting → Silences → New silence → matcher cluster=zitadel-cluster
# Duration: estimated reboot window + 10 min buffer
# Stop services cleanly
ssh root@$SITE_HOST "docker compose -f /root/auth/site-$SITE/docker-compose.yml stop"
# Reboot the host
ssh root@$SITE_HOST "shutdown -r now"
# After it boots, the compose's restart policy brings everything back
# Validate from Site A
tools/auth-patroni-db-cluster-state site-a/
tools/auth-etcd-cluster-state site-a/
8.2 Cluster-wide downtime / cold start
Order matters:
- etcd on all 3 sites (need quorum for everything else)
- Patroni on all 3 sites (waits for etcd, elects leader)
- Vault on Site C (vault-seal first, then unseal it with 3 shards if it doesn't auto-recover)
- Vault on Sites A + B (raft, auto-unseals via transit)
- Zitadel + login-ui on Sites A + B
- idp-hook on Sites A + B (depends on Vault + Zitadel)
- onboard-proxy on Sites A + B
- Cloudflare tunnel on Sites A + B (last so traffic doesn't land until everything else is healthy)
9. Escalation
If any of the following: contact Datasciences SRE / take a snapshot first:
- More than 1 site unreachable for > 5 minutes
- Vault sealed and the saved shards don't unseal it ("invalid key")
- etcd member's data dir is corrupted (won't start with raft errors)
- Patroni shows split-brain (two primaries) — should never happen with sync mode but if it does, DO NOT restart anything until you've identified which one has the latest WAL
- Any 5xx response from
auth.datasciencescorporation.co.za/ui/v2/loginthat persists > 30 s - Customer reports the wizard rolling back repeatedly — check
docker logs auth-{a,b}-onboard-proxyfor the latest error and follow the chain
Snapshot before recovering anything destructive:
# Postgres dump from the leader
docker exec auth-a-pgsql pg_dumpall -U postgres > /root/zitadel-snapshot-$(date +%s).sql
# Vault Raft snapshot
docker exec auth-a-vault vault operator raft snapshot save /vault/data/snapshot-$(date +%s).snap
# Copy out:
docker cp auth-a-vault:/vault/data/snapshot-*.snap /root/
# etcd snapshot
docker exec auth-a-etcd etcdctl snapshot save /etcd-data/snapshot-$(date +%s).db
10. Cheat-sheet — first commands to run when paged
# Cluster heartbeat (5 seconds)
tools/auth-etcd-cluster-state site-a/
tools/auth-patroni-db-cluster-state site-a/
# Container roll-call (10 seconds)
docker ps --filter name=auth- --format 'table {{.Names}}\t{{.Status}}'
ssh root@10.60.21.31 'docker ps --filter name=auth- --format "table {{.Names}}\t{{.Status}}"'
ssh root@10.60.12.205 'docker ps --filter name=auth- --format "table {{.Names}}\t{{.Status}}"'
# Vault seal status
for ip in 10.60.12.31 10.60.21.31 10.60.12.205; do
curl -sS --max-time 3 http://$ip:8200/v1/sys/health \
| python3 -c "import json,sys;d=json.load(sys.stdin);print(f'$ip sealed={d[\"sealed\"]}')"
done
ssh root@10.60.12.205 'curl -sS http://127.0.0.1:8210/v1/sys/seal-status' \
| python3 -c "import json,sys;d=json.load(sys.stdin);print(f'seal :8210 sealed={d[\"sealed\"]}')"
# Public endpoints
curl -sS -o /dev/null -w "auth %{http_code}\n" https://auth.datasciencescorporation.co.za/debug/healthz
curl -sS -o /dev/null -w "onboard %{http_code}\n" https://onboard.datasciencescorporation.co.za/healthz
# Hook activity (last 5 min)
docker logs auth-a-idp-hook --since 5m 2>&1 | grep -cE "req-trigger:|authz"
ssh root@10.60.21.31 'docker logs auth-b-idp-hook --since 5m 2>&1 | grep -cE "req-trigger:|authz"'
If everything above is green and the user-visible symptom persists, the problem is downstream (CF Tunnel routing, customer's IdP, DNS, ISP). Test from outside the LAN: