From a1f0fc8f72441ce501142d9d6a86ecbe19c9b55b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A4=E4=B9=9D?= Date: Wed, 7 Aug 2024 10:19:16 +0800 Subject: [PATCH] support the job controller handles the orphan pod using multi workers --- pkg/controller/job/job_controller.go | 3 +-- pkg/controller/job/job_controller_test.go | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/controller/job/job_controller.go b/pkg/controller/job/job_controller.go index 28d713a3a87..df8d9367f28 100644 --- a/pkg/controller/job/job_controller.go +++ b/pkg/controller/job/job_controller.go @@ -232,10 +232,9 @@ func (jm *Controller) Run(ctx context.Context, workers int) { for i := 0; i < workers; i++ { go wait.UntilWithContext(ctx, jm.worker, time.Second) + go wait.UntilWithContext(ctx, jm.orphanWorker, time.Second) } - go wait.UntilWithContext(ctx, jm.orphanWorker, time.Second) - <-ctx.Done() } diff --git a/pkg/controller/job/job_controller_test.go b/pkg/controller/job/job_controller_test.go index 49e814c1d8f..9bcee76ef98 100644 --- a/pkg/controller/job/job_controller_test.go +++ b/pkg/controller/job/job_controller_test.go @@ -7627,6 +7627,8 @@ func TestFinalizerCleanup(t *testing.T) { // Initialize the controller with 0 workers to make sure the // pod finalizers are not removed by the "syncJob" function. go manager.Run(ctx, 0) + // Make sure the pod finalizers are removed by the "orphanWorker" function. + go wait.UntilWithContext(ctx, manager.orphanWorker, time.Second) // Create a simple Job job := newJob(1, 1, 1, batch.NonIndexedCompletion)