Repository navigation
Conversation
…ad of env vars + liveness restarts The storage Secret now holds a config.yml YAML fragment. The operator merges it with the credentials and default paths into a per-cluster Secret <chi>-<cluster>-backup-config, mounted at /etc/clickhouse-backup; clickhouse-backup re-reads it for every operation, so storage changes apply without restarting the sidecar. The env-from-Secret wiring and the liveness probe that restarted the sidecar on Secret changes are removed. A periodic sync (1 min) keeps the config Secrets in step with the storage Secrets between reconciles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
….yml is too long for the shell Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ub does not have realpath of a missing tmp/ is empty on macOS, so the configs were rendered into /<timestamp>, which fails, and the manifests took the files from GitHub master instead. curl wrote the "404: Not Found" body of the files master lacks into the ConfigMaps without a word. 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.Known limitation, documented: clickhouse-backup checks REST API credentials against the config it has loaded, and only an authenticated operation reloads it. If
<chi>-auto-backup-secretis deleted and recreated with new random passwords, the sidecars must be restarted by hand. Until then the Jobs get401. The old mechanism restarted the sidecars in that case.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