Skip to content

Commit d2c0c8b

Browse files
committed
Enable PQ per default
Signed-off-by: Stefan Büringer [email protected]
1 parent 1c75cb0 commit d2c0c8b

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

examples/priorityqueue/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
"go.uber.org/zap/zapcore"
2626
corev1 "k8s.io/api/core/v1"
27-
"k8s.io/utils/ptr"
2827
"sigs.k8s.io/controller-runtime/pkg/builder"
2928
kubeconfig "sigs.k8s.io/controller-runtime/pkg/client/config"
3029
"sigs.k8s.io/controller-runtime/pkg/config"
@@ -52,7 +51,7 @@ func run() error {
5251

5352
// Setup a Manager
5453
mgr, err := manager.New(kubeconfig.GetConfigOrDie(), manager.Options{
55-
Controller: config.Controller{UsePriorityQueue: ptr.To(true)},
54+
Controller: config.Controller{},
5655
})
5756
if err != nil {
5857
return fmt.Errorf("failed to set up controller-manager: %w", err)

pkg/config/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ type Controller struct {
7979
// UsePriorityQueue configures the controllers queue to use the controller-runtime provided
8080
// priority queue.
8181
//
82-
// Note: This flag is disabled by default until a future version. This feature is currently in beta.
82+
// Note: This flag is enabled by default.
8383
// For more details, see: https://github.com/kubernetes-sigs/controller-runtime/issues/2374.
8484
UsePriorityQueue *bool
8585

pkg/controller/controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ type TypedOptions[request comparable] struct {
9191
// UsePriorityQueue configures the controllers queue to use the controller-runtime provided
9292
// priority queue.
9393
//
94-
// Note: This flag is disabled by default until a future version. This feature is currently in beta.
94+
// Note: This flag is enabled by default.
9595
// For more details, see: https://github.com/kubernetes-sigs/controller-runtime/issues/2374.
9696
UsePriorityQueue *bool
9797

@@ -250,7 +250,7 @@ func NewTypedUnmanaged[request comparable](name string, options TypedOptions[req
250250
}
251251

252252
if options.RateLimiter == nil {
253-
if ptr.Deref(options.UsePriorityQueue, false) {
253+
if ptr.Deref(options.UsePriorityQueue, true) {
254254
options.RateLimiter = workqueue.NewTypedItemExponentialFailureRateLimiter[request](5*time.Millisecond, 1000*time.Second)
255255
} else {
256256
options.RateLimiter = workqueue.DefaultTypedControllerRateLimiter[request]()
@@ -259,7 +259,7 @@ func NewTypedUnmanaged[request comparable](name string, options TypedOptions[req
259259

260260
if options.NewQueue == nil {
261261
options.NewQueue = func(controllerName string, rateLimiter workqueue.TypedRateLimiter[request]) workqueue.TypedRateLimitingInterface[request] {
262-
if ptr.Deref(options.UsePriorityQueue, false) {
262+
if ptr.Deref(options.UsePriorityQueue, true) {
263263
return priorityqueue.New(controllerName, func(o *priorityqueue.Opts[request]) {
264264
o.Log = options.Logger.WithValues("controller", controllerName)
265265
o.RateLimiter = rateLimiter

pkg/controller/controller_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,9 @@ var _ = Describe("controller.Controller", func() {
439439
Expect(ok).To(BeTrue())
440440
})
441441

442-
It("should configure a priority queue if UsePriorityQueue is set", func() {
442+
It("should configure a priority queue per default", func() {
443443
m, err := manager.New(cfg, manager.Options{
444-
Controller: config.Controller{UsePriorityQueue: ptr.To(true)},
444+
Controller: config.Controller{},
445445
})
446446
Expect(err).NotTo(HaveOccurred())
447447

@@ -458,12 +458,13 @@ var _ = Describe("controller.Controller", func() {
458458
Expect(ok).To(BeTrue())
459459
})
460460

461-
It("should not configure a priority queue if UsePriorityQueue is not set", func() {
461+
It("should not configure a priority queue if UsePriorityQueue is set to false", func() {
462462
m, err := manager.New(cfg, manager.Options{})
463463
Expect(err).NotTo(HaveOccurred())
464464

465465
c, err := controller.New("new-controller-17", m, controller.Options{
466-
Reconciler: rec,
466+
Reconciler: rec,
467+
UsePriorityQueue: ptr.To(false),
467468
})
468469
Expect(err).NotTo(HaveOccurred())
469470

0 commit comments

Comments
 (0)