Skip to content

Commit 8db6fc7

Browse files
authored
Merge pull request kubernetes#126567 from fusida/refactor-job-controller
support the job controller handles the orphan pod using multi workers
2 parents cb7b4ea + a1f0fc8 commit 8db6fc7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

pkg/controller/job/job_controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,9 @@ func (jm *Controller) Run(ctx context.Context, workers int) {
232232

233233
for i := 0; i < workers; i++ {
234234
go wait.UntilWithContext(ctx, jm.worker, time.Second)
235+
go wait.UntilWithContext(ctx, jm.orphanWorker, time.Second)
235236
}
236237

237-
go wait.UntilWithContext(ctx, jm.orphanWorker, time.Second)
238-
239238
<-ctx.Done()
240239
}
241240

pkg/controller/job/job_controller_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7627,6 +7627,8 @@ func TestFinalizerCleanup(t *testing.T) {
76277627
// Initialize the controller with 0 workers to make sure the
76287628
// pod finalizers are not removed by the "syncJob" function.
76297629
go manager.Run(ctx, 0)
7630+
// Make sure the pod finalizers are removed by the "orphanWorker" function.
7631+
go wait.UntilWithContext(ctx, manager.orphanWorker, time.Second)
76307632

76317633
// Create a simple Job
76327634
job := newJob(1, 1, 1, batch.NonIndexedCompletion)

0 commit comments

Comments
 (0)