fix(health): answer 503 when MongoDB does not answer (#60) #822

Merged
sharang merged 1 commits from fix/health-db-ping into main 2026-11-04 08:17:16 +00:00
Owner

Closes #60.

GET /api/v1/health answered {"status":"ok"} unconditionally. The Docker HEALTHCHECK (Dockerfile.agent), the nightly's wait loop and scripts/smoke.sh all read it, so an agent that had lost MongoDB still counted as healthy.

What

  • New DatabasePool::ping(): a ping command on the admin database.
  • The health handler pings with a 2 s timeout and answers:
    • 200 {"status":"ok"} when MongoDB answers;
    • 503 {"status":"degraded","mongo":"unreachable"} when it does not, with a warning in the log.
  • The route stays public and untraced (PUBLIC_ENDPOINTS, UNTRACED).

Tests

  • A unit test for the status mapping.
  • The existing integration test health_endpoint_returns_ok runs against live Mongo in CI.
  • Built and tested in CI only.

🤖 Generated with Claude Code

Closes #60. `GET /api/v1/health` answered `{"status":"ok"}` unconditionally. The Docker `HEALTHCHECK` (`Dockerfile.agent`), the nightly's wait loop and `scripts/smoke.sh` all read it, so an agent that had lost MongoDB still counted as healthy. ## What - New `DatabasePool::ping()`: a `ping` command on the `admin` database. - The health handler pings with a 2 s timeout and answers: - 200 `{"status":"ok"}` when MongoDB answers; - 503 `{"status":"degraded","mongo":"unreachable"}` when it does not, with a warning in the log. - The route stays public and untraced (`PUBLIC_ENDPOINTS`, `UNTRACED`). ## Tests - A unit test for the status mapping. - The existing integration test `health_endpoint_returns_ok` runs against live Mongo in CI. - Built and tested in CI only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-04 07:59:30 +00:00
fix(health): answer 503 when MongoDB does not answer (#60)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 4m14s
CI / Check (pull_request) Successful in 17m31s
37d1737b17
GET /api/v1/health answered ok unconditionally, so the container health
check and a load balancer kept an instance that could not reach its
database. It now pings MongoDB (2 s timeout): 200 {"status":"ok"} when
it answers, 503 {"status":"degraded","mongo":"unreachable"} when not.

Closes #60.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit 2523ecb018 into main 2026-11-04 08:17:16 +00:00
Sign in to join this conversation.