Skip to content

Commit

Permalink
Rename ALLOWED_QUERY_TIMEOUT -> OPA_CLIENT_QUERY_TIMEOUT
Browse files Browse the repository at this point in the history
  • Loading branch information
roekatz committed Oct 30, 2023
1 parent 5012ee7 commit 46e0835
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions horizon/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class SidecarConfig(Confi):
10,
)

ALLOWED_QUERY_TIMEOUT = confi.float(
"ALLOWED_QUERY_TIMEOUT",
OPA_CLIENT_QUERY_TIMEOUT = confi.float(
"OPA_CLIENT_QUERY_TIMEOUT",
5 * 60, # This is also aiohttp's default timeout
description="the timeout for querying OPA for an allow decision, 0 means no timeout",
)
Expand Down
4 changes: 2 additions & 2 deletions horizon/enforcer/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,15 @@ async def post_to_opa(request: Request, path: str, data: dict):
url,
data=json.dumps(data) if data is not None else None,
headers=headers,
timeout=sidecar_config.ALLOWED_QUERY_TIMEOUT,
timeout=sidecar_config.OPA_CLIENT_QUERY_TIMEOUT,
) as opa_response:
return await proxy_response(opa_response)
except asyncio.exceptions.TimeoutError:
exc = HTTPException(
status.HTTP_504_GATEWAY_TIMEOUT,
detail="OPA request timed out (url: {url}, timeout: {timeout}s)".format(
url=url,
timeout=sidecar_config.ALLOWED_QUERY_TIMEOUT,
timeout=sidecar_config.OPA_CLIENT_QUERY_TIMEOUT,
raise_for_status=True,
),
)
Expand Down

0 comments on commit 46e0835

Please sign in to comment.