Skip to content

fix(clickhouse): keep the Keeper name inside the StatefulSet volume-name limit - #4133

Merged
Aleksei Sviridkin (lexfrei) merged 1 commit into
cozystack:mainfrom
yankawai:fix/clickhouse-keeper-name
Sep 17, 2026
Merged

Aleksei Sviridkin (lexfrei) merged 1 commit into
cozystack:mainfrom
yankawai:fix/clickhouse-keeper-name

Conversation

@yankawai

@yankawai europrinter (yankawai) commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Fixes #4083.

clickhouse-operator names the Keeper config volume chk-<chk>-deploy-confd-<cluster>-<shard>-<replica>. With the CHK called <release>-keeper and Release.Name already prefixed with clickhouse-, an application name longer than 15 characters pushes that volume name past 63 characters. The StatefulSet is rejected on every reconcile, no Keeper pod appears, and the CHK still reports Completed; the only visible signal is the Keeper WorkloadMonitor staying at operational: false.

templates/_keeper.tpl now computes the CHK name: <release>-keeper as before when it fits, otherwise the release name is truncated and a six-character hash of the release name is appended so two long names cannot collide. The budget accounts for the width of the replica index. chkeeper.yaml and the zookeeper nodes list in clickhouse.yaml both use the helper, so the hosts ClickHouse connects to always match the CHK the operator creates. The pod label, the VMPodScrape selector and the WorkloadMonitor stay on <release>-keeper.

Names up to 15 characters render byte-for-byte as before. A release with a longer name never had a Keeper pod; on upgrade its pod-less CHK is replaced by the shortened one and the Keeper comes up.

helm unittest: 30/30 in the chart, including the new tests/keeper_name_test.yaml (short name unchanged, the exact 63-character boundary, one character past it, a very long name, a two-digit replica index, no trailing dash after truncation).

Downstream repositories

Templates and tests only: no values, schema, README, defaults, ApplicationDefinition or tenant-facing Secret/Service names change.

Release note

fix(clickhouse): shorten the Keeper name for application names longer than 15 characters so the Keeper StatefulSet can be created

Summary by CodeRabbit

  • Bug Fixes

    • Fixed ClickHouse Keeper resource naming for long release names so generated names remain within Kubernetes’ 63-character limit.
    • Updated ClickHouse Keeper hostnames to consistently match the generated resource name, including when names are shortened.
    • Preserved identifying labels and monitoring selectors while applying the corrected Keeper naming behavior.
  • Tests

    • Added coverage for standard, boundary-length, and truncated Keeper names, including replica-specific naming scenarios.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: d3e80408-2fa6-458f-ac3c-d36989c77780

📥 Commits

Reviewing files that changed from the base of the PR and between cd675e1 and 03a7af7.

📒 Files selected for processing (4)
  • packages/apps/clickhouse/templates/_keeper.tpl
  • packages/apps/clickhouse/templates/chkeeper.yaml
  • packages/apps/clickhouse/templates/clickhouse.yaml
  • packages/apps/clickhouse/tests/keeper_name_test.yaml

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


📝 Walkthrough

Walkthrough

The ClickHouse chart now generates a bounded Keeper name. Keeper metadata and ClickHouse zookeeper hostnames use this name. Helm tests cover length boundaries, truncation, replica counts, hostname alignment, and selector behavior.

Changes

ClickHouse Keeper naming

Layer / File(s) Summary
Keeper name helper
packages/apps/clickhouse/templates/_keeper.tpl
Adds clickhouse.keeperName, which preserves valid names and truncates oversized names with a six-character hash suffix.
Template name wiring
packages/apps/clickhouse/templates/chkeeper.yaml, packages/apps/clickhouse/templates/clickhouse.yaml
Uses the helper for Keeper metadata and ClickHouse zookeeper hostnames.
Name budget validation
packages/apps/clickhouse/tests/keeper_name_test.yaml
Tests boundary lengths, truncation, dash trimming, replica counts, hostname alignment, and selector values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 03a7a

The chart now creates Keeper resources for longer application names while preserving existing names for short releases and keeping ClickHouse endpoints aligned. No current merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant HelmRelease
  participant clickhouse.keeperName
  participant ClickHouseKeeperInstallation
  participant ClickHouseInstallation
  HelmRelease->>clickhouse.keeperName: provide release name and replica count
  clickhouse.keeperName->>ClickHouseKeeperInstallation: render bounded metadata.name
  clickhouse.keeperName->>ClickHouseInstallation: render bounded zookeeper hostname
  ClickHouseKeeperInstallation->>ClickHouseInstallation: use matching Keeper name
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: keeping the generated ClickHouse Keeper name within the StatefulSet volume-name limit.
Linked Issues check ✅ Passed The changes address issue [#4083] by shortening the Keeper name only when the generated volume name can exceed 63 characters, adding a collision-resistant hash suffix, accounting for replica index wid…
Out of Scope Changes check ✅ Passed All code and test changes support the linked issue [#4083]. The helper, resource references, hostname references, and boundary tests are directly related to preventing invalid Keeper StatefulSets.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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/bug Categorizes issue or PR as related to a bug labels Sep 7, 2026
…ame limit

clickhouse-operator derives the Keeper config volume name as
chk-<chk>-deploy-confd-<cluster>-<shard>-<replica>. The CHK is named
<release>-keeper and Release.Name already carries the clickhouse- prefix,
so an application name longer than 15 characters pushes that volume name
past 63 characters: the StatefulSet is rejected, no Keeper pod appears,
and the CHK still reports Completed.

The CHK name is now shortened only when it would overflow, with a short
hash of the release name so two long names stay distinct, and the
ClickHouse zookeeper hosts are built from the same helper. Short names
render exactly as before.

Signed-off-by: Yan Bondarenko <[email protected]>

@scooby87 scooby87 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.

LGTM (independent cozy-review pass).

The truncation threshold is exactly the previous failure condition, so no healthy install (name <= 63) is renamed — short release names keep <release>-keeper unchanged and only already-broken names (> 63) are truncated, which makes the upgrade safe for existing keeper PVCs. The truncated name targets exactly 63 chars and the boundary case is tested. Cross-file consistency is right: object names use the truncated $keeper, while pod-label app and its selectors stay on the full name and remain internally consistent.

Verified: helm unittest 7/7; mutating the threshold turns 4 tests RED (non-vacuous); the sha256 hashes in the tests check out.

Non-blocking: in the truncation branch the name depends on the digit count of replicas, so scaling keeper across a power-of-ten boundary (9->10) recomputes the budget and renames the CHK; narrow trigger, worth a comment.

@lexfrei
Aleksei Sviridkin (lexfrei) merged commit bd38922 into cozystack:main Sep 17, 2026
15 checks passed
@lexfrei Aleksei Sviridkin (lexfrei) added the kind/backport Categorizes issue or PR as requiring a backport to the current release line label Sep 18, 2026
@github-actions

Copy link
Copy Markdown

myasnikovdaniil added a commit that referenced this pull request Sep 23, 2026
…he StatefulSet volume-name limit (#4314)

# Description
Backport of #4133 to `release-1.6`.
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/bug Categorizes issue or PR as related to a bug size/L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clickhouse: Keeper is never created when the application name is longer than 15 characters

3 participants