File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55from urllib .parse import urljoin
66from uuid import UUID
77
8+ import aiohttp
89from aiohttp import ClientSession
910from fastapi import status
1011from fastapi .encoders import jsonable_encoder
@@ -134,7 +135,9 @@ async def relay_session(self) -> ClientSession:
134135 ) from e
135136 self ._relay_token = obj .token
136137 self ._relay_session = ClientSession (
137- headers = {"Authorization" : f"Bearer { self ._relay_token } " }, trust_env = True
138+ headers = {"Authorization" : f"Bearer { self ._relay_token } " },
139+ trust_env = True ,
140+ timeout = aiohttp .ClientTimeout (total = sidecar_config .CONTROL_PLANE_TIMEOUT ),
138141 )
139142 return self ._relay_session
140143
Original file line number Diff line number Diff line change @@ -172,6 +172,7 @@ async def proxy_request_to_cloud_service(
172172 path : str ,
173173 cloud_service_url : str ,
174174 additional_headers : dict [str , str ],
175+ timeout : int = sidecar_config .CONTROL_PLANE_TIMEOUT ,
175176) -> Response :
176177 auth_header = request .headers .get ("Authorization" )
177178 if auth_header is None :
@@ -200,9 +201,7 @@ async def proxy_request_to_cloud_service(
200201
201202 logger .info (f"Proxying request: { request .method } { path } " )
202203
203- async with aiohttp .ClientSession (
204- trust_env = True ,
205- ) as session :
204+ async with aiohttp .ClientSession (trust_env = True , timeout = aiohttp .ClientTimeout (total = timeout )) as session :
206205 if request .method == HTTP_GET :
207206 async with session .get (path , headers = headers , params = params ) as backend_response :
208207 return await proxy_response (backend_response )
You can’t perform that action at this time.
0 commit comments