Compare commits

..

No commits in common. "3472e1767a68b9b316889518be762a321d91bcc3" and "6421edfc25047386ddf05fbe79fc97df40bcb3e5" have entirely different histories.

2 changed files with 10 additions and 37 deletions

View File

@ -1,7 +1,5 @@
from __future__ import annotations from __future__ import annotations
import logging
import time
from typing import Any from typing import Any
import httpx import httpx
@ -9,8 +7,6 @@ from flask import jsonify, request
from . import settings from . import settings
logger = logging.getLogger(__name__)
class AriadneError(Exception): class AriadneError(Exception):
def __init__(self, message: str, status_code: int = 502) -> None: def __init__(self, message: str, status_code: int = 502) -> None:
@ -43,38 +39,17 @@ def request_raw(
if not enabled(): if not enabled():
raise AriadneError("ariadne not configured", 503) raise AriadneError("ariadne not configured", 503)
url = _url(path) try:
attempts = max(1, settings.ARIADNE_RETRY_COUNT) with httpx.Client(timeout=settings.ARIADNE_TIMEOUT_SEC) as client:
for attempt in range(1, attempts + 1): return client.request(
try: method,
with httpx.Client(timeout=settings.ARIADNE_TIMEOUT_SEC) as client: _url(path),
resp = client.request( headers=_auth_headers(),
method, json=payload,
url, params=params,
headers=_auth_headers(),
json=payload,
params=params,
)
if resp.status_code >= 500:
logger.warning(
"ariadne error response",
extra={"method": method, "path": path, "status": resp.status_code},
)
return resp
except httpx.RequestError as exc:
logger.warning(
"ariadne request failed",
extra={
"method": method,
"path": path,
"attempt": attempt,
"timeout_sec": settings.ARIADNE_TIMEOUT_SEC,
"error": str(exc),
},
) )
if attempt >= attempts: except httpx.RequestError as exc:
raise AriadneError("ariadne unavailable", 502) from exc raise AriadneError("ariadne unavailable", 502) from exc
time.sleep(settings.ARIADNE_RETRY_BACKOFF_SEC * attempt)
def proxy( def proxy(

View File

@ -50,8 +50,6 @@ KEYCLOAK_ADMIN_REALM = os.getenv("KEYCLOAK_ADMIN_REALM", KEYCLOAK_REALM)
ARIADNE_URL = os.getenv("ARIADNE_URL", "").strip() ARIADNE_URL = os.getenv("ARIADNE_URL", "").strip()
ARIADNE_TIMEOUT_SEC = float(os.getenv("ARIADNE_TIMEOUT_SEC", "10")) ARIADNE_TIMEOUT_SEC = float(os.getenv("ARIADNE_TIMEOUT_SEC", "10"))
ARIADNE_RETRY_COUNT = int(os.getenv("ARIADNE_RETRY_COUNT", "2"))
ARIADNE_RETRY_BACKOFF_SEC = float(os.getenv("ARIADNE_RETRY_BACKOFF_SEC", "0.2"))
ACCOUNT_ALLOWED_GROUPS = [ ACCOUNT_ALLOWED_GROUPS = [
g.strip() g.strip()