Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions examples/priorityqueue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]()
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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())

Expand Down