feat: Automatic CHI reconciliation on operator secret changes #1734
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a mechanism to automatically reconcile all ClickHouseInstallations (CHIs) when the operator's configured Kubernetes Secret (specified in
config.yaml
underclickhouse.access.secret
) is updated.Key Changes:
Secret Watcher & Configuration Update:
ConfigManager
now includes a watcher for the configured ClickHouse access secret (pkg/chop/config_manager.go
).ConfigManager
updates its internal configuration (username, password) and calculates a SHA256 hash of the secret's data.CHOPSecretHash
) is stored in theOperatorConfig
(pkg/apis/clickhouse.altinity.com/v1/type_configuration_chop.go
).CHI Reconciliation Trigger:
ConfigManager
that gets invoked when theCHOPSecretHash
changes (pkg/chop/config_manager.go
).reconcileAllCHIsOnConfigChange
function (cmd/operator/app/thread_chi.go
).internal.altinity.com/chop-secret-hash
on the CHI's metadata and its pod templates with the newchopSecretHash
..metadata.generation
.Action Plan Update:
ActionPlan
(pkg/model/common/action_plan/action_plan.go
) now also considers changes in annotations when determining if there are actions to be performed. This is necessary for the annotation-based reconciliation trigger to work correctly.Controller Enhancement:
pkg/controller/chi/controller.go
) is now equipped with achiLister
for efficient access to CHI resources when reconciling all CHIs.Benefits:
How to Test:
config.yaml
.Caveats
For this reconciliation to happen, the ClickHouse pods needs to be restarted. A future update might change that.