fix(proxy): honor allow_requests_on_db_unavailable in /health/readiness - #34936
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Greptile SummaryThe PR makes both public and detailed readiness checks honor Confidence Score: 5/5The PR appears safe to merge because both readiness paths now consistently honor the existing database fail-open setting while retaining the default 503 behavior. The helper uses the same configuration interpretation as the existing request-layer exception handling, both database-related readiness status assignments invoke it, and the added tests cover disconnected-database behavior with the setting enabled and absent.
|
| Filename | Overview |
|---|---|
| litellm/proxy/health_endpoints/_health_endpoints.py | Centralizes the database-outage readiness decision and consistently applies it to both readiness response paths without changing default behavior. |
| tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py | Adds focused regression tests for public and detailed readiness behavior with fail-open enabled and disabled; other changes are formatting-only. |
Reviews (1): Last reviewed commit: "fix(proxy): honor allow_requests_on_db_u..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
TLDR
Problem this solves:
/health/readinessreturns 503 during a DB outageallow_requests_on_db_unavailable, pulling every pod out of rotationHow it solves it:
db: disconnectedRelevant issues
Fixes #34934
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Live proxy against a real Postgres (
allow_requests_on_db_unavailable: true), then Postgres stopped mid-run to simulate the outage. The request layer already fails open on this flag; the probe now does too, so Kubernetes keeps the pod in the Service endpoints instead of yanking every replicaBefore the fix (commit
daf22ec871, the parent of this branch)After the fix (commit
ec40a2bfb3)Type
🐛 Bug Fix
Changes
allow_requests_on_db_unavailableis the HA switch that keeps the proxy serving when the database is unreachable;PrismaDBExceptionHandler.handle_db_exceptionconsults it and fails open at the request layer./health/readinessnever did. When a Prisma DB was configured but unreachable, both_resolve_public_readiness_dband_get_health_readiness_detailsflipped the response to 503 unconditionally, so a ~30s outage marked every replica NotReady at once and Kubernetes pulled them all out of the Service endpoints; the request-layer fail-open then never got a chance to run. This was a regression: before #26134 the flag did gate readinessThe fix adds
_db_unavailable_should_flip_readiness_to_503, which returnsnot PrismaDBExceptionHandler.should_allow_request_on_db_unavailable(), and both readiness paths now consult it before setting 503. Default behavior is unchanged (unreachable configured DB still 503, no DB configured still 200); only operators who explicitly set the flag now keep serving through an outageScope note: this PR fixes the primary bug (the flag gating readiness). The issue also raises secondary Helm-probe hardening items (
/health/livelinessnot restarting stuck pods,startupProbesharing the readiness path); those are separate config-surface changes and are intentionally left out to keep this isolatedFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/7fa143c1fd3740f592ba77469bd7acc6