Skip to content

feat(clickhouse): add configurable version parameter - #3476

Merged
scooby87 merged 2 commits into
mainfrom
feat/clickhouse-version-param
Aug 26, 2026
Merged

scooby87 merged 2 commits into
mainfrom
feat/clickhouse-version-param

Conversation

@scooby87

@scooby87 scooby87 commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

The ClickHouse server and Keeper images were hardcoded to 24.9.2.42 in the chart templates, so the chart exposed no top-level version values key. The Cozystack API returns a managed database's engine version by passing the HelmRelease's spec.values.version straight through into the Application object, so ClickHouse instances carried no spec.version in the API — unlike postgres, mariadb, mongodb, opensearch, rabbitmq and redis, which all ship a version parameter. This closes the ClickHouse half of the gap tracked in #1246.

This adds the same version-selection scaffolding the other managed-database charts already use:

  • files/versions.yaml maps a major.minor key to the full image tag, shared by the ClickHouse server and Keeper images (both are pinned to one version).
  • templates/_versions.tpl (clickhouse.versionMap) resolves the tag and fails the render on an unsupported version.
  • values.yaml gains a version enum (v25.8, v25.3, v24.9), consumed by templates/clickhouse.yaml and templates/chkeeper.yaml.
  • hack/update-versions.sh + make update refresh the map from Docker Hub, keeping only tags published for both the server and Keeper images and preserving the current default so a regeneration never bumps the major of existing deployments.

The default stays v24.9 → 24.9.2.42, so existing installations render byte-for-byte identically and are never upgraded to a new major implicitly. The generated values.schema.json, README.md, the Go API type and the clickhouse-rd openAPISchema are regenerated with cozyvalues-gen v1.6.0. A new tests/version_test.yaml helm-unittest suite covers the server/Keeper mapping for each version and the schema-level rejection of an unsupported value.

Downstream repositories

The diff changes packages/apps/clickhouse/values.schema.json by adding a new version field with an enum. Per the trigger map, this reaches terraform-provider-cozystack, whose ClickHouse resource is hand-written and would need a matching version attribute with a stringvalidator.OneOf list and its expand/flatten pair. There is no existing PR or issue there for it yet. This is left for a maintainer decision rather than a speculative cross-repo PR, so the box below is intentionally left unticked and flagged here. No other downstream repository is reached (the website reference page is regenerated from README.md by the release docs bot; ClickHouse is already in its app list).

Release note

feat(clickhouse): add a configurable `version` parameter (v25.8, v25.3, v24.9; default v24.9) so the deployed ClickHouse version is selectable and returned through the API. Existing installations are unchanged.

Summary by CodeRabbit

  • New Features
    • Added a configurable ClickHouse version setting for both server and Keeper images, defaulting to v24.9.
    • Supported versions are v25.8, v25.3, and v24.9, with compatible image patches selected automatically.
  • Documentation
    • Documented the version setting, default, and supported values.
  • Validation
    • Unsupported versions are rejected with an error listing allowed options.
  • Tests
    • Added coverage for version mapping, defaults, invalid values, and update behavior.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a2a2750-e8fd-4aa9-a955-087999095e03

📥 Commits

Reviewing files that changed from the base of the PR and between 334e2d8 and 3c78c0b.

📒 Files selected for processing (13)
  • api/apps/v1alpha1/clickhouse/types.go
  • hack/clickhouse-update-versions_test.bats
  • packages/apps/clickhouse/Makefile
  • packages/apps/clickhouse/README.md
  • packages/apps/clickhouse/files/versions.yaml
  • packages/apps/clickhouse/hack/update-versions.sh
  • packages/apps/clickhouse/templates/_versions.tpl
  • packages/apps/clickhouse/templates/chkeeper.yaml
  • packages/apps/clickhouse/templates/clickhouse.yaml
  • packages/apps/clickhouse/tests/version_test.yaml
  • packages/apps/clickhouse/values.schema.json
  • packages/apps/clickhouse/values.yaml
  • packages/system/clickhouse-rd/cozyrds/clickhouse.yaml
