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

Commit

Permalink
CleanPodPolicyRunning cleans Pending phase pod (#105)
Browse files Browse the repository at this point in the history
* CleanPodPolicy cleans Pending phase pod

* fix typo

* fix wording issue
  • Loading branch information
mkkb473 authored Jan 4, 2021
1 parent 31a6ec1 commit b34d87f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/controller.v1/common/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ func (jc *JobController) DeletePodsAndServices(runPolicy *apiv1.RunPolicy, job i
}

for _, pod := range pods {
if *runPolicy.CleanPodPolicy == apiv1.CleanPodPolicyRunning && pod.Status.Phase != v1.PodRunning {
// Note that pending pod will turn into running once schedulable,
// not cleaning it may leave orphan running pod in the future,
// we should treat it equivalent to running phase here.
if *runPolicy.CleanPodPolicy == apiv1.CleanPodPolicyRunning && pod.Status.Phase != v1.PodRunning && pod.Status.Phase != v1.PodPending {
continue
}
if err := jc.PodControl.DeletePod(pod.Namespace, pod.Name, job.(runtime.Object)); err != nil {
Expand Down

0 comments on commit b34d87f

Please sign in to comment.