From b5835b2fa5a6e3d488b6bdfe70d6a97b7890ec83 Mon Sep 17 00:00:00 2001 From: merryzhou Date: Mon, 9 Nov 2020 16:13:07 +0800 Subject: [PATCH] fix: terminate job and release resources when drop job out of queue Signed-off-by: merryzhou --- pkg/controllers/job/job_controller.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/controllers/job/job_controller.go b/pkg/controllers/job/job_controller.go index 41b89a79fe..8d55edb1cf 100644 --- a/pkg/controllers/job/job_controller.go +++ b/pkg/controllers/job/job_controller.go @@ -337,6 +337,10 @@ func (cc *jobcontroller) processNextReq(count uint32) bool { } cc.recordJobEvent(jobInfo.Job.Namespace, jobInfo.Job.Name, batchv1alpha1.ExecuteAction, fmt.Sprintf( "Job failed on action %s for retry limit reached", action)) + klog.Warningf("Terminating Job <%s/%s> and releasing resources", jobInfo.Job.Namespace, jobInfo.Job.Name) + if err = st.Execute(busv1alpha1.TerminateJobAction); err != nil { + klog.Errorf("Failed to terminate Job<%s/%s>: %v", jobInfo.Job.Namespace, jobInfo.Job.Name, err) + } klog.Warningf("Dropping job<%s/%s> out of the queue: %v because max retries has reached", jobInfo.Job.Namespace, jobInfo.Job.Name, err) }