Skip to content

🐛 Priorityqueue: Shutdown on shutdown #3250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2025
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