From 8ba0380043c0eaaa4c01dcee8ae205702ed3f754 Mon Sep 17 00:00:00 2001 From: Alexey Artamonov Date: Wed, 11 Nov 2026 14:42:49 +0300 Subject: [PATCH] docs(clickhouse): name the clickhouse-backup handlers that reload the config clickhouse-backup reloads its config file in each handler that reaches S3, among them the create_remote, restore_remote and list calls the strategy makes. The status and action-log endpoints the strategy polls read in-memory state and do not reload it, so the mounted file reaches the sidecar on the calls that need credentials rather than on every request. Assisted-by: LLM Signed-off-by: Alexey Artamonov --- internal/backupcontroller/credentials_projector.go | 7 ++++--- .../backupcontroller/credentials_projector_test.go | 3 ++- packages/apps/clickhouse/templates/clickhouse.yaml | 12 ++++++------ packages/apps/clickhouse/tests/backup_test.yaml | 7 ++++--- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/internal/backupcontroller/credentials_projector.go b/internal/backupcontroller/credentials_projector.go index 576991d86..aaba89b3c 100644 --- a/internal/backupcontroller/credentials_projector.go +++ b/internal/backupcontroller/credentials_projector.go @@ -450,9 +450,10 @@ const credentialsUpdatedAtAnnotation = "backups.cozystack.io/credentials-updated // clickHouseBackupConfigKey holds the s3 section of a clickhouse-backup // config. The ClickHouse chart mounts it as the sidecar's config file // instead of passing the values as environment: clickhouse-backup reloads -// the file on every API call and kubelet rewrites a mounted Secret in -// place, so credentials projected after the pod started, or rotated since, -// reach a running sidecar. +// the file in each API handler that reaches S3, among them the +// create_remote, restore_remote and list calls the strategy makes, and +// kubelet rewrites a mounted Secret in place, so credentials projected +// after the pod started, or rotated since, reach a running sidecar. const clickHouseBackupConfigKey = "clickhouse-backup.yml" // buildClickHouseBackupConfig renders that file. The projected endpoint is diff --git a/internal/backupcontroller/credentials_projector_test.go b/internal/backupcontroller/credentials_projector_test.go index dd3cf131b..74fd936d1 100644 --- a/internal/backupcontroller/credentials_projector_test.go +++ b/internal/backupcontroller/credentials_projector_test.go @@ -673,7 +673,8 @@ func TestProject_HappyPath_HTTPEndpoint(t *testing.T) { // The ClickHouse sidecar reads its S3 settings from this key as a mounted // file, which kubelet refreshes in place: clickhouse-backup reloads its -// config file on every API call, while its environment is fixed at start. +// config file in each API handler that reaches S3, while its environment +// is fixed at start. func TestProject_WritesClickHouseBackupConfig(t *testing.T) { cases := []struct { name string diff --git a/packages/apps/clickhouse/templates/clickhouse.yaml b/packages/apps/clickhouse/templates/clickhouse.yaml index 4934e8db1..5d0c1c6ab 100644 --- a/packages/apps/clickhouse/templates/clickhouse.yaml +++ b/packages/apps/clickhouse/templates/clickhouse.yaml @@ -230,12 +230,12 @@ spec: backupStorage.forcePathStyle included, comes from the clickhouse-backup.yml key the platform projects into cozy-backups-creds, mounted below as the config file. - clickhouse-backup reloads that file on every API call and - kubelet rewrites a mounted Secret in place, so credentials - projected after the Pod started, or rotated since, reach - the running sidecar; environment would be read only at - start and would override the file, so none of those is - set here. + clickhouse-backup reloads that file in each API handler + that reaches S3 and kubelet rewrites a mounted Secret in + place, so credentials projected after the Pod started, or + rotated since, reach the running sidecar; environment + would be read only at start and would override the file, + so none of those is set here. S3_FORCE_PATH_STYLE selects path-style vs vhost-style S3 addressing. On the legacy paths (own Secret via diff --git a/packages/apps/clickhouse/tests/backup_test.yaml b/packages/apps/clickhouse/tests/backup_test.yaml index 7448e02a3..7954d5d3d 100644 --- a/packages/apps/clickhouse/tests/backup_test.yaml +++ b/packages/apps/clickhouse/tests/backup_test.yaml @@ -47,9 +47,10 @@ tests: - equal: path: spec.templates.podTemplates[0].spec.containers[?(@.name=="clickhouse-backup")].env[?(@.name=="S3_PATH")].value value: tenant-test/ch-test - # clickhouse-backup reloads this file on every API call and kubelet - # rewrites the mounted Secret in place, so credentials projected after - # the Pod started, or rotated since, reach the running sidecar. + # clickhouse-backup reloads this file in each API handler that reaches + # S3 and kubelet rewrites the mounted Secret in place, so credentials + # projected after the Pod started, or rotated since, reach the running + # sidecar. - equal: path: spec.templates.podTemplates[0].spec.containers[?(@.name=="clickhouse-backup")].env[?(@.name=="CLICKHOUSE_BACKUP_CONFIG")].value value: /etc/clickhouse-backup-s3/config.yml