Repository navigation
docs(clickhouse): describe deleting a ClickHouse archive with its Backup - #809
Merged
Merged
Conversation
scooby87
requested review from
Andrei Kvapil (kvaps),
Timofei Larkin (lllamnyp),
myasnikovdaniil and
Timur Tukaev (tym83)
as code owners
November 13, 2026 14:23
✅ Deploy Preview for cozystack ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
1 of 12 tasks
Aleksei Sviridkin (lexfrei)
added a commit
to cozystack/cozystack
that referenced
this pull request
Nov 23, 2026
<!-- Thank you for making a contribution! Here are some tips for you: - Use Conventional Commits for the PR title: `type(scope): description` - Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore - Scopes are not an exhaustive list — pick the most specific scope for the change and extend the list when a genuinely new area appears. Examples: - System components: dashboard, platform, operator, cilium, kube-ovn, linstor, fluxcd, cluster-api - Managed apps: postgres, mariadb, redis, kafka, clickhouse, virtual-machine, kubernetes - Development and maintenance: api, hack, tests, ci, docs, maintenance - Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Add the label `kind/backport` if it's a bugfix that needs to be backported to a previous version. --> ## What this PR does Builds on #5229 (merged), which gives every backup run an archive of its own. Deleting a `Backup` taken with the Altinity (ClickHouse) strategy released its finalizer at once and left the archive in the bucket. On the system bucket nothing else prunes it, so every ClickHouse backup stayed until someone called the sidecar by hand, and the route the chart and the examples documented for that, `DELETE /backup/<name>/remote`, does not exist in clickhouse-backup 2.7 and answers 404. The driver names each archive `<application>-<start time as YYYYMMDDHHMMSS>-<first 12 hex digits of the BackupJob UID>` (#5229) and records it on the `Backup` under `altinity.strategy.backups.cozystack.io/archive`. This PR also records, under `altinity.strategy.backups.cozystack.io/use-system-bucket`, the application's `backup.useSystemBucket` as it read when the backup Job was created: the setting is stamped on the backup Job and copied onto the `Backup`, because the application may switch before the controller sees the Job complete. A Job created before the stamp existed falls back to the application as it reads at completion. For a system-bucket application the bucket the projected credentials (`cozy-backups-creds`) name is recorded the same way, under `altinity.strategy.backups.cozystack.io/bucket`. The `Backup` is created with its cleanup finalizer already set, so a `Backup` deleted before the `Backup` reconciler first sees it still has its archive deleted. On `backup.useSystemBucket: true`, deleting the `Backup` runs a one-shot cleanup Job that calls `POST /backup/delete/remote/<name>` on the application's sidecar and holds the finalizer until it completes. The sidecar refuses a delete with 423 while any other operation runs and cannot be reached while its Pod restarts, so the Job waits both out within its deadline; an archive that is already gone counts as deleted, and any other answer fails the Job, which is reported as an `ArtifactCleanupFailed` Warning Event carrying the reason the Job failed and retried after a wait that starts at 30 seconds and doubles with each failure up to 30 minutes (kept on the `Backup` under `altinity.strategy.backups.cozystack.io/cleanup-failures` and `.../cleanup-retry-after`, since the failed Job is deleted to make room for the next). The Job starts only once the projected credentials have reached the sidecar, as the backup and restore Jobs do. It is built by the controller, not rendered as a whole from the strategy template, because the shipped and the example templates run `restore_remote` for every mode other than `backup`; only the image, how to pull it and where the Pod may be scheduled (node selector, tolerations, affinity, priority class) come from the template, rendered as for the strategy's own Pods. When the delete cannot or must not run, the `Backup` is released with an `ArtifactNotDeleted` Warning Event naming the archive left behind: the namespace is terminating, the strategy, the application or its API Secret is gone, the application no longer uses the system bucket (also when it leaves while the delete runs), the system bucket is no longer the one the `Backup` records or cannot be read (also when it changes while the delete runs; a sidecar on another bucket would answer "not found" and the delete would count as done), another Job holds the cleanup Job name, or the archive has the older `clickhouse-<application>-<YYYYMMDDTHHMMSSZ>` form, without its BackupJob's UID. Such a name comes from a controller that predates per-run names; two runs of one application started within the same second share it, and a run still in flight when the controller is upgraded records it later, so it is never deleted. `backups.cozystack.io/skip-artifact-cleanup: "true"` releases a `Backup` without deleting anything. An application on its own bucket keeps the archive's lifecycle, as with MongoDB. The wrong delete route is corrected in the chart comments and the restore scenario. A BackupJob or RestoreJob no longer takes the outcome of a batch Job of its name that it does not control. A Job left by an earlier owner of the same name is waited out, with the `Ready` condition (`PredecessorJobPending`) naming it, until the garbage collector removes it; any other Job holding the name fails the BackupJob or RestoreJob with a message naming the Job. The condition is dropped once the run's own Job starts. The example strategy under `examples/backups/clickhouse` now uploads under the archive name the controller chose and restores the archive the `Backup` records, as the shipped strategy does, keeping its clock-made name and the newest archive only as the fallback for a run given no name; `hack/clickhouse-example-strategy.bats` runs it against a stubbed sidecar. The backup scenario no longer says the archive is expired by the upstream tool's retention, which the chart does not configure. Known limitations: a `Backup` taken before #5208, or by a custom strategy that does not use `.ArchiveName`, does not name its archive and keeps it; a `Backup` that names its archive but not the bucket setting, as every `Backup` taken before this change does (a 1.7.x release that carries #5208 among them), keeps its archive too and is released without an Event; a `Backup` that records no bucket, taken before buckets were recorded, is deleted without the bucket check; a `Backup` deleted during an application uninstall can lose its cleanup Job to the chart's own `<release>-cleanup` hook and is then released with a Warning Event, leaving the archive; the recorded setting and bucket are read when the backup Job is created, not observed from the upload, so a switch made just before a backup, while the sidecar still runs on the previous bucket, is recorded for an archive written to the previous one. Related gap outside this PR, in main today: an archive uploaded by a run whose `Backup` name is already taken is recorded by nothing, so no `Backup` deletes it. Verified with unit tests that drive the cleanup path through a fake client and the cleanup script against a stub `curl`, with mutation checks on every guard, and on a test cluster running v1.7.0 with the backup controllers built from this branch (before #5229 shortened the run name to its current form, which leaves the deletion side unchanged), against the real clickhouse-backup sidecar and SeaweedFS: a backup records a per-run archive name and the bucket setting on a `Backup` created with its finalizer; deleting the `Backup` deletes the archive's objects in the bucket; a restore from a `Backup` brings the data back; a BackupJob recreated under a used name waits for the earlier Job and then writes an archive of its own; a Job of that name created by anything else fails the BackupJob; a `Backup` recording an archive named without a UID is released with `ArtifactNotDeleted` and its objects stay. The changes made after that run (the recorded bucket, the retry wait, the credentials wait before the cleanup Job, the rendered cleanup Pod settings, the cleared predecessor condition, the example strategy) are covered by the unit tests and bats, not by a live run. ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#809 (for cozystack/website#808; its `next/` pages should merge after this PR) - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note fix(clickhouse): deleting a Backup taken on the system bucket from this release on now deletes its clickhouse-backup archive and keeps the Backup until the delete finished, reporting an archive it cannot or must not delete (including one named without its BackupJob's UID, or in a system bucket the platform has left) as a Warning Event and retrying a failed delete with a growing wait; the cleanup Pod is scheduled as the strategy's own Pods; a BackupJob or RestoreJob no longer reports the outcome of a batch Job it did not create; the documented sidecar delete route is corrected to POST /backup/delete/remote/<name>. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * ClickHouse backups using the system bucket now remove their recorded archive when the backup is deleted. Deletion waits for cleanup to finish. * Backup and restore operations use the controller-provided archive name when available. Restores can fall back to the latest matching archive. * **Bug Fixes** * Temporary sidecar failures are retried with increasing delays. If cleanup cannot safely remove an archive, it completes with a warning rather than risking deletion of the wrong archive. * **Documentation** * Clarified that archives in tenant-owned buckets remain until manually deleted or removed by bucket lifecycle rules. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 of 12 tasks
scooby87
added a commit
to cozystack/cozystack
that referenced
this pull request
Nov 24, 2026
…one once (#5415) <!-- Thank you for making a contribution! Here are some tips for you: - Use Conventional Commits for the PR title: `type(scope): description` - Types: feat, fix, security (a fix that comes through a security advisory), docs, style, refactor, perf, test, build, ci, chore - Scopes are not an exhaustive list — pick the most specific scope for the change and extend the list when a genuinely new area appears. Examples: - System components: dashboard, platform, operator, cilium, kube-ovn, linstor, fluxcd, cluster-api - Managed apps: postgres, mariadb, redis, kafka, clickhouse, virtual-machine, kubernetes - Development and maintenance: api, hack, tests, ci, docs, maintenance - Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Fixes merged to `main` reach the release lines the backport batch runs for automatically, so do not open backport PRs by hand: https://github.com/cozystack/cozystack/blob/main/docs/release/backports.md --> ## What this PR does <!-- Link the issues this PR addresses. For a complete fix targeting the default branch, use Closes #N (Closes owner/repository#N for another repository). Otherwise use a non-closing reference; release-branch PRs need manual issue linking and closure when appropriate. --> Closes #5198. Follow-up to #5224, closing three gaps in how a ClickHouse archive delete on the system bucket treats a refused or failed cleanup Job. - A cleanup Job a ResourceQuota refuses with `status unknown for quota:`, which the quota admission returns until the quota controller has computed the usage, released the `Backup` and left its archive in the bucket for good, although the refusal clears by itself. It is now retried like `exceeded quota:`; any other `Forbidden` or `Invalid` refusal still releases the `Backup` with `ArtifactNotDeleted`. - A cleanup Job a quota refuses now raises an `ArtifactCleanupFailed` Warning Event on the `Backup`, so a `Backup` held terminating by a quota says why. - Recording a failed cleanup Job on the `Backup` starts the next reconcile at once, while the Job cache can still hold the Job just deleted, so one failure could be counted twice: a second Event and the retry wait doubled once more. The UID of the counted Job is now kept on the `Backup` under `altinity.strategy.backups.cozystack.io/cleanup-failed-job`, and a failed Job with that UID is only deleted. - The restore scenario now says that the skip annotation stops only new cleanup Jobs (a cleanup Pod that already exists can still start a delete), and that a quota-refused delete holds the `Backup` until the annotation releases it. Covered by unit tests through the fake client, each guard checked by mutation; not run against a cluster. Out of scope, found while reviewing: the Kafka, Kubernetes, Redis and RabbitMQ strategy controllers release a `Backup` on any `Forbidden` from the cleanup Job create, a quota refusal included, so on a namespace whose Job quota is full their archives are left behind the same way. ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#809 (the ClickHouse archive delete page, updated for the quota retry and the skip annotation wording) - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note fix(clickhouse): a ClickHouse archive delete whose cleanup Job a ResourceQuota refuses, including before the quota's usage is known, now keeps the Backup and retries with an ArtifactCleanupFailed Warning Event instead of releasing it and leaving the archive; a failed cleanup Job is counted once. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Backups are retained when cleanup Jobs are refused due to quota limits, with a warning and retry when quota permits. * Repeated reconciliation of the same failed cleanup Job no longer increments the failure count or emits duplicate warnings. * Invalid cleanup errors continue to release the Backup, even if the error message mentions quota. * Clarified that cleanup may continue if a Pod has already started or a sidecar has accepted the deletion. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
IvanHunters
approved these changes
Nov 24, 2026
scooby87
enabled auto-merge
November 24, 2026 12:45
cozystack/cozystack#5224 makes deleting a Backup taken on the system bucket delete its clickhouse-backup archive, and the trunk docs still said the archive stays and is governed by the sidecar's retention, which the chart does not configure. The backup classes page described the cleanup of the other drivers but not of ClickHouse, which now has its own Events, retry and release cases. The v1.4 page sent administrators to DELETE /backup/<name>/remote, which clickhouse-backup 2.7 does not serve; the route is POST /backup/delete/remote/<name>. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
…on stops A cleanup Job a ResourceQuota refuses now holds the Backup and is retried, and the skip annotation stops only new cleanup Jobs: a cleanup Pod that already exists can still start a delete until it is removed. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
scooby87
force-pushed
the
docs/clickhouse-archive-delete
branch
from
November 24, 2026 12:55
359641d to
d710875
Compare
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.
What this PR does
Documents the ClickHouse archive cleanup that cozystack/cozystack#5224 adds, and fixes the sidecar delete route in the v1.4 docs. Fixes #808.
next/operations/services/backup-classes.md: a new "ClickHouse archive cleanup" section. Onbackup.useSystemBucket: true, deleting aBackupdeletes its archive through the sidecar and theBackupstays until that delete finished; it covers the waits, theArtifactCleanupFailedretries, the cases released withArtifactNotDeleted, the skip annotation, and theBackups that keep their archive.next/applications/backup-and-recovery.md: the retention bullet no longer says a deletedBackupalways leaves its S3 object, and the ClickHouse line describes the new behaviour instead of the sidecar's retention, which the chart does not configure.v1.4/operations/services/managed-app-backup-configuration.md:DELETE /backup/<name>/remoteis not served by clickhouse-backup 2.7 and answers 404; the route isPOST /backup/delete/remote/<name>.The
next/changes describe behaviour from cozystack/cozystack#5224, so they should merge after it. The v1.4 route fix stands on its own.