### Tasks * [x] [v0.20] Design: https://github.com/kubernetes-sigs/controller-runtime/pull/3013 * [x] [v0.20] Initial implementation: https://github.com/kubernetes-sigs/controller-runtime/pull/3014 * [x] Follow-up: https://github.com/kubernetes-sigs/controller-runtime/pull/3060 * [x] [v0.21] https://github.com/kubernetes-sigs/controller-runtime/pull/3156 * [ ] Further improvements: * https://github.com/kubernetes-sigs/controller-runtime/issues/3105 * https://github.com/kubernetes-sigs/controller-runtime/issues/3157 * https://github.com/kubernetes-sigs/controller-runtime/issues/3171 * [ ] [v0.?] Enable feature per default * Add Priority parameter to reconcile.Result * Add Priority parameter to reconcile.Request (TBD, depending on use cases: https://github.com/kubernetes-sigs/controller-runtime/pull/3013#discussion_r1850435612) ### Feature enablement The feature can be enabled by setting the `UsePriorityQueue` option to true, e.g.: ```go ctrlOptions := ctrl.Options{ Controller: config.Controller{ UsePriorityQueue: ptr.To[bool](true), }, ... } mgr, err := ctrl.NewManager(restConfig, ctrlOptions) ``` ### Original issue description While discussing https://github.com/kubernetes-sigs/controller-runtime/issues/857#issuecomment-1587149384 an idea come up about having something like a priority queue, so we can give resync events a lower priority while assigning to other events a higher priority. This could help when there are many objects of the same type and at every resync period there is a storm of events being added to the queue. cc @alvaroaleman @sbueringer