Repository navigation
Conversation
Collaborator
Author
|
@alex-zaitsev latest changes (2aa659a, 9cf5e21):
|
Slach
force-pushed
the
backup-config-file
branch
from
November 5, 2026 19:30
9cf5e21 to
a6379b9
Compare
…rage settings from backup.configSecretRef - backup.configSecretRef names a Secret whose key config.yml holds the clickhouse-backup configuration of a cluster (replaces backup.storages[]/backup.storage). The operator builds <chi>-<cluster>-backup-config from it and the credentials of <chi>-auto-backup-secret, mounts it into the sidecar, and keeps it in step with a reconcile and a sync once a minute, with a deadline per installation. No more env vars from the storage Secret and no liveness restarts. A storage Secret gone or emptied keeps the storage settings the sidecars have. - <chi>-auto-backup-secret holds only the generated REST API credentials. CLICKHOUSE_USERNAME and CLICKHOUSE_PASSWORD are set by the user or not at all: without them the sidecar configuration has no ClickHouse credentials and clickhouse-backup uses its own defaults. With both set, the operator creates that backup user, reachable from the pod's loopback only; with only one set, it warns with BackupCredentialsIncomplete. - The sidecar restarts its server on new REST API credentials (api-credentials.sha256 next to config.yml). - A change of CLICKHOUSE_USERNAME or CLICKHOUSE_PASSWORD reconciles the CHI, which writes the users configuration before the sidecar configuration; the sync takes new backup user credentials only once the users configuration has them. - Jobs and CronJobs carry the clickhouse.altinity.com/backup-config-secret annotation; backups, restores and schedules report status.clusters[].configSecret. - Events BackupStorageSecretMissing and BackupStorageConfigInvalid, once per change of state in the sync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Slach
force-pushed
the
backup-config-file
branch
from
November 6, 2026 05:13
a6379b9 to
2e5729b
Compare
…ile of its own Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Summary
Replaces the way the operator-managed
clickhouse-backupsidecar gets its settings.Before: the storage Secret's keys came in as env vars through
envFrom, and the credentials assecretKeyRefenv vars. Kubelet reads env vars only when it starts a container, so a liveness probe compared the mounted Secret files with the sidecar's start-up environment and failed, so that the sidecar got restarted, whenever they differed.After:
backup.storages[].secretRef) holds a keyconfig.yml: a YAML fragment of the clickhouse-backup configuration (general:,s3:,gcs:, …).<chi>-<cluster>-backup-configfrom it (pkg/model/chi/backupconfig). The Secret is owned by the CHI and holds:<chi>-auto-backup-secret;path/object_disk_pathfor every storage type;general.disable_environment_override: false;/etc/clickhouse-backupas a whole directory, not viasubPath.clickhouse-backup serverre-readsconfig.ymlfor every API operation (APIServer.ReloadConfig), so a change applies without a restart.API_LISTEN,API_SECURE,API_ALLOW_PARALLEL,RESTORE_SCHEMA_ON_CLUSTER,RESTORE_*_MAPPING,CLICKHOUSE_RESTART_COMMAND) and the per-host ClickHouse port/TLS stay env vars, which take precedence over the file.API_USERNAME,API_PASSWORD,CLICKHOUSE_USERNAME,CLICKHOUSE_PASSWORDandCLICKHOUSE_BACKUP_CONFIG;/etc/clickhouse-backup.backup-sidecar-liveness.sh, theenvFromof the storage Secret, the Secret mounts under/var/run/secrets/clickhouse-backup, and the default-path logic inbackup-sidecar.sh.BackupStorageConfigInvalid.BackupStorageSecretMissingnow also fires when the Secret has noconfig.ymlkey.REMOTE_STORAGE,S3_BUCKET, …) are no longer read and must be converted toconfig.yml. Docs, examples and e2e manifests are updated.How the problems of the previous mechanism are addressed
S3_STORAGE_CLASSstayed in the sidecar's environment until something else restarted it. Now the config file is rebuilt from the whole Secret, and clickhouse-backup reloads it for every operation, so a removed key is gone from the next operation on.livenessProbedisabled the mechanism entirely. With such a probe, Secret changes never reached the sidecar until the pod restarted. Applying a change no longer needs a probe or a restart, so a user-defined probe is irrelevant here.busy()only saw the local sidecar's operations, so a sidecar on host B could be restarted while a Job was still working on host A and hit B mid-run. A restore is never resumed. Nothing restarts the sidecar any more: a running operation keeps the config it loaded, and the next operation picks up the new one.Unhealthy/ liveness-probe-failed events and bumpedrestartCount, which triggers container-restart alerts during routine credential rotation. Now there are no probe failures or restarts, only a Secret update./proc/<pid>/environor in the container env. They live only in the mounted file, read-only, inside the sidecar container.REST API credentials: clickhouse-backup checks them against the config it has loaded, and only an authenticated operation reloads it, so a change of the credentials in
<chi>-auto-backup-secret, edited in place or recreated, would otherwise get every Job a401. The generated Secret also holdsapi-credentials.sha256, the SHA-256 of the REST API username and password, mounted next toconfig.yml. The sidecar script now supervisesclickhouse-backup serverinstead of exec-ing it and sends itSIGHUPwhen the fingerprint changes. That restarts the server process, not the container, and cancels the operations in progress, which Jobs started with the old credentials could not follow anyway. Storage and ClickHouse settings are still reloaded per operation without a restart. e2etest_010087changes the password in place and checks that every sidecar accepts the new one and refuses the old one without a container restart.Sync warnings: the once-a-minute sync emits
BackupStorageSecretMissingandBackupStorageConfigInvalidlike the reconcile does, once per change of state rather than on every pass.Testing
pkg/model/chi/backupconfig: merge, defaults, determinism, invalid input;pkg/controller/chi: create, update only on change, invalid input leaves the Secret alone, registry, periodic sync and its skip conditions.go test ./pkg/... ./cmd/...passes ingolang:1.27.2(Linux). The script tests need/procand GNUdate, and are skipped or fail on macOS, as before.test_010087was updated for the new Secret format: it asserts the config volume, the generated Secret and the absence of credential env vars, and waits for the regenerated config before the shared-path backup.test_010087(11m) andtest_010088(6m) pass on a local OrbStack Kubernetes against the operator image built from this branch. The full e2e suite passed in CI (run 40454429451, 3h 16m); test_010009, test_010011_5, test_010036, test_010086_1 and test_090099 needed a retry.🤖 Generated with Claude Code