Skip to content

Commit 866050c

Browse files
📖docs: improve MaxConcurrentReconciles documentation (#3521)
* docs: improve MaxConcurrentReconciles documentation Add detailed Go doc comments for MaxConcurrentReconciles explaining: - The option controls the number of worker goroutines processing items from the controller's work queue - Different queue items may be reconciled concurrently, but the same item is never processed by multiple workers at the same time - If the same item is added again while being processed, it is marked dirty and requeued after the current reconciliation finishes - Increasing concurrency can improve throughput but may increase load on the API server and external systems; QPS/Burst settings should be considered - Manager-level (config.Controller) and GroupKind-level configuration are also available; per-controller values take precedence * Update pkg/controller/controller.go Co-authored-by: Alvaro Aleman <alvaroaleman@users.noreply.github.com> * docs: simplify MaxConcurrentReconciles comment in TypedOptions * Update pkg/controller/controller.go Co-authored-by: Alvaro Aleman <alvaroaleman@users.noreply.github.com> --------- Co-authored-by: Alvaro Aleman <alvaroaleman@users.noreply.github.com>
1 parent 6e96526 commit 866050c

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

pkg/config/controller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ type Controller struct {
4444
// e.g. ReplicaSet in apps group (regardless of version) would be `ReplicaSet.apps`.
4545
GroupKindConcurrency map[string]int
4646

47-
// MaxConcurrentReconciles is the maximum number of concurrent Reconciles which can be run. Defaults to 1.
47+
// MaxConcurrentReconciles is the maximum number of concurrent reconciliations which can be run.
48+
// Defaults to 1.
49+
//
50+
// This value is used as a default for controllers that do not specify their own value.
51+
// Per-controller options take precedence over this setting.
52+
//
53+
// For more details on how concurrency works, see the MaxConcurrentReconciles
54+
// field in pkg/controller.TypedOptions.
4855
MaxConcurrentReconciles int
4956

5057
// CacheSyncTimeout refers to the time limit set to wait for syncing caches.

pkg/controller/controller.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,26 @@ type TypedOptions[request comparable] struct {
4545
// Defaults to false if Controller.SkipNameValidation setting from the Manager is also unset.
4646
SkipNameValidation *bool
4747

48-
// MaxConcurrentReconciles is the maximum number of concurrent Reconciles which can be run. Defaults to 1.
48+
// MaxConcurrentReconciles is the maximum number of concurrent reconciliations
49+
// that can be run. Defaults to 1.
50+
//
51+
// This value controls the number of worker goroutines that process items from
52+
// the controller's workqueue. Increasing it allows different queue items to be
53+
// reconciled in parallel, which can improve throughput when a controller manages
54+
// many objects or when reconciliation involves slow operations such as external
55+
// API calls.
56+
//
57+
// The workqueue ensures that the same item is not processed by multiple
58+
// workers at the same time. If the same item is added again while it is being
59+
// processed, it is processed again only after the current reconciliation
60+
// finishes. For the default reconcile.Request type, the item key is the object's
61+
// namespace/name.
62+
//
63+
// This option can also be configured at the manager level via
64+
// config.Controller.MaxConcurrentReconciles or per GroupKind via
65+
// config.Controller.GroupKindConcurrency (applied when using the builder
66+
// utilities and no per-controller value is set). Per-controller values
67+
// take precedence.
4968
MaxConcurrentReconciles int
5069

5170
// CacheSyncTimeout refers to the time limit set to wait for syncing caches.

pkg/internal/controller/controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type Options[request comparable] struct {
5858
NewQueue func(controllerName string, rateLimiter workqueue.TypedRateLimiter[request]) workqueue.TypedRateLimitingInterface[request]
5959

6060
// MaxConcurrentReconciles is the maximum number of concurrent Reconciles which can be run. Defaults to 1.
61+
// See controller.TypedOptions.MaxConcurrentReconciles for full documentation.
6162
MaxConcurrentReconciles int
6263

6364
// CacheSyncTimeout refers to the time limit set on waiting for cache to sync
@@ -96,7 +97,8 @@ type Controller[request comparable] struct {
9697
// Name is used to uniquely identify a Controller in tracing, logging and monitoring. Name is required.
9798
Name string
9899

99-
// MaxConcurrentReconciles is the maximum number of concurrent Reconciles which can be run. Defaults to 1.
100+
// MaxConcurrentReconciles is the number of worker goroutines spawned to process work queue items.
101+
// See controller.TypedOptions.MaxConcurrentReconciles for full documentation.
100102
MaxConcurrentReconciles int
101103

102104
// Reconciler is a function that can be called at any time with the Name / Namespace of an object and

0 commit comments

Comments
 (0)