Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion horizon/opal_relay_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from urllib.parse import urljoin
from uuid import UUID

import aiohttp
from aiohttp import ClientSession
from fastapi import status
from fastapi.encoders import jsonable_encoder
Expand Down Expand Up @@ -134,7 +135,9 @@ async def relay_session(self) -> ClientSession:
) from e
self._relay_token = obj.token
self._relay_session = ClientSession(
headers={"Authorization": f"Bearer {self._relay_token}"}, trust_env=True
headers={"Authorization": f"Bearer {self._relay_token}"},
trust_env=True,
timeout=aiohttp.ClientTimeout(total=sidecar_config.CONTROL_PLANE_TIMEOUT),
)
return self._relay_session

Expand Down
5 changes: 2 additions & 3 deletions horizon/proxy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ async def proxy_request_to_cloud_service(
path: str,
cloud_service_url: str,
additional_headers: dict[str, str],
timeout: int = sidecar_config.CONTROL_PLANE_TIMEOUT,
) -> Response:
auth_header = request.headers.get("Authorization")
if auth_header is None:
Expand Down Expand Up @@ -200,9 +201,7 @@ async def proxy_request_to_cloud_service(

logger.info(f"Proxying request: {request.method} {path}")

async with aiohttp.ClientSession(
trust_env=True,
) as session:
async with aiohttp.ClientSession(trust_env=True, timeout=aiohttp.ClientTimeout(total=timeout)) as session:
if request.method == HTTP_GET:
async with session.get(path, headers=headers, params=params) as backend_response:
return await proxy_response(backend_response)
Expand Down
Loading