Add /healthz and /healthz/sync, and probe over HTTP #27

Merged
svc-agent-writer merged 1 commit from feat/healthz into main 2026-10-31 04:20:52 +00:00

Closes #15 (epic #7).

What changed

  • GET /healthz needs no token and answers ok lag_seconds=N while the process runs and the mirror opens. Both the readiness and the liveness probe use it.
  • GET /healthz/sync answers 503 (stale lag_seconds=… max_lag_seconds=…) once any account's last successful sync is older than sync.max_lag_seconds. The default is 10 × interval_seconds, so 1200 s at the default interval. Use it for external monitoring.
  • Lag is measured for the stalest configured account. An account that has never synced reads never.
  • Neither route returns account ids, addresses or counts. The Host allowlist still applies, so both probes send Host: localhost.
  • The base deployment probes moved from tcpSocket to httpGet. The README has a Health section, and config.example.toml lists the new key.

One change from the issue

The issue asked for readiness to fail on sync lag. I did not do that: an unready pod drops out of the Service, so Grok would get 502s even though the stale mirror is still readable. Lag is reported on /healthz and judged on /healthz/sync instead. Say if you want readiness gated anyway.

Deploy note

Both starbase ConfigMaps already list localhost in allowed_hosts, so the new probes pass there. Any other deployment must list it too, or the pod never becomes ready.

Checks

  • make check: clean; 42 tests pass (3 new).
  • kubectl kustomize deploy/k8s/overlays/example renders both probes with the Host header.

🤖 Generated with Claude Code

Closes #15 (epic #7). ## What changed - `GET /healthz` needs no token and answers `ok lag_seconds=N` while the process runs and the mirror opens. Both the readiness and the liveness probe use it. - `GET /healthz/sync` answers 503 (`stale lag_seconds=… max_lag_seconds=…`) once any account's last successful sync is older than `sync.max_lag_seconds`. The default is 10 × `interval_seconds`, so 1200 s at the default interval. Use it for external monitoring. - Lag is measured for the stalest configured account. An account that has never synced reads `never`. - Neither route returns account ids, addresses or counts. The Host allowlist still applies, so both probes send `Host: localhost`. - The base deployment probes moved from `tcpSocket` to `httpGet`. The README has a Health section, and `config.example.toml` lists the new key. ## One change from the issue The issue asked for readiness to fail on sync lag. I did not do that: an unready pod drops out of the Service, so Grok would get 502s even though the stale mirror is still readable. Lag is reported on `/healthz` and judged on `/healthz/sync` instead. Say if you want readiness gated anyway. ## Deploy note Both starbase ConfigMaps already list `localhost` in `allowed_hosts`, so the new probes pass there. Any other deployment must list it too, or the pod never becomes ready. ## Checks - `make check`: clean; 42 tests pass (3 new). - `kubectl kustomize deploy/k8s/overlays/example` renders both probes with the Host header. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
/healthz answers while the mirror opens and reports sync lag without
judging it, so a stalled sync never takes the read tools down.
/healthz/sync answers 503 past sync.max_lag_seconds for monitoring.
Neither needs a token or returns account data. The probes send
Host: localhost because the Host allowlist covers every route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No description provided.