You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ClickHouse system-bucket backup needs pod restart after first credential projection #3986
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
Use tenant namespace without cozy-backups-creds.
Create ClickHouse with backup.enabled: true and backup.useSystemBucket: true.
Create BackupJob for it with backupClassName: cozy-default.
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.
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.
Activity
myasnikovdaniil commentedon Nov 4, 2026
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: truestarts with onlyS3_PATHand a literal, unexpandedS3_ENDPOINT=https://$(S3_ENDPOINT_HOST)in its environment, because everysecretKeyRefis optional and the Secret does not exist yet. The first BackupJob createscozy-backups-credswithin 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
Failedafter 2m53s: three strategy pods, each callingPOST /backup/create_remoteand gettingcan't upload <archive>/metadata.json: S3 PutFileAbsolute Upload: operation error S3: PutObject, get identity: get credentials: ... no EC2 IMDS role found. BackupJob status says onlyJob 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 stillFailed30 minutes later. Afterkubectl delete podof 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/remoteanswers HTTP 200 with an empty body when S3 authentication fails, so the strategy pod printsno remote backup foundalthough the archives are in the bucket.Rotation has the same shape. With dead keys in the sidecar a BackupJob fails with
403 InvalidAccessKeyIdwhile 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.
scooby87 commentedon Nov 12, 2026
Fixed by #5232.