fix: wrong defaulting of setting enableDatabaseSync to false - #275
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the ClickHouseCluster API where spec.settings.enableDatabaseSync: false could be dropped during JSON serialization due to omitempty, causing the API server to apply the CRD default (true) instead. It does so by making the field a pointer so the operator can distinguish “not specified” (nil) from an explicit false.
Changes:
- Change
ClickHouseSettings.EnableDatabaseSyncfromboolto*boolto preserve explicitfalsevalues. - Update ClickHouse reconciliation logic to treat
nilas enabled (default), and skip only when explicitlyfalse. - Regenerate deepcopy logic for the new pointer field.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
internal/controller/clickhouse/sync.go |
Updates database-sync gating logic to handle pointer semantics correctly (nil vs explicit false). |
api/v1alpha1/zz_generated.deepcopy.go |
Regenerated deepcopy to correctly copy the new *bool field. |
api/v1alpha1/clickhousecluster_types.go |
Changes the API type of enableDatabaseSync to *bool while keeping the CRD default behavior. |
Files not reviewed (1)
- api/v1alpha1/zz_generated.deepcopy.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
GrigoryPervakov
enabled auto-merge (squash)
July 21, 2026 17:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
omitemptywipes thefalsevalue from JSON, and the API server sets the value to default=trueWhat
Make it a pointer to distinguish a false and "not specified" case.