8000 Reload user passwords from a Secret without restarting ClickHouse by alex-zaitsev · Pull Request #2100 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

Skip to content

Reload user passwords from a Secret without restarting ClickHouse - #2100

Merged
alex-zaitsev merged 14 commits into
0.28.0from
hot-reload-user-passwords
Nov 3, 2026
Merged

alex-zaitsev merged 14 commits into
0.28.0from
hot-reload-user-passwords

Conversation

@alex-zaitsev
@alex-zaitsev alex-zaitsev commented Oct 9, 2026 •
Copy link
Copy Markdown
Member

Summary

  • Add valueFrom.hotReload: true for ClickHouse user password, password_sha256_hex, and password_double_sha1_hex fields to support password rotation from Kubernetes Secrets without restarting Pods.
  • Publish hot-reload users in chop-generated-hot-reload-users.xml inside the CHI-owned Secret chi-<chi>-users. Other users remain in the existing users ConfigMap. Both files are projected into users.d without subPath, allowing ClickHouse to reload updated credentials.
  • Watch referenced source Secrets and reconcile the generated Secret when their values change. Update it only when its contents differ; missing or invalid credentials abort reconciliation and preserve the last valid configuration.
  • Preserve existing from_env behavior when hotReload is omitted. Enabling hot reload requires a one-time Pod rollout; subsequent password rotations do not.
  • Reject hotReload on unsupported fields, including settings, profiles, quotas, files, and Keeper configuration. Automatic Secret-change detection supports references declared directly in the CHI; template-inherited references require manual reconciliation.

Resolves #2092.

Test plan

  • Go unit tests: credential rendering, hash validation, missing Secrets, default-user handling, Secret-change detection, reconciliation, cleanup, and restart behavior.
  • E2E test_010011_6: verify password rotation on both replicas, rejection of previous passwords, unchanged passwords for users without hotReload, and no Pod restarts.
  • CI checks pass.

@alex-zaitsev
alex-zaitsev marked this pull request as ready for review October 12, 2026 09:21
@alex-zaitsev alex-zaitsev added the planned for review This feature is planned for review label Oct 12, 2026
alex-zaitsev and others added 8 commits October 15, 2026 16:40
valueFrom.hotReload publishes those users in a CHI-owned Secret mounted beside chop-generated-users.xml, so a later password change is picked up from users.d instead of a Pod recreate.

Co-authored-by: Cursor <cursoragent@cursor.com>
The plan is stored on chi-storage-{chi} and is gone once the namespace is deleted.

Co-authored-by: Cursor <cursoragent@cursor.com>
Conflict resolutions:
- pkg/interfaces/interfaces-main.go, pkg/model/common/creator/secret.go: kept both
  CreateHotReloadUsersSecret (this PR) and CreateBackupSecret (0.28.0).
- pkg/controller/chi/worker-secret.go: took 0.28.0's backup Secret reconcile
  (prepare/ensure/reconcileSecretKeepValues) and appended this PR's hot-reload
  users Secret functions; merged imports.
- pkg/controller/chi/worker-secret_test.go (add/add): kept both test sets; aliased
  k8s types import as k8stypes to avoid clashing with pkg/apis/common/types.
- pkg/controller/chi/worker-reconcile-gate{,_test}.go, worker-reconciler-chi.go: kept
  both gatePasswordSecretChanged and gateBackupSecretChanged (decision, input,
  switch case, test table).
- pkg/controller/chi/worker.go: shouldForceRestartHost keeps 0.28.0's
  RollingUpdate / configurationChangeRequiresReboot (reloadability cache) ahead of
  recovery cases; the password-only shortcut is a guarded case placed first and is
  skipped for hosts needing recovery (crashed or stuck NotReady), preserving the
  PR's "recovery beats password shortcut" rule. Extracted the recovery predicates
  into helpers. Kept both passwordOnlyRefresh and the reloadability cache types.
- deploy/operator/*-v1beta1.yaml: took 0.28.0 and re-applied only this PR's CRD
  description change (build_manifests.sh is not usable here).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Slach Slach 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 of the hot-reload passwords PR: three issues worth addressing before merge (see inline comments): the ClickHouse container lookup for the projected volume, an auth gap for users during the hotReload on/off transition, and the memory footprint of the unfiltered cluster-wide Secret informer.

🤖 Generated with Claude Code

Comment thread pkg/model/chi/volume/volume.go Resolved
Comment thread pkg/model/chi/config/generator.go Resolved
Comment thread cmd/operator/app/thread_chi.go Resolved
@alex-zaitsev
alex-zaitsev requested a review from Slach November 3, 2026 11:53
@Slach
Slach commented Nov 3, 2026
Copy link
Copy Markdown
Collaborator

LGTM. The container lookup fix and the metadata-only Secret informer look good; unit tests pass locally.

@alex-zaitsev
alex-zaitsev merged commit bd9e0a7 into 0.28.0 Nov 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

planned for review This feature is planned for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Regression / Discussion] Loss of hot-reloaded password rotation after removal of k8s_secret_* in 0.27.4

2 participants

0