Repository navigation
Description
Description
The CHK controller currently uses controller-runtime's default MaxConcurrentReconciles=1, meaning all ClickHouseKeeperInstallation resources are reconciled serially, one at a time. There is no configuration knob to increase this value.
By contrast, the CHI controller uses a custom worker pool with a configurable reconcileCHIsThreadsNumber setting (default 10), allowing parallel reconciliation of ClickHouseInstallation resources.
This asymmetry becomes a significant bottleneck at scale.
Problem
When a spec change is applied to a large number of CHK resources (e.g., adding Prometheus metrics settings to the base spec), the single-threaded CHK controller must reconcile every resource sequentially. Each reconciliation includes:
- A hardcoded
time.Sleep()inreconcileCRAuxObjectsPreliminaryDomain(10s for same-size, 30s for upscale, 120s for downscale) - A force restart cycle when config changes are detected (scale to 0, wait, scale back up)
At ~30-40 seconds per CHK, a cluster with 1,000+ CHK resources takes 9-12 hours to complete the full reconciliation backlog. During this time, any newly created CHK resources are added to the back of a FIFO queue behind the re-reconciliation of existing resources, with no priority mechanism. This means new ClickHouseKeeperInstallation resources can wait hours before the operator even begins to reconcile them.
Observed metrics from a production environment
| Metric | Value |
|---|---|
| Total CHK resources | 1,000+ |
| CHK controller concurrency | 1 (hardcoded) |
| CHI controller concurrency | 100 (configurable via reconcileCHIsThreadsNumber) |
| Time per CHK reconciliation (force restart) | ~30-40 seconds |
| Estimated full backlog processing time | 9-12 hours |
Proposed Solution
Add a reconcileCHKsThreadsNumber configuration option (analogous to reconcileCHIsThreadsNumber) that maps to controller-runtime's MaxConcurrentReconciles for the CHK controller.
Code change
In cmd/operator/app/thread_keeper.go, add .WithOptions() to the builder chain:
err = ctrlRuntime.
NewControllerManagedBy(manager).
For(
&api.ClickHouseKeeperInstallation{},
builder.WithPredicates(keeperPredicate()),
).
Owns(&apps.StatefulSet{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: chop.Config().Reconcile.Runtime.ReconcileCHKsThreadsNumber,
}).
Complete(
&controller.Controller{...},
)And add ReconcileCHKsThreadsNumber to the OperatorConfigReconcileRuntime struct in pkg/apis/clickhouse.altinity.com/v1/type_configuration_chop.go, with a sensible default (e.g., 10).
Config YAML
reconcile:
runtime:
reconcileCHIsThreadsNumber: 10
reconcileCHKsThreadsNumber: 10 # <-- new
reconcileShardsThreadsNumber: 5
reconcileShardsMaxConcurrencyPercent: 50Environment
- Operator version: 0.26.3 (also verified against 0.27.0, 0.27.1, and current master — none have this setting)
- Kubernetes: GKE v1.34
- CHK resources: 1,000+
We are happy to submit a PR for this change if the approach looks good.
Activity
miguel-signoz commentedon Jul 6, 2026
Submitted a PR for this: #2033
feat: add configurable MaxConcurrentReconciles for CHK controller
feat: add configurable MaxConcurrentReconciles for CHK controller
alex-zaitsev commentedon Jul 20, 2026
0.27.2: