@@ -393,7 +393,8 @@ def _should_retry_job(run: Run, job: Job, job_model: JobModel) -> Optional[datet
393393 break
394394
395395 if (
396- job_model .termination_reason == JobTerminationReason .FAILED_TO_START_DUE_TO_NO_CAPACITY
396+ job_model .termination_reason is not None
397+ and job_model .termination_reason .to_retry_event () == RetryEvent .NO_CAPACITY
397398 and last_provisioned_submission is None
398399 and RetryEvent .NO_CAPACITY in job .job_spec .retry .on_events
399400 ):
@@ -403,24 +404,9 @@ def _should_retry_job(run: Run, job: Job, job_model: JobModel) -> Optional[datet
403404 return None
404405
405406 if (
406- last_provisioned_submission .termination_reason
407- == JobTerminationReason .INTERRUPTED_BY_NO_CAPACITY
408- and RetryEvent .INTERRUPTION in job .job_spec .retry .on_events
409- ):
410- return common .get_current_datetime () - last_provisioned_submission .last_processed_at
411-
412- if (
413- last_provisioned_submission .termination_reason
414- in [
415- JobTerminationReason .CONTAINER_EXITED_WITH_ERROR ,
416- JobTerminationReason .CREATING_CONTAINER_ERROR ,
417- JobTerminationReason .EXECUTOR_ERROR ,
418- JobTerminationReason .GATEWAY_ERROR ,
419- JobTerminationReason .WAITING_INSTANCE_LIMIT_EXCEEDED ,
420- JobTerminationReason .WAITING_RUNNER_LIMIT_EXCEEDED ,
421- JobTerminationReason .PORTS_BINDING_FAILED ,
422- ]
423- and RetryEvent .ERROR in job .job_spec .retry .on_events
407+ last_provisioned_submission .termination_reason is not None
408+ and last_provisioned_submission .termination_reason .to_retry_event ()
409+ in job .job_spec .retry .on_events
424410 ):
425411 return common .get_current_datetime () - last_provisioned_submission .last_processed_at
426412
0 commit comments