Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Handle pod failures for all policies #189

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions pkg/controller.v1/common/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,18 @@ func (jc *JobController) ReconcilePods(
}
}
// Check if the pod is retryable.
if spec.RestartPolicy == apiv1.RestartPolicyExitCode {
if pod.Status.Phase == v1.PodFailed && trainutil.IsRetryableExitCode(exitCode) {
failedPodsCount.Inc()
logger.Infof("Need to restart the pod: %v.%v", pod.Namespace, pod.Name)
if err := jc.PodControl.DeletePod(pod.Namespace, pod.Name, runtimeObject); err != nil {
return err
}
// Deletion is expected
jc.Expectations.RaiseExpectations(expectationPodsKey, 0, 1)
if pod.Status.Phase == v1.PodFailed &&
(spec.RestartPolicy == apiv1.RestartPolicyExitCode && trainutil.IsRetryableExitCode(exitCode) ||
spec.RestartPolicy == apiv1.RestartPolicyOnFailure ||
spec.RestartPolicy == apiv1.RestartPolicyAlways) {
failedPodsCount.Inc()
logger.Infof("Need to restart the pod: %v.%v", pod.Namespace, pod.Name)
if err := jc.PodControl.DeletePod(pod.Namespace, pod.Name, runtimeObject); err != nil {
return err
}
// Deletion is expected
jc.Expectations.RaiseExpectations(expectationPodsKey, 0, 1)

}

updateJobReplicaStatuses(jobStatus, rType, pod)
Expand Down