Skip to content

Commit 5281cfa

Browse files
committed
attempt to fix shutdown reconcile error race
1 parent b6c5897 commit 5281cfa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkg/internal/controller/controller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,16 @@ func (c *Controller[request]) Start(ctx context.Context) error {
197197
for i := 0; i < c.MaxConcurrentReconciles; i++ {
198198
go func() {
199199
defer wg.Done()
200+
queueCtx := context.WithoutCancel(ctx)
200201
// Run a worker thread that just dequeues items, processes them, and marks them done.
201202
// It enforces that the reconcileHandler is never invoked concurrently with the same object.
202-
for c.processNextWorkItem(ctx) {
203+
Process:
204+
for c.processNextWorkItem(queueCtx) {
205+
select {
206+
case <-ctx.Done():
207+
break Process
208+
default:
209+
}
203210
}
204211
}()
205212
}

0 commit comments

Comments
 (0)