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

Commit

Permalink
Handle pod failures for all policies (#189)
Browse files Browse the repository at this point in the history
If a pod is in phase failure we have to create a new one.
Currently it was assumed the pod would restart due to a RestartPolicy on the pod level
This doesn't work if the pod fails for a system reason.
  • Loading branch information
georgkaleido authored Jun 9, 2022
1 parent b5b18e6 commit 8f0ddb5
Showing 1 changed file with 11 additions and 9 deletions.
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

0 comments on commit 8f0ddb5

Please sign in to comment.