mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(proxy): preserve low-detail readiness status
This commit is contained in:
parent
3fd0a2d761
commit
6536088aff
2 changed files with 16 additions and 4 deletions
|
|
@ -1530,6 +1530,17 @@ def _allow_public_health_readiness_details() -> bool:
|
|||
return general_settings.get("allow_public_health_readiness_details") is True
|
||||
|
||||
|
||||
async def _set_public_readiness_status(response: Response) -> None:
|
||||
from litellm.proxy.proxy_server import prisma_client
|
||||
|
||||
if prisma_client is None:
|
||||
return
|
||||
|
||||
db_health_status = await _db_health_readiness_check()
|
||||
if db_health_status["status"] != "connected":
|
||||
response.status_code = status.HTTP_503_SERVICE_UNAVAILABLE
|
||||
|
||||
|
||||
@router.get(
|
||||
"/health/readiness",
|
||||
tags=["health"],
|
||||
|
|
@ -1542,6 +1553,8 @@ async def health_readiness(response: Response):
|
|||
"""
|
||||
if _allow_public_health_readiness_details():
|
||||
return await _get_health_readiness_details(response=response)
|
||||
|
||||
await _set_public_readiness_status(response=response)
|
||||
return {"status": "healthy"}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1520,8 +1520,7 @@ async def test_health_readiness_returns_503_when_db_disconnected():
|
|||
result = await health_readiness(response=response)
|
||||
|
||||
assert response.status_code == 503
|
||||
assert result["db"] == "disconnected"
|
||||
assert result["status"] == "healthy" # body shape unchanged for back-compat
|
||||
assert result == {"status": "healthy"}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -1544,7 +1543,7 @@ async def test_health_readiness_returns_200_when_db_connected():
|
|||
result = await health_readiness(response=response)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert result["db"] == "connected"
|
||||
assert result == {"status": "healthy"}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -1563,7 +1562,7 @@ async def test_health_readiness_returns_200_when_no_db_configured():
|
|||
result = await health_readiness(response=response)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert result["db"] == "Not connected"
|
||||
assert result == {"status": "healthy"}
|
||||
|
||||
|
||||
def test_clean_endpoint_data_strips_credentials_keeps_routing_fields():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue