Skip to content
Snippets Groups Projects
Verified Commit 44dc1d27 authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Fix healthcheck endpoint to query RGW base URL

#10
parent 8941ce39
No related branches found
No related tags found
2 merge requests!10Add OIDC login,!6First working version
Pipeline #24572 skipped
import httpx
from fastapi import APIRouter, Depends, HTTPException, status
from rgwadmin import RGWAdmin
from sqlalchemy.ext.asyncio import AsyncSession
from starlette.responses import RedirectResponse
from app.api.dependencies import get_db, get_rgw_admin
from app.api.dependencies import get_db
from app.core.config import settings
miscellaneous_router = APIRouter()
@miscellaneous_router.get("/health", include_in_schema=False)
async def health_check(db: AsyncSession = Depends(get_db), rgw: RGWAdmin = Depends(get_rgw_admin)) -> dict[str, str]:
async def health_check(db: AsyncSession = Depends(get_db)) -> dict[str, str]:
try:
assert db.is_active
except Exception:
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail="Connection to database lost")
try:
rgw.get_users()
httpx.get(settings.OBJECT_GATEWAY_URI, timeout=5.0)
except Exception:
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail="Connection to RGW lost")
return {"status": "OK"}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment