Skip to content

Commit 0b2632c

Browse files
committed
added check for successfull and failed pods in job_controller_actions
Signed-off-by: Kevin Jacob <[email protected]>
1 parent e7bf847 commit 0b2632c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pkg/controllers/job/job_controller_actions.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (cc *jobcontroller) killPods(jobInfo *apis.JobInfo, podRetainPhase state.Ph
9797
var total int
9898

9999
podsToKill := make(map[string]*v1.Pod)
100-
100+
podsToBeRetained := make(map[string]*v1.Pod)
101101
if target != nil {
102102
if target.Type == state.TargetTypeTask {
103103
if targetPods, found := jobInfo.Pods[target.TaskName]; found {
@@ -139,6 +139,8 @@ func (cc *jobcontroller) killPods(jobInfo *apis.JobInfo, podRetainPhase state.Ph
139139

140140
if !retain {
141141
podsToKill[pod.Name] = pod
142+
} else {
143+
podsToBeRetained[pod.Name] = pod
142144
}
143145
}
144146
}
@@ -164,6 +166,16 @@ func (cc *jobcontroller) killPods(jobInfo *apis.JobInfo, podRetainPhase state.Ph
164166
calcPodStatus(pod, taskStatusCount)
165167
}
166168

169+
for _, pod := range podsToBeRetained {
170+
if pod.DeletionTimestamp != nil {
171+
klog.Infof("Pod <%s/%s> is terminating", pod.Namespace, pod.Name)
172+
terminating++
173+
continue
174+
}
175+
classifyAndAddUpPodBaseOnPhase(pod, &pending, &running, &succeeded, &failed, &unknown)
176+
calcPodStatus(pod, taskStatusCount)
177+
}
178+
167179
if len(errs) != 0 {
168180
klog.Errorf("failed to kill pods for job %s/%s, with err %+v", job.Namespace, job.Name, errs)
169181
cc.recorder.Event(job, v1.EventTypeWarning, FailedDeletePodReason,

0 commit comments

Comments
 (0)