From 44dc1d2704c8aacc55e85dae1350a1200df4938e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20G=C3=B6bel?= <dgoebel@techfak.uni-bielefeld.de> Date: Thu, 7 Jul 2022 15:59:01 +0200 Subject: [PATCH] Fix healthcheck endpoint to query RGW base URL #10 --- ProxyAPI/app/api/miscellaneous_endpints.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ProxyAPI/app/api/miscellaneous_endpints.py b/ProxyAPI/app/api/miscellaneous_endpints.py index 2cda37b..27afde8 100644 --- a/ProxyAPI/app/api/miscellaneous_endpints.py +++ b/ProxyAPI/app/api/miscellaneous_endpints.py @@ -1,21 +1,22 @@ +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"} -- GitLab