@@ -1232,7 +1232,7 @@ async def is_scaling_elastic_ep(raw_request: Request):
12321232 HTTPStatus .INTERNAL_SERVER_ERROR .value : {"model" : ErrorResponse },
12331233 },
12341234)
1235- async def send_fault_tolerance_instruction (raw_request : Request ):
1235+ async def process_fault_tolerance_instruction (raw_request : Request ):
12361236 try :
12371237 body = await raw_request .json ()
12381238 except json .JSONDecodeError as e :
@@ -1247,50 +1247,51 @@ async def send_fault_tolerance_instruction(raw_request: Request):
12471247 if fault_tolerance_instruction is None or fault_tolerance_timeout is None :
12481248 raise HTTPException (
12491249 status_code = 400 ,
1250- detail = "fault_tolerance_instruction and"
1251- " fault_tolerance_timeout is required" ,
1250+ detail = "Both ' fault_tolerance_instruction' and "
1251+ "' fault_tolerance_timeout' are required. " ,
12521252 )
12531253
12541254 if not isinstance (fault_tolerance_instruction , str ):
12551255 raise HTTPException (
1256- status_code = 400 , detail = "fault_tolerance_instruction must be a str "
1256+ status_code = 400 , detail = "' fault_tolerance_instruction' must be a string. "
12571257 )
1258- # Currently, only two types of instructions are supported : [pause, retry].
1259- # Additional descaling instructions will be supported in future updates.
1258+ # Supported instructions: [" pause", " retry" ].
1259+ # More instruction types may be added in future updates.
12601260 elif fault_tolerance_instruction not in ["pause" , "retry" ]:
12611261 raise HTTPException (
1262- status_code = 400 , detail = "not a valid fault_tolerance_instruction"
1262+ status_code = 400 , detail = "Invalid ' fault_tolerance_instruction' value. "
12631263 )
12641264
12651265 if not isinstance (fault_tolerance_timeout , int ) or fault_tolerance_timeout <= 0 :
12661266 raise HTTPException (
1267- status_code = 400 , detail = "fault_tolerance_timeout must be a positive integer"
1267+ status_code = 400 ,
1268+ detail = "'fault_tolerance_timeout' must be a positive integer." ,
12681269 )
12691270 try :
1270- execute_result = await client .handle_fault (
1271+ success = await client .handle_fault (
12711272 fault_tolerance_instruction ,
12721273 fault_tolerance_timeout ,
12731274 ** dynamic_fault_tolerance_params ,
12741275 )
1275- if execute_result :
1276+ if success :
12761277 return JSONResponse (
12771278 {
1278- "message" : "instruction has been executed successfully" ,
1279+ "message" : "Instruction executed successfully. " ,
12791280 }
12801281 )
12811282 else :
1282- logger .error ("Fault tolerance failed, shutdown the app ." )
1283+ logger .error ("Fault tolerance failed. Shutting down the application ." )
12831284 client .shutdown ()
12841285 raise HTTPException (
12851286 status_code = 400 ,
12861287 detail = "Instruction execution failed." ,
12871288 )
12881289
12891290 except Exception as e :
1290- logger .error ("Handle fault failed : %s" , e )
1291+ logger .error ("Failed to handle fault : %s" , e )
12911292 raise HTTPException (
12921293 status_code = HTTPStatus .INTERNAL_SERVER_ERROR .value ,
1293- detail = "Handle fault failed " ,
1294+ detail = "Failed to handle fault. " ,
12941295 ) from e
12951296
12961297
0 commit comments