feat(api): readiness probe at /api/v1/ready (PMS-130) #68
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pms-130-readiness"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
GET /api/v1/readyfor container orchestrators. Returns{"status":"ready","checks":{"db":"ok","infisical":"ok"|"skipped"}}on 200, or{"status":"not_ready",...}with per-dependency error strings on 503.SELECT 1via the existingDatabase::health_check.<base>/api/statuswith a 2s timeout whenINFISICAL_BASE_URLis set. Skipped cleanly when unset (single-machine deployments without an Infisical sibling)./healthstays unchanged as the cheap liveness probe (no downstream calls).tests/readiness.rspins both contracts; CI integration-tests step picks up the new binary.Test plan
cargo test --test readiness(two cases)curl http://...:port/api/v1/readyreturns 200 against a healthy stack; returns 503 when Postgres is down.Closes PMS-130.
Adds `GET /api/v1/ready` for container orchestrators. Returns `{"status":"ready","checks":{"db":"ok","infisical":"ok"|"skipped"}}` on 200 or `{"status":"not_ready",...}` with a per-dependency error string on 503. The DB check runs `SELECT 1` via the existing `Database::health_check`. The Infisical check is best-effort: it activates only when the operator sets `INFISICAL_BASE_URL` (so single-machine deployments without an Infisical sibling skip cleanly), pings `<base>/api/status` with a 2-second timeout, and reports the underlying error on failure. mokosh-server loads Infisical secrets at boot only, so a transient Infisical outage does not break in-flight requests; the probe still surfaces the outage because the next process restart would otherwise fail to boot. Pairs the new endpoint with `tests/readiness.rs` (two `#[sqlx::test]` cases: `/ready` returns 200+`db:ok`+`infisical:skipped` against a fresh DB without `INFISICAL_BASE_URL`; the legacy `/health` stays plain-text `OK`) and wires the binary into the CI integration-tests step. The legacy `/health` is left untouched as the cheap liveness probe (no downstream calls). #PMS-130