🚧 Files skipped from review as they are similar to previous changes (12)
  • packages/apps/clickhouse/Makefile
  • packages/apps/clickhouse/templates/chkeeper.yaml
  • api/apps/v1alpha1/clickhouse/types.go
  • packages/apps/clickhouse/values.schema.json
  • packages/apps/clickhouse/templates/clickhouse.yaml
  • packages/apps/clickhouse/files/versions.yaml
  • packages/apps/clickhouse/README.md
  • packages/apps/clickhouse/templates/_versions.tpl
  • hack/clickhouse-update-versions_test.bats
  • packages/apps/clickhouse/tests/version_test.yaml
  • packages/apps/clickhouse/values.yaml
  • packages/apps/clickhouse/hack/update-versions.sh

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

ClickHouse version selection is added across the API, chart values and schema, version-generation tooling, Helm image templates, tests, and the ClickHouse application definition. Supported versions map to common server and Keeper image tags.

Changes

ClickHouse version selection

Layer / File(s) Summary
Version contract and chart parameters
api/apps/v1alpha1/clickhouse/types.go, packages/apps/clickhouse/values.yaml, packages/apps/clickhouse/values.schema.json, packages/apps/clickhouse/README.md
Adds the Version type and version parameter with supported values v25.8, v25.3, and v24.9. The default is v24.9 for both server and Keeper images.
Version metadata generation
packages/apps/clickhouse/hack/update-versions.sh, packages/apps/clickhouse/files/versions.yaml, packages/apps/clickhouse/Makefile, hack/clickhouse-update-versions_test.bats
Adds tooling and offline tests to discover common Docker Hub tags, generate the version map, preserve or select a default, and rewrite chart parameters atomically.
Helm image resolution and validation
packages/apps/clickhouse/templates/_versions.tpl, packages/apps/clickhouse/templates/clickhouse.yaml, packages/apps/clickhouse/templates/chkeeper.yaml, packages/apps/clickhouse/tests/version_test.yaml
Maps selected versions to image tags for ClickHouse and Keeper, rejects unsupported values, and tests default and mapped versions.
Application schema synchronization
packages/system/clickhouse-rd/cozyrds/clickhouse.yaml
Updates the stored chart-values schema and serialized key ordering.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 3c78c

The change adds selectable ClickHouse versions while preserving the existing v24.9 default, so current installations remain unchanged; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: kvaps

Sequence Diagram(s)

