fix: prevent StatefulSet infinite reconcile restart loop #132
Open
brightsparc wants to merge 2 commits intoClickHouse:mainfrom
Open
fix: prevent StatefulSet infinite reconcile restart loop #132brightsparc wants to merge 2 commits intoClickHouse:mainfrom
brightsparc wants to merge 2 commits intoClickHouse:mainfrom
Conversation
…event infinite reconcile restart loop
Extract terminationGracePeriodSeconds default (30) to a named constant in each package's constants.go. Add blank lines between if-blocks and subsequent assignments to satisfy wsl_v5. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Fixes #131
Why
The KeeperCluster and ClickHouseCluster reconcilers enter an infinite restart loop because the desired StatefulSet spec omits fields that the Kubernetes API server fills with defaults. On each reconcile,
DeepHashObjectsees a diff between the desired state (nil/zero values) and the actual state (K8s-defaulted values), concludes config has changed, and force-restarts the pod via therestartedAtannotation. This annotation change itself creates another diff on the next reconcile, producing a self-reinforcing ~30s restart loop that prevents the keeper from ever stabilising.What
Explicitly set K8s-defaulted fields in the desired StatefulSet and PodSpec so they match what the API server returns:
terminationGracePeriodSecondsto30,schedulerNameto"default-scheduler", andsecurityContextto&PodSecurityContext{}when not specified by the userrollingUpdate.partitionto0,rollingUpdate.maxUnavailableto1, andpersistentVolumeClaimRetentionPolicytoRetain/RetainsuccessThreshold: 1onDefaultLivenessProbeSettings(the K8s default — was zero-valued, causing a diff against the API server's defaulted1)Applied to both
keeperandclickhousetemplate generators. Added 8 unit tests covering each defaulted field.