diff --git a/pkg/controller.v1/common/job.go b/pkg/controller.v1/common/job.go index 6684b082..2bee5da3 100644 --- a/pkg/controller.v1/common/job.go +++ b/pkg/controller.v1/common/job.go @@ -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 {