Skip to content

Commit 9afbfac

Browse files
committed
fix: treat MaxConcurrentReconciles=0 as unlimited
Fixes CodeRabbit review feedback where value 0 should mean "unlimited" instead of falling back to controller-runtime default. Changes: - Map value 0 to 1000 (effectively unlimited) in GetMaxConcurrentReconciles() - Change condition from > 0 to >= 0 to always apply the option - Update documentation to clarify 0 = unlimited behavior - Update Helm values.yaml comment This ensures that setting MAX_CONCURRENT_RECONCILES=0 provides true unlimited concurrency as documented, rather than defaulting to 1.
1 parent b68810b commit 9afbfac

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

helm/operator/STACK_CONCURRENCY.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ helm install operator ./helm/operator \
2525
### Default Behavior
2626

2727
- **Default value: `5`** (good balance for most clusters)
28-
- Set to `0` to use controller-runtime default (typically 1 concurrent reconciliation)
29-
- For near-unlimited concurrency, set a high value like `1000`
28+
- Set to `0` for unlimited concurrency (mapped to 1000 internally)
29+
- Any positive value (1-999) sets that exact limit
3030

3131
## Recommended Values
3232

@@ -230,6 +230,10 @@ spec:
230230
func GetMaxConcurrentReconciles() int {
231231
if v := os.Getenv("MAX_CONCURRENT_RECONCILES"); v != "" {
232232
if n, err := strconv.Atoi(v); err == nil && n >= 0 {
233+
if n == 0 {
234+
// Treat 0 as "unlimited" by using a very high value
235+
return 1000
236+
}
233237
return n
234238
}
235239
}

helm/operator/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ operator:
5050
enableLeaderElection: true
5151

5252
# Maximum number of concurrent reconciliations (applies to all resources: stacks, modules, etc.)
53-
# Set to 0 for unlimited
53+
# Set to 0 for unlimited (mapped to 1000 internally)
5454
# Recommended values: 5 for small/medium clusters, 10 for large, 20 for XL
5555
# @section -- Concurrency Control
5656
maxConcurrentReconciles: 5

internal/core/concurrency.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ import (
66
)
77

88
// GetMaxConcurrentReconciles returns the maximum number of concurrent reconciliations
9-
// from the MAX_CONCURRENT_RECONCILES environment variable, or a default value of 5
9+
// from the MAX_CONCURRENT_RECONCILES environment variable, or a default value of 5.
10+
// A value of 0 is treated as "unlimited" and mapped to a very high value (1000).
1011
func GetMaxConcurrentReconciles() int {
1112
if v := os.Getenv("MAX_CONCURRENT_RECONCILES"); v != "" {
1213
if n, err := strconv.Atoi(v); err == nil && n >= 0 {
14+
if n == 0 {
15+
// Treat 0 as "unlimited" by using a very high value
16+
return 1000
17+
}
1318
return n
1419
}
1520
}

internal/core/reconciler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ func withReconciler[T client.Object](controller ObjectController[T], opts ...Rec
234234
}
235235
}
236236

237-
// Apply MaxConcurrentReconciles if specified (0 means use controller-runtime default)
238-
if options.MaxConcurrentReconciles > 0 {
237+
// Apply MaxConcurrentReconciles if specified (always apply when >= 0)
238+
if options.MaxConcurrentReconciles >= 0 {
239239
b = b.WithOptions(controllerconfig.Options{
240240
MaxConcurrentReconciles: options.MaxConcurrentReconciles,
241241
})

0 commit comments

Comments
 (0)