fix(clickhouse): stop the backup sidecar from publishing failed attempts

create_remote keeps its local backup when the upload fails, and with
the upstream defaults the sidecar never prunes local backups and
resumes every unfinished upload when it starts. A strategy attempt that
fails mid-upload therefore lands in the bucket on the next sidecar
restart as an archive no Backup refers to, and restore can pick it as
the newest one. The resumed upload also holds the API lock, so the
strategy Pods racing it get 423 and burn the Job's retries.

Turning the resume off keeps a failed attempt out of the bucket, and a
negative local retention leaves at most the newest local backup and
drops it once its upload succeeds, so leftovers no longer accumulate on
the data volume.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit 4f3f1a5cad)
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
This commit is contained in:
Alexey Artamonov authored and Myasnikov Daniil committed 2026-11-25 10:15:38 +00:00
1 parent 668ddded49
commit 84a5f9ee64
2 files changed
+51

No files matched your search

@@ -222,6 +222,18 @@ spec:
key: backup
- name: ALLOW_EMPTY_BACKUPS
value: "true"
{{- /*
create_remote keeps the local backup when its upload fails,
and the upstream defaults never prune local backups (0) and
resume unfinished uploads at start, which pushes a failed
attempt to the bucket as an archive no Backup refers to and
holds the API lock (423) while it does. -1 keeps only the
newest local backup and removes it once its upload succeeds.
*/}}
- name: BACKUPS_TO_KEEP_LOCAL
value: "-1"
- name: API_COMPLETE_RESUMABLE_AFTER_RESTART
value: "false"
- name: REMOTE_STORAGE
value: s3
{{- /*
@@ -292,3 +292,42 @@ tests:
- notMatchRegex:
path: stringData["backup.sh"]
pattern: 'echo DB_LIST='
# A strategy attempt that fails mid-upload leaves its local backup behind,
# and with the upstream defaults the sidecar would keep it forever and push
# it to the bucket on its next start as an archive no Backup refers to. The
# sidecar must neither resume uploads at start nor keep local copies once an
# upload succeeds, on either S3 flow.
- it: "sidecar drops local backups after upload and does not resume uploads at start"
template: templates/clickhouse.yaml
documentSelector:
path: kind
value: ClickHouseInstallation
set:
backup:
enabled: true
useSystemBucket: true
asserts:
- equal:
path: spec.templates.podTemplates[0].spec.containers[?(@.name=="clickhouse-backup")].env[?(@.name=="BACKUPS_TO_KEEP_LOCAL")].value
value: "-1"
- equal:
path: spec.templates.podTemplates[0].spec.containers[?(@.name=="clickhouse-backup")].env[?(@.name=="API_COMPLETE_RESUMABLE_AFTER_RESTART")].value
value: "false"
- it: "legacy flow: sidecar drops local backups after upload and does not resume uploads at start"
template: templates/clickhouse.yaml
documentSelector:
path: kind
value: ClickHouseInstallation
set:
backup:
enabled: true
useSystemBucket: false
asserts:
- equal:
path: spec.templates.podTemplates[0].spec.containers[?(@.name=="clickhouse-backup")].env[?(@.name=="BACKUPS_TO_KEEP_LOCAL")].value
value: "-1"
- equal:
path: spec.templates.podTemplates[0].spec.containers[?(@.name=="clickhouse-backup")].env[?(@.name=="API_COMPLETE_RESUMABLE_AFTER_RESTART")].value
value: "false"