Skip to content

Commit

Permalink
fix bug in task dependsOn
Browse files Browse the repository at this point in the history
  • Loading branch information
hwdef committed Jul 14, 2022
1 parent 729dca1 commit e4f370d
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions pkg/controllers/job/job_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,25 @@ func (cc *jobcontroller) isDependsOnPodsReady(task string, job *batch.Job) bool
runningPodCount := 0
for _, podName := range dependsOnPods {
pod, err := cc.podLister.Pods(job.Namespace).Get(podName)
// If failed to get pod. There are 2 possibilities.
// 1. pod not found
// 2. Error communicating with apiserver
if err != nil {
klog.Errorf("Failed to get pod %v/%v %v", job.Namespace, podName, err)
continue
// If pod is not found. There are 2 possibilities.
// 1. vcjob has been deleted.
// 2. pod is not created.
// if 1, this function should return true.
// if 2, this function should return false, continue waiting.
if apierrors.IsNotFound(err) {
_, errGetJob := cc.jobLister.Jobs(job.Namespace).Get(job.Name)
if errGetJob != nil {
// vcjob has been deleted.
return apierrors.IsNotFound(errGetJob)
}
} else {
klog.Errorf("Failed to get pod %v/%v %v", job.Namespace, podName, err)
continue
}
}

if pod.Status.Phase != v1.PodRunning && pod.Status.Phase != v1.PodSucceeded {
Expand Down

0 comments on commit e4f370d

Please sign in to comment.