Skip to content

ClickHouse system-bucket backup needs pod restart after first credential projection #3986

Closed

Description

@myasnikovdaniil

What is wrong?

ClickHouse with backup.useSystemBucket: true can start before cozy-backups-creds exists. Secret refs are optional, so sidecar starts without S3 values. First BackupJob projects Secret into tenant namespace, but environment of running clickhouse-backup container is not updated and backup still does not complete until pod restart.

This bug predates #3963. Scheme fix from that PR works when Secret existed before ClickHouse pod start.

How to reproduce

  1. Use tenant namespace without cozy-backups-creds.
  2. Create ClickHouse with backup.enabled: true and backup.useSystemBucket: true.
  3. Create BackupJob for it with backupClassName: cozy-default.
  4. Secret appears, but backup does not complete. Restart ClickHouse pod and retry, projected credentials are picked up.

Expected behaviour

First backup and restore should work without manual pod restart.

Acceptance

Make sidecar pick up credentials projected after pod start, or roll and wait for ClickHouse pod after projection. Add ClickHouse e2e which starts without Secret and runs backup and restore through cozy-default.

Update docs/operations/backup-classes.md and projector comment: projected endpoint stays bare, ClickHouse chart adds https://.

Related to #2734, projected Secret lifecycle must stay compatible with long-running ClickHouse sidecar.

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug
    priority/backlogGeneral backlog priority. Lower than priority/important-longterm
    area/databaseIssues or PRs related to managed databases (postgres, mariadb, redis, etcd, kafka, clickhouse)
    triage/acceptedIndicates an issue is ready to be actively worked on
    on Aug 28, 2026
  2. myasnikovdaniil commented on Nov 4, 2026

    @myasnikovdaniil
    ContributorAuthor

    I reproduced this on v1.7.0 on a clean tenant and measured how it fails, maybe it helps with the acceptance criteria.

    Sidecar of a release with backup.useSystemBucket: true starts with only S3_PATH and a literal, unexpanded S3_ENDPOINT=https://$(S3_ENDPOINT_HOST) in its environment, because every secretKeyRef is optional and the Secret does not exist yet. The first BackupJob creates cozy-backups-creds within a second, before the first strategy pod runs, so the Secret is complete when the sidecar is called, but the sidecar never sees it.

    BackupJob ends Failed after 2m53s: three strategy pods, each calling POST /backup/create_remote and getting can't upload <archive>/metadata.json: S3 PutFileAbsolute Upload: operation error S3: PutObject, get identity: get credentials: ... no EC2 IMDS role found. BackupJob status says only Job has reached the specified backoff limit, so the cause is visible in the pod and sidecar logs only. It is terminal, a second BackupJob four minutes later fails the same way and the first is still Failed 30 minutes later. After kubectl delete pod of the ClickHouse pod a new BackupJob succeeds in 20 seconds.

    RestoreJob on a fresh pod without the Secret fails the same way and is more confusing: GET /backup/list/remote answers HTTP 200 with an empty body when S3 authentication fails, so the strategy pod prints no remote backup found although the archives are in the bucket.

    Rotation has the same shape. With dead keys in the sidecar a BackupJob fails with 403 InvalidAccessKeyId while the projected Secret already holds the right keys, because the projector rewrites it at every BackupJob reconcile and the sidecar keeps what it read at start. A changed region does not fail on SeaweedFS (it accepted a mismatching signing region in my test), so there the divergence is silent.

    Whatever the fix is (roll the pod after the first projection, mount the Secret as files, make the sidecar re-read), I would also make the strategy fail with a message that names the missing sidecar credentials, otherwise a ClickHouse pod started before the Secret and never restarted keeps failing.

    Failed attempts of this also leave archives behind that the sidecar uploads at the next restart, I filed that separately.

  3. self-assigned this
    on Nov 4, 2026
  4. scooby87 commented on Nov 12, 2026

    @scooby87
    Contributor

    Fixed by #5232.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/databaseIssues or PRs related to managed databases (postgres, mariadb, redis, etcd, kafka, clickhouse)kind/bugCategorizes issue or PR as related to a bugpriority/backlogGeneral backlog priority. Lower than priority/important-longtermtriage/acceptedIndicates an issue is ready to be actively worked on

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions