@@ -1235,7 +1235,7 @@ async def is_scaling_elastic_ep(raw_request: Request):
12351235 HTTPStatus .INTERNAL_SERVER_ERROR .value : {"model" : ErrorResponse },
12361236 },
12371237)
1238- async def send_fault_tolerance_instruction (raw_request : Request ):
1238+ async def process_fault_tolerance_instruction (raw_request : Request ):
12391239 try :
12401240 body = await raw_request .json ()
12411241 except json .JSONDecodeError as e :
@@ -1250,50 +1250,51 @@ async def send_fault_tolerance_instruction(raw_request: Request):
12501250 if fault_tolerance_instruction is None or fault_tolerance_timeout is None :
12511251 raise HTTPException (
12521252 status_code = 400 ,
1253- detail = "fault_tolerance_instruction and"
1254- " fault_tolerance_timeout is required" ,
1253+ detail = "Both ' fault_tolerance_instruction' and "
1254+ "' fault_tolerance_timeout' are required. " ,
12551255 )
12561256
12571257 if not isinstance (fault_tolerance_instruction , str ):
12581258 raise HTTPException (
1259- status_code = 400 , detail = "fault_tolerance_instruction must be a str "
1259+ status_code = 400 , detail = "' fault_tolerance_instruction' must be a string. "
12601260 )
1261- # Currently, only two types of instructions are supported : [pause, retry].
1262- # Additional descaling instructions will be supported in future updates.
1261+ # Supported instructions: [" pause", " retry" ].
1262+ # More instruction types may be added in future updates.
12631263 elif fault_tolerance_instruction not in ["pause" , "retry" ]:
12641264 raise HTTPException (
1265- status_code = 400 , detail = "not a valid fault_tolerance_instruction"
1265+ status_code = 400 , detail = "Invalid ' fault_tolerance_instruction' value. "
12661266 )
12671267
12681268 if not isinstance (fault_tolerance_timeout , int ) or fault_tolerance_timeout <= 0 :
12691269 raise HTTPException (
1270- status_code = 400 , detail = "fault_tolerance_timeout must be a positive integer"
1270+ status_code = 400 ,
1271+ detail = "'fault_tolerance_timeout' must be a positive integer." ,
12711272 )
12721273 try :
1273- execute_result = await client .handle_fault (
1274+ success = await client .handle_fault (
12741275 fault_tolerance_instruction ,
12751276 fault_tolerance_timeout ,
12761277 ** dynamic_fault_tolerance_params ,
12771278 )
1278- if execute_result :
1279+ if success :
12791280 return JSONResponse (
12801281 {
1281- "message" : "instruction has been executed successfully" ,
1282+ "message" : "Instruction executed successfully. " ,
12821283 }
12831284 )
12841285 else :
1285- logger .error ("Fault tolerance failed, shutdown the app ." )
1286+ logger .error ("Fault tolerance failed. Shutting down the application ." )
12861287 client .shutdown ()
12871288 raise HTTPException (
12881289 status_code = 400 ,
12891290 detail = "Instruction execution failed." ,
12901291 )
12911292
12921293 except Exception as e :
1293- logger .error ("Handle fault failed : %s" , e )
1294+ logger .error ("Failed to handle fault : %s" , e )
12941295 raise HTTPException (
12951296 status_code = HTTPStatus .INTERNAL_SERVER_ERROR .value ,
1296- detail = "Handle fault failed " ,
1297+ detail = "Failed to handle fault. " ,
12971298 ) from e
12981299
12991300
0 commit comments