@@ -185,28 +185,33 @@ async def status_check_fastapi(request: web.Request, vm_id: Optional[ItemHash] =
185185 # Default to the value in the settings.
186186 fastapi_vm_id : ItemHash = vm_id or ItemHash (settings .CHECK_FASTAPI_VM_ID )
187187
188- async with aiohttp .ClientSession () as session :
189- result = {
190- "index" : await status .check_index (session , fastapi_vm_id ),
191- "environ" : await status .check_environ (session , fastapi_vm_id ),
192- "messages" : await status .check_messages (session , fastapi_vm_id ),
193- "dns" : await status .check_dns (session , fastapi_vm_id ),
194- "ipv4" : await status .check_ipv4 (session , fastapi_vm_id ),
195- "internet" : await status .check_internet (session , fastapi_vm_id ),
196- "cache" : await status .check_cache (session , fastapi_vm_id ),
197- "persistent_storage" : await status .check_persistent_storage (session , fastapi_vm_id ),
198- "error_handling" : await status .check_error_raised (session , fastapi_vm_id ),
199- }
200- if not retro_compatibility :
201- # These fields were added in the runtime running Debian 12.
202- result = result | {
203- "lifespan" : await status .check_lifespan (session , fastapi_vm_id ),
204- # IPv6 requires extra work from node operators and is not required yet.
205- # "ipv6": await status.check_ipv6(session),
188+ try :
189+ async with aiohttp .ClientSession () as session :
190+ result = {
191+ "index" : await status .check_index (session , fastapi_vm_id ),
192+ "environ" : await status .check_environ (session , fastapi_vm_id ),
193+ "messages" : await status .check_messages (session , fastapi_vm_id ),
194+ "dns" : await status .check_dns (session , fastapi_vm_id ),
195+ "ipv4" : await status .check_ipv4 (session , fastapi_vm_id ),
196+ "internet" : await status .check_internet (session , fastapi_vm_id ),
197+ "cache" : await status .check_cache (session , fastapi_vm_id ),
198+ "persistent_storage" : await status .check_persistent_storage (session , fastapi_vm_id ),
199+ "error_handling" : await status .check_error_raised (session , fastapi_vm_id ),
206200 }
207-
201+ if not retro_compatibility :
202+ # These fields were added in the runtime running Debian 12.
203+ result = result | {
204+ "lifespan" : await status .check_lifespan (session , fastapi_vm_id ),
205+ # IPv6 requires extra work from node operators and is not required yet.
206+ # "ipv6": await status.check_ipv6(session),
207+ }
208+
209+ return web .json_response (
210+ result , status = 200 if all (result .values ()) else 503 , headers = {"Access-Control-Allow-Origin" : "*" }
211+ )
212+ except aiohttp .ServerDisconnectedError as error :
208213 return web .json_response (
209- result , status = 200 if all ( result . values ()) else 503 , headers = {"Access-Control-Allow-Origin" : "*" }
214+ { "error" : f"Server disconnected: { error } " }, status = 503 , headers = {"Access-Control-Allow-Origin" : "*" }
210215 )
211216
212217
0 commit comments