From d2c0c8b55aed8a473b23d4a860103e7d096377be Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Fri, 3 Oct 2025 08:21:47 +0200 Subject: [PATCH] Enable PQ per default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Büringer buringerst@vmware.com --- examples/priorityqueue/main.go | 3 +-- pkg/config/controller.go | 2 +- pkg/controller/controller.go | 6 +++--- pkg/controller/controller_test.go | 9 +++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/priorityqueue/main.go b/examples/priorityqueue/main.go index 8dacdcc9a3..1dc10c2cbe 100644 --- a/examples/priorityqueue/main.go +++ b/examples/priorityqueue/main.go @@ -24,7 +24,6 @@ import ( "go.uber.org/zap/zapcore" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/builder" kubeconfig "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/config" @@ -52,7 +51,7 @@ func run() error { // Setup a Manager mgr, err := manager.New(kubeconfig.GetConfigOrDie(), manager.Options{ - Controller: config.Controller{UsePriorityQueue: ptr.To(true)}, + Controller: config.Controller{}, }) if err != nil { return fmt.Errorf("failed to set up controller-manager: %w", err) diff --git a/pkg/config/controller.go b/pkg/config/controller.go index 3dafaef93b..5eea2965f6 100644 --- a/pkg/config/controller.go +++ b/pkg/config/controller.go @@ -79,7 +79,7 @@ type Controller struct { // UsePriorityQueue configures the controllers queue to use the controller-runtime provided // priority queue. // - // Note: This flag is disabled by default until a future version. This feature is currently in beta. + // Note: This flag is enabled by default. // For more details, see: https://github.com/kubernetes-sigs/controller-runtime/issues/2374. UsePriorityQueue *bool diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index afa15aebec..853788d52f 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -91,7 +91,7 @@ type TypedOptions[request comparable] struct { // UsePriorityQueue configures the controllers queue to use the controller-runtime provided // priority queue. // - // Note: This flag is disabled by default until a future version. This feature is currently in beta. + // Note: This flag is enabled by default. // For more details, see: https://github.com/kubernetes-sigs/controller-runtime/issues/2374. UsePriorityQueue *bool @@ -250,7 +250,7 @@ func NewTypedUnmanaged[request comparable](name string, options TypedOptions[req } if options.RateLimiter == nil { - if ptr.Deref(options.UsePriorityQueue, false) { + if ptr.Deref(options.UsePriorityQueue, true) { options.RateLimiter = workqueue.NewTypedItemExponentialFailureRateLimiter[request](5*time.Millisecond, 1000*time.Second) } else { options.RateLimiter = workqueue.DefaultTypedControllerRateLimiter[request]() @@ -259,7 +259,7 @@ func NewTypedUnmanaged[request comparable](name string, options TypedOptions[req if options.NewQueue == nil { options.NewQueue = func(controllerName string, rateLimiter workqueue.TypedRateLimiter[request]) workqueue.TypedRateLimitingInterface[request] { - if ptr.Deref(options.UsePriorityQueue, false) { + if ptr.Deref(options.UsePriorityQueue, true) { return priorityqueue.New(controllerName, func(o *priorityqueue.Opts[request]) { o.Log = options.Logger.WithValues("controller", controllerName) o.RateLimiter = rateLimiter diff --git a/pkg/controller/controller_test.go b/pkg/controller/controller_test.go index 335e6d830e..06138a476b 100644 --- a/pkg/controller/controller_test.go +++ b/pkg/controller/controller_test.go @@ -439,9 +439,9 @@ var _ = Describe("controller.Controller", func() { Expect(ok).To(BeTrue()) }) - It("should configure a priority queue if UsePriorityQueue is set", func() { + It("should configure a priority queue per default", func() { m, err := manager.New(cfg, manager.Options{ - Controller: config.Controller{UsePriorityQueue: ptr.To(true)}, + Controller: config.Controller{}, }) Expect(err).NotTo(HaveOccurred()) @@ -458,12 +458,13 @@ var _ = Describe("controller.Controller", func() { Expect(ok).To(BeTrue()) }) - It("should not configure a priority queue if UsePriorityQueue is not set", func() { + It("should not configure a priority queue if UsePriorityQueue is set to false", func() { m, err := manager.New(cfg, manager.Options{}) Expect(err).NotTo(HaveOccurred()) c, err := controller.New("new-controller-17", m, controller.Options{ - Reconciler: rec, + Reconciler: rec, + UsePriorityQueue: ptr.To(false), }) Expect(err).NotTo(HaveOccurred())