Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 79e8baa609 | |||
| 3860a5d061 | |||
| 7a7aaca064 | |||
| 76781ed238 | |||
| 2b20946ad7 |
@@ -118,7 +118,7 @@ jobs:
|
|||||||
echo "CalVer tag: $VERSION"
|
echo "CalVer tag: $VERSION"
|
||||||
|
|
||||||
- name: Log in to Gitea Container Registry
|
- name: Log in to Gitea Container Registry
|
||||||
run: echo "${{ github.token }}" | docker login git.farh.net -u ${{ github.actor }} --password-stdin
|
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.farh.net -u ${{ github.actor }} --password-stdin
|
||||||
|
|
||||||
- name: Extract metadata
|
- name: Extract metadata
|
||||||
id: meta
|
id: meta
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"mcpServers": {
|
|
||||||
"gitea": {
|
|
||||||
"type": "http",
|
|
||||||
"url": "https://git-mcp.farh.net/mcp",
|
|
||||||
"headers": {
|
|
||||||
"Authorization": "Bearer ${GITEA_TOKEN}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,8 +4,8 @@ import bcrypt
|
|||||||
|
|
||||||
|
|
||||||
def hash_password(password: str) -> str:
|
def hash_password(password: str) -> str:
|
||||||
return bcrypt.hashpw(password.encode(), bcrypt.gensalt()).decode()
|
return str(bcrypt.hashpw(password.encode(), bcrypt.gensalt()).decode())
|
||||||
|
|
||||||
|
|
||||||
def verify_password(plain_password: str, hashed_password: str) -> bool:
|
def verify_password(plain_password: str, hashed_password: str) -> bool:
|
||||||
return bcrypt.checkpw(plain_password.encode(), hashed_password.encode())
|
return bool(bcrypt.checkpw(plain_password.encode(), hashed_password.encode()))
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class CacheClient:
|
|||||||
async def get(self, key: str) -> str | None:
|
async def get(self, key: str) -> str | None:
|
||||||
if not self._client:
|
if not self._client:
|
||||||
return None
|
return None
|
||||||
value = await self._client.get(key)
|
value: str | bytes | None = await self._client.get(key)
|
||||||
if value is None:
|
if value is None:
|
||||||
return None
|
return None
|
||||||
if isinstance(value, bytes):
|
if isinstance(value, bytes):
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ def _build_engine_kwargs() -> dict:
|
|||||||
kwargs.update(
|
kwargs.update(
|
||||||
pool_size=10,
|
pool_size=10,
|
||||||
max_overflow=20,
|
max_overflow=20,
|
||||||
|
pool_timeout=30,
|
||||||
pool_pre_ping=True,
|
pool_pre_ping=True,
|
||||||
pool_recycle=3600,
|
pool_recycle=3600,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,16 +1,40 @@
|
|||||||
"""Health check and error metrics endpoints."""
|
"""Health check and error metrics endpoints."""
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends
|
import logging
|
||||||
|
|
||||||
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
|
from sqlalchemy import text
|
||||||
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from cartsnitch_api.auth.dependencies import verify_service_key
|
from cartsnitch_api.auth.dependencies import verify_service_key
|
||||||
|
from cartsnitch_api.database import get_db
|
||||||
from cartsnitch_api.middleware.error_handler import get_error_monitor
|
from cartsnitch_api.middleware.error_handler import get_error_monitor
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
router = APIRouter(tags=["health"])
|
router = APIRouter(tags=["health"])
|
||||||
|
|
||||||
|
|
||||||
@router.get("/health")
|
@router.get("/health")
|
||||||
async def health():
|
async def health(db: AsyncSession = Depends(get_db)):
|
||||||
return {"status": "ok"}
|
"""Liveness + DB connectivity probe.
|
||||||
|
|
||||||
|
Returns HTTP 200 when the API process is responsive *and* the database
|
||||||
|
is reachable, so Kubernetes readiness probes can correctly route traffic
|
||||||
|
away from pods that have lost their database connection.
|
||||||
|
|
||||||
|
Returns HTTP 503 when the database is unreachable so K8s marks the pod
|
||||||
|
unhealthy and stops sending traffic to it.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
await db.execute(text("SELECT 1"))
|
||||||
|
except Exception as exc:
|
||||||
|
logger.exception("Health check failed: database unreachable")
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||||
|
detail={"status": "unavailable", "database": "disconnected"},
|
||||||
|
) from exc
|
||||||
|
return {"status": "ok", "database": "connected"}
|
||||||
|
|
||||||
|
|
||||||
@router.get("/internal/error-stats", dependencies=[Depends(verify_service_key)])
|
@router.get("/internal/error-stats", dependencies=[Depends(verify_service_key)])
|
||||||
|
|||||||
Reference in New Issue
Block a user