Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions pkg/controller/priorityqueue/priorityqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ type priorityqueue[T comparable] struct {
}

func (w *priorityqueue[T]) AddWithOpts(o AddOpts, items ...T) {
if w.shutdown.Load() {
return
}

w.lock.Lock()
defer w.lock.Unlock()

Expand Down Expand Up @@ -274,16 +278,15 @@ func (w *priorityqueue[T]) AddRateLimited(item T) {
}

func (w *priorityqueue[T]) GetWithPriority() (_ T, priority int, shutdown bool) {
w.waiters.Add(1)

w.notifyItemOrWaiterAdded()

// ref: https://github.com/kubernetes-sigs/controller-runtime/issues/3239
if w.shutdown.Load() {
var zero T
return zero, 0, true
}

w.waiters.Add(1)

w.notifyItemOrWaiterAdded()

item := <-w.get

return item.Key, item.Priority, w.shutdown.Load()
Expand Down