8000 fix: ignore resource.Quantity string cache in ActionPlan diff by yuminn-k · Pull Request #2130 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

Skip to content

fix: ignore resource.Quantity string cache in ActionPlan diff - #2130

Open
yuminn-k wants to merge 3 commits into
Altinity:0.28.0from
yuminn-k:fix-action-plan-quantity-string
Open

yuminn-k wants to merge 3 commits into
Altinity:0.28.0from
yuminn-k:fix-action-plan-quantity-string

Conversation

@yuminn-k
@yuminn-k yuminn-k commented Nov 1, 2026 •
Copy link
Copy Markdown

Fixes #1904

Problem

resource.Quantity caches its string form lazily in the unexported .s field. The ancestor CR stored in status and the freshly normalized CR can hold the same quantity, one with that cache and one without. MakeActionPlan diffs specs with messagediff, which also compares unexported fields. It reports the difference as a spec change:

diff item [0]:'.Templates.PodTemplates[0].Spec.Containers[0].Resources.Limits["memory"].s' = '""'

HasActionsToDo() then returns true. A CR with a limit such as 2048Mi is reconciled again and again, even though the StatefulSet comparison finds nothing to update.

Change

isExcludedPathSegment now skips the .s path segment, the same way it already skips ResourceVersion and TaskID. The quantity's value lives in its other fields (i, d, Format), so a real change is still planned.

Testing

TestActionPlanIgnoresQuantityStringCache in action_plan_test.go builds two CHIs with the same 2048Mi memory limit, one with the string cache filled and one without.

  • Before the fix, the test fails and the plan contains the exact diff line from the issue.
  • After the fix, the plan is empty.
  • A real change (2048Mi to 4Gi) still produces a plan.

go test ./pkg/apis/clickhouse.altinity.com/v1/ passes and go build ./... succeeds. Locally, pkg/model/chbackup and pkg/model/clickhouse (TestEnforceVerifiedLegacyTLS) fail on macOS on the base commit too, so this change does not cause them.

AI disclosure: Written with Claude Code (Claude Opus 5.5)

🤖 Generated with Claude Code

resource.Quantity caches its string form lazily in the unexported .s
field. The ancestor CR and the freshly normalized CR can hold the same
quantity with and without that cache, and messagediff reported the
difference as a spec change. A CR with a memory limit such as 2048Mi
was therefore reconciled again and again with nothing to change.
Exclude the .s path from the spec diff.

Signed-off-by: YuMin Kim <yuminkim.dev@gmail.com>
@chatgpt-codex-connector
chatgpt-codex-connector Bot commented Nov 1, 2026 •
Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T00:42:26.187118Z 7ab2016 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0