harness(api): add /health/ready endpoint for kubelet readinessProbe#520
Conversation
The miot-harness Helm chart configures `readinessProbe.httpGet.path: /health/ready` but the FastAPI server only exposed `/health`, so pods deployed via the chart never became Ready. Adds a Nexo-aware readiness handler matching the chart's design: ready when Nexo isn't required (no DSN), or when DSN is set and Nexo finished booting; 503 when DSN is set but Nexo failed to enable (tunnel down, stale snapshot past the refuse-gate, tool registration failure). Closes #519 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughA new ChangesReadiness probe endpoint
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
GET /health/readytomiot_harness.api.serverso the Helm chart'sreadinessProbe.httpGet.path: /health/readypoints at a real endpoint instead of a 404.MIOT_HARNESS_NEXO_DSNunset) or when it's required andapp.state.nexo_enabledis True; 503 not_ready when DSN is set but the lifespan didn't bring Nexo up (tunnel down, snapshot stale past the refuse-gate, tool registration failure).nexo.required,nexo.enabled,nexo.tools,nexo.snapshot_age_minutesso operators cancurlto see why a pod is not ready.Closes #519
Test plan
pytest tests/api tests/test_server_lifespan.py— 14 passed, 1 skipped (pre-existing SSE skip).tests/api/test_health.pycover: no DSN → 200, DSN set + pool fails → 503, DSN set + simulated-enabled → 200. Hermetic —create_nexo_poolmocked, no real network connect.GET /health -> 200andGET /health/ready -> 200 {"status":"ready", "nexo":{"required":false,...}}.charts/miot-harness/values.yamlalready points the readiness probe at/health/ready.🤖 Generated with Claude Code
Summary by CodeRabbit