Skip to content

feat: add /readyz readiness probe with database check#113

Merged
rubenhensen merged 2 commits into
mainfrom
feat/readiness-probe
Jul 1, 2026
Merged

feat: add /readyz readiness probe with database check#113
rubenhensen merged 2 commits into
mainfrom
feat/readiness-probe

Conversation

@rubenhensen

Copy link
Copy Markdown
Contributor

Closes #97.

Adds a /readyz readiness probe, distinct from the existing /health liveness check.

What & why

/health returns { status: 'ok' } unconditionally — it says the process is up, not that it can serve traffic. /readyz runs a select 1 against Postgres and returns:

  • 200 { status: 'ready', checks: { database: 'ok' } } when the DB is reachable;
  • 503 { status: 'unavailable', checks: { database: 'down' } } when it isn't.

This lets an orchestrator hold traffic when the database is unreachable. The container liveness HEALTHCHECK intentionally stays on /health; readiness gates should point at /readyz.

Covered by an e2e test (tests/e2e/readyz.e2e.ts) that mirrors the existing health.e2e.ts — in CI the Postgres service is up, so it asserts the 200/ready path.

Scope notes

@dobby-coder

dobby-coder Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

On it, @rubenhensen! I'm reviewing your readiness probe PR now and will post a consolidated review shortly.

@rubenhensen

Copy link
Copy Markdown
Contributor Author

/dobby review

@dobby-coder

dobby-coder Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

On it! I'm reviewing the pull request in postguard-business#113 for correctness and rule-compliance, and will post a consolidated review shortly.

@dobby-coder dobby-coder Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the /readyz readiness probe (Closes #97). The implementation is correct: select 1 via drizzle, 200 {status:ready,checks:{database:ok}} on success and 503 {status:unavailable,checks:{database:down}} on failure, distinct from the /health liveness check. Title is conventional-commit, the Closes #97 keyword is present, and the deferred IRMA/startup-validation scope is called out explicitly. Rule checks (SvelteKit route exports, CSP, promised-vs-delivered, PR title, close-keyword, vitest hoisting) all pass. Two non-blocking nits inline — no changes required to merge.

Comment thread src/routes/readyz/+server.ts Outdated
Comment thread tests/e2e/readyz.e2e.ts
@dobby-coder

dobby-coder Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Reviewed! I left a COMMENT review with two non-blocking nits:

  • Line 18 — worth considering for the probe response
  • Test coverage — a 503/down-path test would be nice to have

Everything else looks good — no blocking issues. Good to merge when you're ready.

@rubenhensen

Copy link
Copy Markdown
Contributor Author

/dobby fix the nits

@dobby-coder

dobby-coder Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

On it! I'll fix the nitpick comments and open a draft PR with the changes, then run through a review loop to make sure everything's clean before marking it ready.

Addresses review nits on #113:
- Mark both the 200/ready and 503/unavailable responses Cache-Control: no-store
  so an intermediary cache can't serve a stale readiness verdict.
- Add tests/unit/readyz-endpoint.test.ts covering both branches by stubbing
  db.execute, locking in the 503/down shape that the e2e test can't reach.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@dobby-coder dobby-coder Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rules Dobby 2 — clean. Per-rule compliance sweep + Review Dobby 2's pass both came back with zero blocking findings.

  • src/routes/readyz/+server.ts exports only GET (the NO_STORE object is a plain const, not exported) → no SvelteKit adapter build-time export violation.
  • Unit test uses the correct vi.hoisted()vi.mock() ordering; 85 unit tests pass (2 new readyz) and svelte-check reports 0 errors.
  • Both success (200/ready) and failure (503/unavailable) paths are covered by unit tests, plus a Playwright e2e happy-path test — satisfies the tests-required-on-fixes rule.
  • no-store on both 200 and 503 correctly mirrors /health; no sensitive data leaked (caught error is logged server-side only).

Approving.

@dobby-coder

dobby-coder Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Reviewed the nit-fix diff — all rules pass. ✅

  • Cache headers correct ( on both 200 and 503)
  • Mirrors behaviour as expected
  • New unit tests cover both success and failure paths, plus Playwright e2e
  • No sensitive data leaking through the probe

Approved — good to merge when you're ready.

@rubenhensen rubenhensen merged commit 36b8dad into main Jul 1, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Observability: add /readyz readiness probe (DB + IRMA) and fail-fast config validation

1 participant