@@ -47,35 +47,36 @@ async def fetch_new_compute_session(
4747 sessions_url = f"{ compute_ctx .compute_url } /v1/sessions"
4848
4949 res = None
50- need_new_session = False
50+ create_reason = None
5151
5252 try :
5353 async with client_session .get (sessions_url , headers = headers ) as get_response :
5454 log .debug (f"GET /v1/sessions - status: { get_response .status } " )
5555 if get_response .status == 404 :
56- need_new_session = True
56+ create_reason = "no sessions endpoint (404)"
5757 else :
5858 get_response .raise_for_status ()
5959 res = await get_response .json ()
6060
6161 if not res :
62- need_new_session = True
62+ create_reason = "empty response"
6363 elif isinstance (res , list ) and len (res ) == 0 :
64- need_new_session = True
64+ create_reason = "no existing sessions"
6565 elif isinstance (res , dict ) and not res .get ("session_uuid" ):
66- need_new_session = True
66+ create_reason = "response missing session_uuid"
6767
6868 except aiohttp .ClientResponseError as e :
6969 if e .status == 404 :
70- need_new_session = True
70+ create_reason = "no sessions endpoint (404)"
7171 else :
7272 raise ComputeSessionException (
7373 f"Failed to fetch existing sessions: { e .message } " ,
7474 ) from e
7575 except Exception as e :
7676 raise ComputeSessionException (f"Unexpected error fetching sessions: { str (e )} " ) from e
7777
78- if need_new_session :
78+ if create_reason :
79+ log .debug (f"Creating new session: { create_reason } " )
7980 try :
8081 body = {}
8182 if compute_ctx .pipeline_image :
0 commit comments