sequenceDiagram
  participant ChartValues
  participant ClickHouseVersionMap
  participant ServerAndKeeper
  ChartValues->>ClickHouseVersionMap: pass selected version
  ClickHouseVersionMap->>ServerAndKeeper: resolve mapped patch tag
  ServerAndKeeper-->>ChartValues: render server and Keeper images
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. (10 skipped: 10 unsupported.) Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a configurable ClickHouse version parameter to the chart and API.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/clickhouse-version-param

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size/L This PR changes 100-499 lines, ignoring generated files area/database Issues or PRs related to managed databases (postgres, mariadb, redis, etcd, kafka, clickhouse) kind/feature Categorizes issue or PR as related to a new feature labels Jul 28, 2026
@scooby87
scooby87 marked this pull request as ready for review July 28, 2026 15:22
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/apps/clickhouse/hack/update-versions.sh`:
- Around line 54-99: Make the supported-version resolution loop fail immediately
when any configured entry in SUPPORTED_MAJORS has no matching tag, instead of
warning and continuing. Ensure the failure occurs before writing VERSIONS_FILE
or updating the generated values.yaml section, preserving all configured
versions and the existing default such as v24.9.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: aff950a2-1602-46e2-9c5e-38ba89191a64

📥 Commits

Reviewing files that changed from the base of the PR and between 2c45377 and 5625b9e.

📒 Files selected for processing (12)
  • api/apps/v1alpha1/clickhouse/types.go
  • packages/apps/clickhouse/Makefile
  • packages/apps/clickhouse/README.md
  • packages/apps/clickhouse/files/versions.yaml
  • packages/apps/clickhouse/hack/update-versions.sh
  • packages/apps/clickhouse/templates/_versions.tpl
  • packages/apps/clickhouse/templates/chkeeper.yaml
  • packages/apps/clickhouse/templates/clickhouse.yaml
  • packages/apps/clickhouse/tests/version_test.yaml
  • packages/apps/clickhouse/values.schema.json
  • packages/apps/clickhouse/values.yaml
  • packages/system/clickhouse-rd/cozyrds/clickhouse.yaml

Comment thread packages/apps/clickhouse/hack/update-versions.sh Outdated

@IvanHunters IvanHunters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: request changes

The runtime chart change is sound: the version enum feeds only the image tag, the default v24.9 renders 24.9.2.42 byte-identical to the previous hardcoded tags (so existing installs need no migration), it is not a mutable-identity field (no metadata.name/selector/content-hash derives from it), and helm unittest passes 17/17. The pattern correctly mirrors the sibling DB charts.

The blocking items are all in the hack/update-versions.sh generator and the reproducibility of the committed files/versions.yaml, not in the rendered chart.

Blocking

1. comm is fed version-sorted input and silently drops common tags.
fetch_tags ends with sort -Vu, and that version-sorted output is passed to comm -12. comm requires inputs sorted in the collation order it walks (lexicographic), so it mis-compares at every X.9 -> X.10 boundary where version order and lexicographic order diverge.

Reproduction:

server (sort -V): 24.9.2.42, 24.10.1.1, 25.3.14.14
keeper (sort -V): 24.10.1.1, 25.3.14.14
comm -12 (version-sorted, as the script does)  => 25.3.14.14        # 24.10.1.1 lost, exit 0, no warning
comm -12 (lexicographically sorted, correct)   => 24.10.1.1, 25.3.14.14

Consequence: on the next make update, a whole major line can drop out of COMMON_TAGS, the script prints only Warning: no tag found for X.Y, skipping, and that major disappears from the enum. Existing tenant CRs pinned to the dropped version then fail schema validation. Fix is one line: feed comm a plain sort -u (lexicographic) intersection, and keep sort -V only for the per-major tail -n1 pick, which already does it.

2. The committed files/versions.yaml is not reproducible by its own generator.
The file pins v24.9 -> 24.9.2.42, but the latest patch common to both clickhouse/clickhouse-server and clickhouse/clickhouse-keeper on the 24.9 line is 24.9.3.128 (verified against Docker Hub, present in both repos). The generator selects the latest patch per major (sort -V | tail -n1), so the first real make update would write v24.9 -> 24.9.3.128, changing the image for every default-version install and turning tests/version_test.yaml red (it hardcodes 24.9.2.42).

The PR body only promises to preserve the major, which is honoured, but the "renders byte-for-byte identically" guarantee and the test assertion both rest on a hand-pinned patch the generator will not reproduce. Please either add a patch-pin mechanism for the default line, or have version_test.yaml derive the expected tag from files/versions.yaml instead of hardcoding it, so the generator and the committed artifacts cannot drift apart.

Should fix (robustness)

3. Non-atomic regeneration. update-versions.sh writes versions.yaml before it edits values.yaml, and make generate is a separate step. A failure in between (see item 4) leaves versions.yaml updated while the enum/schema/README/types.go are stale. Collect all outputs into temp files and apply them at the end.

4. Does not run on stock macOS. declare -A requires bash 4+ (macOS ships 3.2), and BSD awk rejects -v new_section=... with embedded newlines (awk: newline in string). Combined with item 3 this corrupts the tree mid-run. If make update requires GNU awk + bash 4, state it; otherwise make the script portable.

Non-blocking notes

  • Downgrade hazard. version is editable with no ordering guard, so v25.8 -> v24.9 is reachable and schema-valid. ClickHouse cannot read data written by a newer server, and Keeper snapshots are not backward compatible, so a downgrade lands the pods in CrashLoopBackOff with no legible "downgrade unsafe" signal. This matches existing precedent (postgres et al. have the same gap), so a CEL immutability guard is not required, but please add a warning to the parameter description.
  • Default v24.9 is an EOL non-LTS line (LTS are 25.3 and 25.8). Preserving it for existing installs is correct, but fresh installs get an EOL default by omission.
  • templates/_versions.tpl fail branch is effectively dead code behind schema-enum validation (harmless defense-in-depth).
  • tests/version_test.yaml asserts on the Helm-4 jsonschema error string, which is brittle across helm versions in CI.
  • The server/Keeper image references are neither digest-pinned nor routed through cozy-lib.image, so mirrored/air-gapped installs cannot rewrite the registry. Pre-existing, but the new version-map indirection is a natural place to add mirror routing.

@IvanHunters

Copy link
Copy Markdown
Collaborator

Follow-up: I re-ran the generator end-to-end against the live Docker Hub catalogs (server 540 tags, keeper 401) to pin down the exact current impact of the two blocking items. Refined severity:

Item 2 (versions.yaml not reproducible) is the immediate one. The generator's per-major pick resolves v24.9 -> 24.9.3.128 today, on both the buggy and the correct intersection path, so it is independent of item 1. Committed is 24.9.2.42. The very next make update therefore changes the default image and turns tests/version_test.yaml red. This is concrete now, not hypothetical.

Item 1 (comm on version-sorted input) is real but currently latent. The buggy comm path returns 395 common tags vs 401 for a lexicographically-sorted intersection, i.e. it drops 6 real tags today: 22.8.16.32, 22.8.17.17, 22.8.18.31, 22.8.19.10, 22.8.20.11, 22.8.21.38. All are on the 22.8 line, so none touch the three supported majors (25.8/25.3/24.9) and the current enum is unaffected. It bites only if a dropped tag is ever the tail -n1 of a supported major. Still worth the one-line fix (feed comm a plain sort -u), since a silent tag-dropping bug in the tag-selection tool is exactly the kind that surfaces later.

Verdict unchanged; both still warrant a fix to the generator.

@scooby87

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, IvanHunters — all four blocking items and the robustness notes are addressed in 25f408d. TDD: the generator's behaviour is now pinned by hack/clickhouse-update-versions_test.bats (7 cases, green under both real bats and hack/cozytest.sh), each guarding one of the failures below.

Blocking 1 — comm fed version-sorted input. fetch_tags now emits a byte-collated LC_ALL=C sort -u, which is the order comm walks, so the intersection no longer drops tags at the X.9 → X.10 boundary. The per-major latest-patch pick uses a numeric field sort instead of sort -V. Covered by the "intersection keeps tags across the X.9 → X.10 boundary" test.

Blocking 2 — committed files/versions.yaml not reproducible. The default line is now patch-pinned (pin_for v24.9 → 24.9.2.42): the generator emits the pinned patch for the default major and the latest common patch for the others. A live make update against Docker Hub now reproduces the committed files/versions.yaml verbatim (v25.8 → 25.8.28.1, v25.3 → 25.3.14.14, v24.9 → 24.9.2.42), so the "renders byte-for-byte identically" guarantee holds across regenerations. The helm-unittest default assertion keeps the exact 24.9.2.42; the upgrade lines now assert only the major.minor so a future patch bump on 25.3/25.8 does not turn the test red. Covered by the "pinned default is reproduced, not bumped" test.

Blocking 3 — non-atomic regeneration. Both versions.yaml and the values.yaml block are built into temp files and mvd into place only after everything succeeds; a configured major that cannot be resolved exits before any write. Covered by the "on error the committed files are left untouched (atomic)" test.

Blocking 4 — does not run on stock macOS. Dropped the bash-4 associative array (parallel indexed arrays + a pin_for function) and the BSD-incompatible constructs (awk -v with embedded newlines is replaced by a pure-bash splice; sort -V by a numeric field sort). Verified on the local bash 3.2.57.

Non-blocking. Downgrade hazard: added an explicit "downgrading is unsafe — only increase this value" sentence to the version parameter description (regenerated into schema/README/rd). EOL default: kept v24.9 deliberately so existing installs are untouched — agreed it is a non-LTS default for fresh installs, worth a follow-up to move the default to an LTS once a migration story exists. _versions.tpl fail: left as harmless defense-in-depth behind the schema enum. Test brittleness: the unsupported-version assertion now matches either the schema error or the versionMap fail, so it is not tied to Helm's exact phrasing. Digest pinning / cozy-lib.image mirror routing: pre-existing for this chart and out of scope here — happy to open a separate issue to route both images through the mirror-aware helper.

@scooby87
scooby87 requested a review from IvanHunters July 28, 2026 20:01

@IvanHunters IvanHunters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with non-blocking notes.

Clean, well-tested feature that faithfully mirrors the established managed-DB
version-selection pattern (postgres/mariadb/redis/mongodb/opensearch/rabbitmq).
Verified by hand, not just by reading:

Verified

  • Upgrade of existing installations is byte-for-byte safe: a CR with no
    spec.version renders 24.9.2.42 via the chart default, and an explicit
    empty value is fail-closed by the schema enum.
  • All generated artifacts are consistent and up to date: values.yaml,
    values.schema.json, types.go, the clickhouse-rd openAPISchema and
    README.md all carry the same v25.8/v25.3/v24.9 enum with default v24.9;
    re-running cozyvalues-gen produces an empty diff.
  • Tests pass: helm-unittest 5/5 and the bats generator suite 7/7 (including the
    byte-collation invariant across the X.9 -> X.10 boundary and the pinned-default
    reproduction).

Non-blocking notes (all scoped to the maintainer-run hack/update-versions.sh,
whose output is always reviewed via git diff; none affect what this PR ships):

  1. update-versions.sh (default fallback): if the current default's major is
    removed from CH_SUPPORTED_MAJORS, DEFAULT_VERSION="${MAJORS[0]}" silently
    promotes the newest major as the new default. Losing the current default would
    be safer as a hard error than a silent fallback.
  2. pin_for is keyed to a hardcoded v24.9 rather than to "whichever major is
    the default", so if the default ever moves it becomes unpinned and subsequent
    regenerations can patch-bump its image.
  3. The values.yaml splice loop only clears in_section on a version: line, so
    a malformed input (enum header present, version: line absent) would swallow
    everything to EOF. Cannot happen with the well-formed committed file; worth a
    bounded terminator for robustness.

Not raised as a blocker: there is no CEL transition guard preventing a version
downgrade (the field doc says "only increase"), but this matches every sibling
DB chart, so it belongs to a family-wide change rather than this PR.

The note about terraform-provider-cozystack needing a matching version
attribute is correct and reasonably left as a maintainer decision.

@scooby87

scooby87 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks IvanHunters — the three update-versions.sh robustness notes are addressed in 274ae9f, each with a new bats case. The shipped chart is unchanged: a live make update still reproduces files/versions.yaml and values.yaml byte-for-byte.

  1. Silent default promotion → hard error. If the current default's major is not in CH_SUPPORTED_MAJORS, the generator now exits with an error instead of falling back to MAJORS[0], so the default cannot change silently. Covered by "dropping the current default's major from the supported set is a hard error".

  2. Pin follows the default. Dropped the hardcoded pin_for v24.9. The default major is now frozen to the exact tag it already ships, read from the committed versions.yaml, so whichever major is the default is the one that is frozen — moving the default cannot leave it unpinned. Covered by "the freeze follows the default major, not a hardcoded one".

  3. Bounded splice. The version section now ends at the version: line or at the first line that is not a recognised section member (## @value / ## @param / blank), so a malformed input with the enum header but no version: line no longer swallows the rest of the file. Covered by "a malformed version section does not swallow the rest of the file".

The unrelated E2E failure on the previous run was a control-plane flake (cluster-wide leader-election timeouts, "Wait for Cluster-API provider deployments"; ClickHouse itself reconciled) — I re-ran it. If the current state looks good, a formal Approve would clear the earlier change-request and unblock the merge.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
hack/clickhouse-update-versions_test.bats (1)

136-147: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Exercise the unresolved-major failure path.

Line 144 omits the current default v24.9. The generator exits during default validation before it resolves 26.99. Keep 24.9 in CH_SUPPORTED_MAJORS so this test verifies that unresolved-version failure preserves both committed files.

Proposed test fix
-  if CH_SUPPORTED_MAJORS="26.99" bash "$GEN" >/dev/null 2>&1; then echo "expected non-zero exit" >&2; exit 1; fi
+  if CH_SUPPORTED_MAJORS="26.99 24.9" bash "$GEN" >/dev/null 2>&1; then echo "expected non-zero exit" >&2; exit 1; fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hack/clickhouse-update-versions_test.bats` around lines 136 - 147, Update the
atomic failure test around the generator invocation so CH_SUPPORTED_MAJORS
retains the current default major 24.9 while also including unresolved major
26.99. Preserve the existing assertions that both versions.yaml and values.yaml
remain unchanged after the generator exits non-zero.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@hack/clickhouse-update-versions_test.bats`:
- Around line 136-147: Update the atomic failure test around the generator
invocation so CH_SUPPORTED_MAJORS retains the current default major 24.9 while
also including unresolved major 26.99. Preserve the existing assertions that
both versions.yaml and values.yaml remain unchanged after the generator exits
non-zero.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7d4ef2ad-f665-4403-8eae-b8b82732df3b

📥 Commits

Reviewing files that changed from the base of the PR and between 69cce57 and 274ae9f.

📒 Files selected for processing (2)
  • hack/clickhouse-update-versions_test.bats
  • packages/apps/clickhouse/hack/update-versions.sh

Add a `version` value (v25.8, v25.3, v24.9; default v24.9) to the
ClickHouse chart, backed by files/versions.yaml and resolved by
templates/_versions.tpl for both the ClickHouse server and Keeper
images, so the Cozystack API returns the engine version (spec.version)
like the other managed-DB charts. Default v24.9 -> 24.9.2.42 keeps
existing installations byte-for-byte identical.

The maintainer-run hack/update-versions.sh generator intersects the
server/keeper Docker Hub tags byte-collated (LC_ALL=C) so comm keeps
tags across the X.9 -> X.10 boundary; freezes the default major to the
tag it already ships (read from versions.yaml, so the freeze follows the
default); errors on a dropped default or an unresolvable major; writes
atomically; and runs on stock macOS bash 3.2 / BSD. Covered by
hack/clickhouse-update-versions_test.bats (10 cases) and the
tests/version_test.yaml helm-unittest suite.

Refs: #1246
Signed-off-by: Alexey Artamonov <[email protected]>
@scooby87
scooby87 force-pushed the feat/clickhouse-version-param branch from 274ae9f to 3c78c0b Compare August 24, 2026 20:42
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

IvanHunters
IvanHunters previously approved these changes Aug 25, 2026

@IvanHunters IvanHunters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This closes the ClickHouse half of the #1246 gap: a selectable version (v25.8 / v25.3 / v24.9, default v24.9) exposed through the API like the other managed databases. Scope is tight, the version generator is atomic and correct on collation, the upgrade path is byte-identical, and the tests are thorough and pass.

Verified without a cluster:

  • No regression: the default v24.9 → 24.9.2.42 matches the previous hardcoded tag byte-for-byte, so existing instances do not silently upgrade. No hardcoded ClickHouse tags remain; both server and keeper images resolve through versionMap.
  • Tests run and are green: 10/10 bats for the version generator (hack/clickhouse-update-versions_test.bats, auto-picked up via wildcard hack/*.bats) and 5/5 helm-unittest, including schema rejection of v1.0.
  • The implementation mirrors the established sibling pattern (mariadb), with higher coverage since it is the only DB chart with a generator bats test.

Non-blocking notes for the maintainer:

  • [MINOR] The version default is the oldest enum member (v24.9), whereas every other managed-DB chart defaults to its own newest major (mariadb v11.8, mongodb v8, redis v8, postgres v18, opensearch v2). Fresh instances come up on a ~year-old release unless the user picks v25.8. If this is a deliberate upgrade-safety choice, worth confirming for fresh installs specifically.
  • [MINOR] No downgrade guard on version, even though the field docstring says downgrading is unsafe. This matches every sibling DB chart (none guard version), so it is a pre-existing platform stance rather than a regression here.
  • [NIT] The downstream terraform-provider-cozystack is not updated; the PR already flags this.

@myasnikovdaniil myasnikovdaniil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two blockers, both in hack/update-versions.sh, inline.

Generator cannot see the tags it needs, and when it half sees them it silently moves the default image. Fix for both is small: fetch with skopeo list-tags like the postgres, redis, mongodb, opensearch and kubernetes generators already do (skopeo is already required in root build-deps), and make a missing frozen tag a hard error instead of a fallback.

Chart part itself is fine and I checked it: default render is byte identical to main, v25.3 and v25.8 move both server and keeper images together, schema rejects an unknown value, bats suite passes under hack/cozytest.sh, helm-unittest is 23/23 and it does catch a broken map (mutated _versions.tpl to confirm).

Not blocking:

  • .helmignore has no /hack, so update-versions.sh ships inside the chart tarball. postgres, mariadb and redis all exclude it.
  • default line freezes its patch and not only its major, so default installs never get patch fixes for their own line, every other chart maps major to latest patch. v24.9 is not lts either, its last patch is 2024-11-19 and the map pins it two patches back.
  • successful run leaves files/versions.yaml and values.yaml at mode 600, mktemp mode survives the mv.
  • nothing boots 25.3 or 25.8. helm-unittest checks rendered tags only and the chainsaw fixture has no version. No other database chart does this either so not asking for it here.
  • unrelated to this PR: templates/clickhouse.yaml:99 shadows $clusterDomain with .Values.clusterDomain which the chart does not define, so keeper hosts render as chk-...-0.<ns>.svc. with an empty domain. Separate issue.

Comment thread packages/apps/clickhouse/hack/update-versions.sh Outdated
Comment thread packages/apps/clickhouse/hack/update-versions.sh Outdated
Comment thread hack/clickhouse-update-versions_test.bats Outdated
Address review of the version generator (hack/update-versions.sh):

- Fetch tags with `skopeo list-tags` (registry v2 /tags/list) instead of
  the Docker Hub v2 API, whose anonymous pagination caps at 1000 entries
  and then returns an error page with no `.results`, silently truncating
  the list so the frozen 24.9.2.42 fell outside the window and the run
  failed. skopeo is already in build-deps and is how the sibling
  generators (postgres, redis, mongodb, opensearch, kubernetes) fetch.
- Make a frozen default tag missing from the registry a hard error
  instead of silently falling back to a newer patch, which would move
  the default image for existing installs.
- Restore 0644 on the regenerated files (mktemp's 0600 survived the mv).
- Exclude /hack from the chart tarball via .helmignore.
- Refresh files/versions.yaml: v25.8 -> 25.8.32.4, the true latest 25.8
  patch now visible with the complete tag list.
- bats: add a missing-frozen-tag hard-error case and make the atomicity
  test reach the resolution phase after a valid default rather than
  failing at the default-in-set check.

Signed-off-by: Alexey Artamonov <[email protected]>
@scooby87

Copy link
Copy Markdown
Contributor Author

Thanks myasnikovdaniil — both blockers are fixed in e707475 and the three threads are resolved. I installed skopeo 1.24.0 and verified end-to-end: the generator now reads the complete tag list, freezes v24.9 to 24.9.2.42, and make update reproduces the map (v25.8 legitimately advances to 25.8.32.4, the true latest 25.8 patch that the truncated Docker Hub pagination had hidden).

On the non-blocking notes:

  • .helmignore — added /hack, so update-versions.sh no longer ships inside the chart tarball. Done.
  • Mode 0600 — the script now chmod 0644s the two outputs after the mv, so a run no longer leaves them at mktemp's 0600. Done.
  • Freeze pins the patch, not just the major — this is deliberate and was requested in the earlier review round: the default must render byte-for-byte identical to the pre-PR hardcoded 24.9.2.42 so existing installs are not moved on upgrade. It only pins the default line; every other major still maps to its latest patch. I agree it diverges from the other charts (which move the default to latest patch), and I'm happy to switch to the sibling convention if you'd prefer that consistency over the no-op-upgrade guarantee — your call as the area owner.
  • templates/clickhouse.yaml:99 .Values.clusterDomain shadow — confirmed pre-existing (it came in with the Keeper zookeeper-nodes block on main, not this PR) and out of scope here; I'll open a separate issue for the empty-domain Keeper FQDN.

Re-requesting your review.

@github-actions github-actions Bot added size/XL This PR changes 500-999 lines, ignoring generated files and removed size/L This PR changes 100-499 lines, ignoring generated files labels Aug 25, 2026

@myasnikovdaniil myasnikovdaniil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both blockers fixed, verified on e707475.

Ran the generator live against the registry: v25.8 to 25.8.32.4, v25.3 to 25.3.14.14, v24.9 to 24.9.2.42, exit 0, and regeneration leaves zero diff against the committed tree, so the map is exactly what the generator produces now. That was not checkable before because the generator could not complete at all. Missing frozen tag is a hard error with nothing written (checked with committed map at 24.9.2.42 and a tag list holding only 24.9.3.128). Modes stay 644, hack/ is out of the chart tarball, bats 11/11 under hack/cozytest.sh, helm-unittest 23/23, default render still byte identical to main, v25.3 and v25.8 both move server and keeper together.

On the freeze question, keep it. The danger was never the freeze itself, it was that the freeze could move the default silently, and that is gone now. Sibling charts move the default major to newest on every regeneration with no signal at all, which is worse than what you have here. The real problem is a different one: v24.9 is not lts and its last patch is 2024-11-19, so the default ships an abandoned line. That is a question about which version cozystack ships, and it wants its own PR with an upgrade note rather than a change to the generator.

Two things I am not asking for here:

  • files/versions.yaml is invisible to hack/lib/image-refs.sh, image_ref_files walks only packages/*/*/values.yaml and images/*.tag. Same for all seven charts that carry a version map, so it is one glob elsewhere and not yours.
  • nothing boots 25.3 or 25.8 anywhere, helm-unittest checks rendered tags only. No database chart in the tree does this, so it is separate work.

Unit and e2e checks are still running on this head. I ran locally what the unit job runs and both suites pass, and this commit does not touch anything e2e exercises.

@scooby87
scooby87 merged commit 9dd2841 into main Aug 26, 2026
46 of 48 checks passed
@scooby87
scooby87 deleted the feat/clickhouse-version-param branch August 26, 2026 14:45
@IvanHunters IvanHunters added the kind/backport Categorizes issue or PR as requiring a backport to the current release line label Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Created backport PR for release-1.6:

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin backport-3476-to-release-1.6
git worktree add --checkout .worktree/backport-3476-to-release-1.6 backport-3476-to-release-1.6
cd .worktree/backport-3476-to-release-1.6
git reset --hard HEAD^
git cherry-pick -x 3c78c0be569cd4e5a4d53f74c6d64f96494349b8 e707475f960831d47883c354d8386fa0db835bbb
git push --force-with-lease

myasnikovdaniil added a commit that referenced this pull request Sep 3, 2026
…ameter (#4054)

# Description
Backport of #3476 to `release-1.6`.
Andrei Kvapil (kvaps) pushed a commit that referenced this pull request Sep 7, 2026
## What this PR does

The ClickHouse server and Keeper images were hardcoded to `24.9.2.42` in
the chart templates, so the chart exposed no top-level `version` values
key. The Cozystack API returns a managed database's engine version by
passing the HelmRelease's `spec.values.version` straight through into
the Application object, so ClickHouse instances carried no
`spec.version` in the API — unlike postgres, mariadb, mongodb,
opensearch, rabbitmq and redis, which all ship a `version` parameter.
This closes the ClickHouse half of the gap tracked in #1246.

This adds the same version-selection scaffolding the other
managed-database charts already use:

- `files/versions.yaml` maps a `major.minor` key to the full image tag,
shared by the ClickHouse server and Keeper images (both are pinned to
one version).
- `templates/_versions.tpl` (`clickhouse.versionMap`) resolves the tag
and fails the render on an unsupported version.
- `values.yaml` gains a `version` enum (`v25.8`, `v25.3`, `v24.9`),
consumed by `templates/clickhouse.yaml` and `templates/chkeeper.yaml`.
- `hack/update-versions.sh` + `make update` refresh the map from Docker
Hub, keeping only tags published for *both* the server and Keeper images
and preserving the current default so a regeneration never bumps the
major of existing deployments.

The default stays `v24.9` → `24.9.2.42`, so existing installations
render byte-for-byte identically and are never upgraded to a new major
implicitly. The generated `values.schema.json`, `README.md`, the Go API
type and the `clickhouse-rd` `openAPISchema` are regenerated with
`cozyvalues-gen` v1.6.0. A new `tests/version_test.yaml` helm-unittest
suite covers the server/Keeper mapping for each version and the
schema-level rejection of an unsupported value.

### Downstream repositories

The diff changes `packages/apps/clickhouse/values.schema.json` by adding
a new `version` field with an `enum`. Per the trigger map, this reaches
`terraform-provider-cozystack`, whose ClickHouse resource is
hand-written and would need a matching `version` attribute with a
`stringvalidator.OneOf` list and its expand/flatten pair. There is no
existing PR or issue there for it yet. This is left for a maintainer
decision rather than a speculative cross-repo PR, so the box below is
intentionally left unticked and flagged here. No other downstream
repository is reached (the website reference page is regenerated from
`README.md` by the release docs bot; ClickHouse is already in its app
list).

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: needs a `version` attribute on the ClickHouse resource
(maintainer decision — see note above)
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:

### Release note

```release-note
feat(clickhouse): add a configurable `version` parameter (v25.8, v25.3, v24.9; default v24.9) so the deployed ClickHouse version is selectable and returned through the API. Existing installations are unchanged.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a configurable ClickHouse version setting for both server and
Keeper images, defaulting to `v24.9`.
* Supported versions are `v25.8`, `v25.3`, and `v24.9`, with compatible
image patches selected automatically.
* **Documentation**
  * Documented the version setting, default, and supported values.
* **Validation**
* Unsupported versions are rejected with an error listing allowed
options.
* **Tests**
* Added coverage for version mapping, defaults, invalid values, and
update behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/database Issues or PRs related to managed databases (postgres, mariadb, redis, etcd, kafka, clickhouse) kind/backport Categorizes issue or PR as requiring a backport to the current release line kind/feature Categorizes issue or PR as related to a new feature size/XL This PR changes 500-999 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants