mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
cdec07d0bd853d64b2c4b812e3eb4f46ca8b5dba
303
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
faaa2b7f2c |
refactor(backups): stop annotating restored PVCs for CDI claim adoption
CDI decides whether a DataVolume may adopt an existing claim from the cdi.kubevirt.io/allowClaimAdoption annotation on the DataVolume, or from the DataVolumeClaimAdoption feature gate. It never reads the annotation on the PVC. The Velero modifier rule that stamped it on every restored PVC in both the VM and the Kubernetes restore strategy therefore changed nothing, while the Kubernetes strategy comment and the VM restore example described it as part of what lets CDI adopt. Drop the PVC rule from both strategies. Adoption still rests on the annotation the vm-disk chart puts on its DataVolume and, for tenant clusters, on the rule that sets it on restored DataVolumes, which a test now pins as the only rule of the volumes phase. Without that rule an in-place VM strategy restore of a VMDisk, or of a VMInstance with no recorded IP and MAC to keep, has no modifier rule left. Velero fails validation of a Restore whose modifier ConfigMap has an empty rule list, so in that case no ConfigMap is created and the Restore carries no resource modifier. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
fc5ece0a28 |
fix(clickhouse): keep a quota-held archive delete and count a failed 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 --> |
||
|
|
94d710e50f |
fix(tenant): render the LimitRange only under a compute quota (#4954)
## What this PR does
The tenant chart rendered `tenant-range-limits` whenever
`resourceQuotas` was non-empty. Under a quota on something other than
compute, for example `{services.loadbalancers: "1"}`, `storage` or
`nvidia.com/gpu` alone, its 128Mi default memory limit still applied to
every container and refused any pod that requests more memory without a
limit of its own. virt-launcher is one of those, so VMs could not start
in such a tenant.
The LimitRange exists so pods without requests or limits pass a quota
that tracks `cpu`, `memory` or `ephemeral-storage`. This PR has it
default each of those three only when the flattened quota bounds that
resource (its `requests.*` or `limits.*` key), and renders no LimitRange
when the quota bounds none of them. A quota on all three renders the
LimitRange exactly as before, with the same values. The ResourceQuota is
unchanged. The system memory limits guide has moved to the website and
described the old condition in two places; the follow-up below updates
it. A second commit qualifies the comments in the operator, the tenant
quota controller, the backup controller and the barman and kafka charts
that still said every tenant with `resourceQuotas` gets a 128Mi memory
default.
Tests:
- New `packages/apps/tenant/tests/quota_limitrange_test.yaml` (9 tests):
no LimitRange under a quota on load balancers, storage or GPUs alone;
only the cpu, only the memory, or only the ephemeral-storage defaults
under a quota on that resource alone; only memory beside non-compute
keys; every default, values unchanged, under a quota on all three.
- Against main's template, 7 of the 9 tests fail. The two that pass are
the empty quota and the full cpu, memory and ephemeral-storage quota,
which keep their behaviour.
- `helm unittest` for the whole tenant chart: 23 suites, 98 tests pass.
- `helm template` of `templates/quota.yaml` under `{cpu, memory,
ephemeral-storage}` is identical to main.
I did not reproduce the virt-launcher admission failure on a live
cluster; the reproduction in the issue is from a test cluster on main.
Fixes #4930
### Screenshots
Not a UI change.
### Downstream repositories
- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: cozystack/website#817
- [ ]
[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
```release-note
fix(tenant): the tenant LimitRange now defaults cpu, memory and ephemeral-storage only when resourceQuotas bounds that resource, so a quota without memory no longer gives containers a 128Mi default memory limit that kept VMs from starting.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* LimitRange settings are now rendered only when quotas bound CPU,
memory, or ephemeral storage. Defaults are included only for the bounded
resources; quotas limited to load balancers, storage, or GPUs do not
trigger a LimitRange on their own.
* **Documentation**
* Clarified when tenant namespaces receive LimitRange defaults,
including the resource-specific conditions for CPU, memory, and
ephemeral storage.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
3c04f64307 |
fix(clickhouse): count a failed archive delete once
Recording a cleanup Job's failure on the Backup starts the next reconcile at once, and the Job cache can still hold the failed Job the controller has just deleted. That reconcile counted the same failure again: a second ArtifactCleanupFailed Event and the wait doubled once more for one failed delete. The UID of the counted Job is kept on the Backup beside the count, and a failed Job with that UID is only deleted, the Backup held for the rest of the wait already set. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
905a75118f |
fix(clickhouse): name a quota-held archive delete on its Backup
A cleanup Job a ResourceQuota refuses is retried with the Backup held, which leaves the Backup terminating with the reason only in the controller log. The refusal is now an ArtifactCleanupFailed Warning Event on the Backup, as a failed cleanup Job is. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
64d614d0d1 |
fix(clickhouse): hold an archive delete while a quota's usage is unknown
The ResourceQuota admission plugin refuses a Job with "status unknown for quota:" until the quota controller has computed its usage, as well as with "exceeded quota:" once it is used up. The cleanup only retried the latter; on the former it released the Backup and left its archive in the bucket for good, though the refusal clears by itself. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
a2f7ea18ee |
fix(clickhouse): drop the predecessor wait once a run's own Job starts
A BackupJob or RestoreJob that waited for the Job of an earlier owner of its name kept its Ready=False PredecessorJobPending condition after that Job was gone and its own Job had started, so for the whole run it still said it was waiting for the garbage collector. The condition is now dropped when the run's own Job is running, the way the credentials wait is. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
084fed9e2f |
fix(clickhouse): take no restore Job's result that this RestoreJob did not run
The restore path took any Job standing under a RestoreJob's Job name as its own, so a RestoreJob re-created under a used name met the completed Job of the earlier one before the garbage collector removed it and was marked Succeeded although nothing was restored for it. The restore path now refuses such a Job the way the backup path does: the Job of an earlier RestoreJob of the same name is waited out, with the Ready condition naming it, and any other Job holding the name fails the RestoreJob. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
e199ef1d83 |
fix(clickhouse): take no backup Job's result that this BackupJob did not run
A Job standing under a BackupJob's Job name was taken as its own. A BackupJob re-created under a used name, as a Plan does when the BackupJob of a schedule slot is deleted within the slot's starting deadline, met the completed Job of the earlier one before the garbage collector removed it, was marked Succeeded without uploading anything, and recorded a Backup for an archive nobody uploaded for it. A Job controlled by an earlier BackupJob of the same name is now waited out, with the Ready condition naming it; any other Job holding the name fails the BackupJob, since nothing will remove it. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
564bdd3a79 |
fix(clickhouse): delete the archive when its Backup is deleted
Deleting a Backup taken with the Altinity 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. Deleting such a Backup now runs a one-shot Job that asks the application's sidecar to delete the archive the Backup records, and holds the finalizer until the Job completes. The driver creates the Backup with the finalizer already set, so a Backup deleted before the reconciler first sees it still gets its archive deleted. An archive that is already gone counts as deleted. The sidecar refuses a delete while another operation runs, and cannot be reached while the ClickHouse Pod restarts, so the Job waits both out within its deadline; any other refusal fails the Job, which is reported as an ArtifactCleanupFailed Warning Event carrying the reason it failed. Each failure doubles the wait before the next cleanup Job, from 30 seconds up to 30 minutes, so a delete the sidecar refuses for good, such as one made with a wrong password, does not cost a Job, its Pod and a Warning Event every few seconds. The count of failures and the time the next Job may start are kept on the Backup, because the Backup controller does not watch Jobs; a start time further ahead than the longest wait, from a skewed clock or a hand edit, is logged and ignored. A Job the namespace's Job quota refuses is retried once a slot frees up rather than released, since the Backup would be gone by then and nothing would delete the archive. The Job is built by the controller, not rendered from the strategy template, because the shipped and the example templates run a restore for every mode other than backup. Only the image, how to pull it, and the node selector, tolerations, affinity and priority class come from the template, rendered against the application and the Backup as for the strategy's own Pods, so the cleanup Pod can be scheduled where they are. The strategy is read only when a Job has to be created, so a running delete outlives it. The Job also waits for the projected credentials to reach the sidecar, as the backup and restore Jobs do: a sidecar still serving the previous bucket answers "not found", and the delete would count as done. When the delete cannot 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 has left the system bucket, the platform's system bucket is no longer the one the Backup records (also when it changes while the delete runs), another Job holds the cleanup Job name, or the API server refuses the Job. An archive named without its BackupJob's UID is released the same way: such a name comes from a run that crossed the controller upgrade, and another run started in the same second may share it. The backups.cozystack.io/skip-artifact-cleanup annotation releases the Backup without starting a delete. An application on its own bucket keeps the archive's lifecycle, as with MongoDB. The restore scenario and the chart comments told tenants to delete an archive with DELETE /backup/<name>/remote, which clickhouse-backup 2.7 answers with 404; they now name POST /backup/delete/remote/<name>. Co-authored-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> |
||
|
|
b62f2f385f |
fix(clickhouse): record the bucket setting a ClickHouse backup was taken with
A ClickHouse application writes its archives either to the system bucket, which nothing prunes, or to its own bucket, whose lifecycle is the tenant's. A Backup did not say which applied, so nothing deciding the fate of the archive when the Backup goes could tell them apart. The application's useSystemBucket is read when the backup Job is created, stamped on the Job and copied onto the Backup from there, because the application may switch before the controller sees the Job complete. It is the setting, not an observation of the bucket: the sidecar uploads to the bucket it was last restarted with, so a switch made just before the backup can be recorded while the sidecar still writes to the previous bucket. A Job created before the stamp existed falls back to the application as it reads then. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
46f03b8748 |
docs(tenant): qualify LimitRange defaults by the bounded resource
tenant-range-limits now defaults cpu, memory and ephemeral-storage each only when resourceQuotas bounds that resource, and is not rendered at all under a quota on none of them. Comments in the operator, the tenant quota controller, the backup controller and the barman and kafka charts still said every tenant with resourceQuotas gets a 128Mi memory default, which would mislead the next change made on that assumption. The tenant quota controller's gate on limits.cpu or limits.memory stays: a root rendered by an older chart may still carry a LimitRange under a quota that bounds no compute. Assisted-by: LLM Signed-off-by: Nimesh Kulkarni <167794819+GitNimay@users.noreply.github.com> |
||
|
|
e11ca91d81 |
fix(backups): stop leaking MariaDB dumps of stuck runs and torn-down namespaces (#5344)
## What this PR does Closes #5291. Two paths left a MariaDB dump and its `k8s.mariadb.com/Backup` behind after the dump cleanup from #5233. **A run that never completes.** When the operator Backup stays short of `Complete` past `mariadbDefaultBackupDeadline`, the BackupJob now deletes it (background propagation, so its Job goes too) before it marks itself `Failed`, and says so in the failure message. No Cozystack `Backup` is ever made of such a run, so nothing else deleted it, and while it stood its window had no end: `contestedMariaDBDump` counted it as a possible writer of every later dump of the application, and every later `Backup` was released with `ArtifactNotDeleted`. Deleting the Job also stops a run that is still going from uploading a dump nobody tracks. An operator Backup that is `Complete=True` on a reason the driver does not know has a bounded window and is kept, as before. The decision is made on the operator Backup read from the API server, not the cache. A run the operator has just marked complete or failed goes down the normal path and is not deleted. The delete carries the UID and resourceVersion that were read, so a run that completes between the read and the delete is not deleted either. Past the deadline no new run is created, so a pass that deleted the run and then failed to persist `Failed` does not start another one on retry. A delete the API server keeps refusing shows as `Ready=False/OperatorBackupDeleteFailed` on the BackupJob. The delete also removes the run's pod, so before it the controller copies what held the pod up into the failure message: an unschedulable pod, or a container that is waiting or has failed. The MariaDB driver's other failure exits take the same path: the MariaDB application was deleted, the MariaDB CR never came back, the strategy disappeared past its deadline, the strategy no longer renders, the applicationRef is rejected, or the run could not be created. Past the deadline, the run is taken from the API server listing and `ensureMariaDBBackup` is not called, so a cache that has not seen the run cannot cause a second one to be created. mariadb-operator leaves the run of a MariaDB that went away at `Complete=False` for good, so if the application was later recreated under the same name, that run used to contest every later dump. The deadline is still 30 minutes from `StartedAt`, but a dump that is still running at that point is now stopped instead of being left to finish outside Cozystack. **Namespace teardown.** mariadb-operator puts no finalizer on its `Backup`, so during teardown it is usually gone before the Cozystack `Backup` finalizer runs. When the operator Backup is not found, the cleanup now: - takes bucket, prefix and Secret references from the snapshot in `status.underlyingResources`; - goes on only for a recorded dump (`k8s.mariadb.com/dump-file`) on the platform bucket written with the projected platform Secret, reached with the platform credentials, which do not depend on the namespace; - keeps the dump, with a `Warning ArtifactNotDeleted`, when another operator Backup, finished or not, could have written it (the same `contestedMariaDBDump` check as before); - retries a failed delete through `retryMariaDBCleanup`, which releases the `Backup` once the namespace is terminating. The snapshot and the storage URI now record the storage the run was created with, whatever its kind, rather than the strategy as rendered when the run completed. A strategy edited during a run therefore cannot send the cleanup to the wrong place. The BackupJob looks for its run on the API server rather than in the cache, so a retry after a failed status write never starts a second run. A `Running` BackupJob never starts a run at all, and if its run is gone the job is failed. A `Backup` with no recorded dump, no snapshot, a dump on another bucket or written with the tenant's own Secret, or unreadable platform credentials is released with a `Warning`, as before. A missing operator CRD keeps the old release path. The platform-bucket check that `mariadbCleanupConnection` used is now `mariadbPlatformConnection`, shared by both paths. Its behaviour is unchanged. Not covered: - Operator Backups left behind by BackupJobs that failed before this change are still there, because terminal BackupJobs are not reconciled again. Deleting them by hand releases the dumps they hold. - Deleting a BackupJob that is still running leaves its operator Backup, which has no ownerRef and no finalizer. This was already the case and is not addressed here. - The driver-independent terminal exits in `backupjob_controller.go` (BackupClass resolution, credentials projection) still fail a BackupJob without looking at a MariaDB run. - A run that is stopped at the deadline after it has uploaded its dump leaves that dump untracked. No `Backup` is ever made of such a run. The other fail-safe cases listed in the issue (a `Restore` that never completes, the single `Backup` worker, non-204 DELETE responses, endpoint moves) are not addressed here. Tests: `go test ./internal/backupcontroller/...`. The deadline outcome table now also checks whether the operator Backup was deleted. New cleanup tests cover a missing operator Backup: the dump deleted with the platform credentials, already absent, contested by an unfinished run, a failed delete held for retry, and each case it cannot reach (volume storage, a recorded name that is not a dump, a snapshot of another kind). Deadline tests cover a retry after a failed status write, a cache that trails a completed run or misses a new one, a delete conditional on the run that was read, a refused delete, and the application or MariaDB going away mid-run. ### Screenshots N/A, no UI changes. ### Downstream repositories I checked the trigger map in `docs/agents/contributing.md` against the diff. The diff touches `internal/backupcontroller/mariadbstrategy_*.go` and their tests. It also adds a message helper in `internal/backupcontroller/backupjob_controller.go` and changes comments in `internal/backupcontroller/backup_controller.go` and `packages/system/backupstrategy-controller/templates/rbac.yaml`. No values, schemas, CRDs, RBAC rules, annotations or telemetry change. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [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 ```release-note fix(backups): MariaDB dumps are no longer left in the bucket when a backup run never completes or when a tenant namespace is deleted. A BackupJob that times out now deletes the operator Backup it gave up on, so that run no longer blocks the deletion of later dumps. A Backup whose operator Backup is already gone now deletes its recorded dump from the platform bucket using the platform credentials. A MariaDB backup run that has not completed 30 minutes after its BackupJob started is now stopped. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * MariaDB backup cleanup now removes a recorded dump from the platform bucket when its operator Backup is already gone, while leaving contested or insufficiently verified dumps untouched. * Failed dump deletions are retried, and cleanup reports when a dump is already absent. * Backup jobs are less likely to start duplicate runs during retries, and completed backups retain the storage configuration used by their run. * Failure handling preserves completed runs and includes operator-run completion details when available. * Backup jobs now recheck the operator Backup before failing on a deadline, helping account for runs that completed or failed in the meantime. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
dbc088f862 |
fix(backups): enforce the Velero deletion backoff of failed BackupJobs
The retry backoff of the failed-job sweep only set RequeueAfter. Writing the retry counter onto the BackupJob triggers a reconcile at once, since the BackupJob watch has no predicate. When Velero processes a request instantly, as it does when the backup storage location is missing or read-only, that reconcile replaced the request again, emitted another event and raised the counter without any wait. The sweep now records when it last created a request, in the backups.cozystack.io/velero-deletion-attempted-at annotation, and replaces a processed request only after the backoff for the current count has passed since then. Before that, it requeues for the remaining time. A request Velero never processes, because Velero is down, and a Velero backup stuck in New or with no phase were checked at a fixed interval, each check with an uncached list of Backups. They are now checked again after as long as they have already waited, from the request's or the backup's creation time, capped at one hour. Waiting emits no event. Recording the attempt can fail after the request was created. If the job was deleted meanwhile, the sweep ends without an error. Any other error is logged and the computed requeue is kept, because failing the reconcile would only retry sooner. Unit tests drive the clock through two back-to-back reconciles of an instantly processed request (one replacement, one event), then three retries at 10, 20 and 40 minutes. They also check the waiting intervals for requests and backups of different ages, and both annotation write errors. Refs: #5355 Assisted-by: LLM Signed-off-by: Andrey Kolkov <androndo@gmail.com> |
||
|
|
73df99b77d |
fix(backups): retry stuck Velero deletions of failed BackupJobs and report them
Velero marks a backup Deleting before it removes the data and leaves it in that phase when removing the data fails, with the deletion request processed with errors. The failed-job sweep skipped Deleting backups and did not requeue for them, so their data stayed in the bucket until Velero's TTL. Deleting backups now go through the same request path: a pending request is left alone, and a processed one of ours is replaced. A request of ours that Velero processed without errors is also replaced when the backup still exists, for example after the BSL sync brought it back. Otherwise the request name blocked a new attempt until Velero garbage-collects processed requests a day later. When Velero can never carry out the deletion, because the backup storage location is missing, read-only or unavailable, the sweep replaced the request every 5 minutes without any sign of it. Each replacement now emits a VeleroBackupDeletionFailed Warning event on the BackupJob with Velero's status.errors, and doubles the requeue interval from 5 minutes up to 1 hour. The count is kept in the backups.cozystack.io/velero-deletion-retries annotation, because the replaced request is gone and a requeue carries no state. The controller's ClusterRole already allows patching BackupJobs. Unit tests cover a Deleting backup with a pending request and with an errored one, a cleanly processed request whose backup still exists, an errored request under a foreign name that is left alone, three consecutive failed deletions (three events, 10m, 20m and 40m requeues, the 1h cap), and a cluster without the Velero CRDs. Refs: #5355 Assisted-by: LLM Signed-off-by: Andrey Kolkov <androndo@gmail.com> |
||
|
|
887453c008 |
fix(backups): keep completed Velero backups of failed BackupJobs
The failed-job sweep treated a Completed Velero backup as deletable. A BackupJob can fail after Velero completed, when creating or recording its Backup fails transiently, and that Velero backup may be the only copy of a good backup. The sweep now deletes only Failed, PartiallyFailed and FailedValidation backups, also when several Velero backups reference one job, and it reads the Backups that may reference them through the uncached API reader, so a Backup the cache has not seen yet still protects its data. The Velero strategy no longer requests the deletion before it records the failure. If that status write failed, Velero removed the backup and the retried run created a new one, so the failure was lost. The deletion now comes only from the sweep, which runs on the reconcile that the persisted Failed phase triggers; the BackupJob watch has no predicate that drops status updates. Replacing a request that Velero processed with errors deletes it, and the backupstrategy-controller ClusterRole only allowed create, get, list and watch on deletebackuprequests. That Delete failed with 403, and since the Backup finalizer uses the same helper, a Backup deletion could get stuck on it. The rule now includes delete. Nothing watches DeleteBackupRequests, so the sweep did not run again after Velero processed a request with errors. A Failed job now requeues every 5 minutes while a failed Velero backup of it remains, which replaces such a request, and every minute while one is still running, instead of every 5 seconds. Unit tests cover a rejected Failed status write, Completed, Deleting and FailedValidation backups, a request processed with and without errors, the UID precondition on the replacement, a Backup visible only to the uncached reader, and API errors from the helper. Refs: #5355 Assisted-by: LLM Signed-off-by: Andrey Kolkov <androndo@gmail.com> |
||
|
|
5fbf7e9a38 |
fix(backups): delete the Velero backup of a failed BackupJob
When a Velero strategy run ended Failed or PartiallyFailed, no Backup was created, and the Backup finalizer was the only code that asked Velero to delete backup data. The failed backup.velero.io object, labelled for the BackupJob but not owned by it, stayed in the bucket with its partial resources and logs until Velero's TTL (720h by default) expired it, and deleting the BackupJob did not remove it. The strategy now requests the deletion through a DeleteBackupRequest before it marks the job Failed, and the failure message is still read from the Velero backup first. A direct delete is not enough, because the BSL sync recreates the object from the object store. A reconcile of a Failed BackupJob, which used to return at once, now requests deletion of every Velero backup still labelled for the job. That retries a request that could not be created and removes backups that earlier versions leaked, after an upgrade. A Velero backup that a Backup references (the job failed after its Backup was created) is left alone, and one still running is polled until Velero accepts a request for it. The sweep matches on the job labels, so it also covers the Velero backup of a failed Kubernetes strategy run. The request is named after the Velero backup, and the Backup finalizer uses the same helper, so repeated reconciles converge on one request. Nothing is created while another request for the backup is pending. A request that Velero processed with errors is replaced, because Velero keeps it for a day and its name would block the retry until then. A job with more than one Velero backup now fails with a message that names them, not with an empty one. Fake-client unit tests cover Failed and PartiallyFailed runs, a repeated reconcile, leftovers of already Failed jobs (no request, a pending request, a request processed with errors, a Backup-referenced backup, a running backup) and the unchanged Succeeded path. Closes: #5355 Assisted-by: LLM Signed-off-by: Andrey Kolkov <androndo@gmail.com> |
||
|
|
a3e60ec372 |
feat(kafka)!: run on Strimzi 1.2.0 and Kafka 4.x (#4900)
<!-- 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 This upgrades the Kafka operator to Strimzi 1.2.0. Kafka 4.3 is the application default, with 4.2 also available. Upgrades must pass through Cozystack v1.7 and finish the ZooKeeper-to-KRaft migration first. The upgrade now stops while any Kafka lacks KRaft evidence. Every Kafka must report a nonempty `kafkaMetadataVersion` and the `KRaft` metadata state. The API conversion deletes that state, so without it a Kafka needs `Ready=True` or the `cozystack.io/kraft-verified` annotation, which migration 61 writes on every Kafka it accepts before it stops the operators. Any other explicit state blocks, and the error gives the reason for each Kafka. On every variant, the platform chart refuses to switch package sources while Strimzi still serves `v1beta2` and a Kafka fails that check. On variants without the migration hook, it also refuses while any Strimzi CRD still stores `v1beta2`, so `/migrations/61` has to run first. Migration 61 checks the same evidence again, including on repeat runs, and blocks unfinished broker-pool drains. A manual change that bypasses the managed package source is outside this check. Existing Kafka 3.x applications move to v4.3. Kafka 4 no longer accepts clients older than Kafka 2.1. Kafka 4 also rejects the topic settings `message.format.version`, `message.downconversion.enable` and `message.timestamp.difference.max.ms`, and a `segment.bytes` below 1 MiB (1048576), which Kafka 3.x accepted down to 14 bytes. A Kafka 4 broker whose log holds such a topic does not start. The chart now refuses to render a topic that sets any of these. The platform upgrade refuses to start while a Kafka application sets one, and migration 61 also checks KafkaTopic resources, so topics created outside the chart are caught too. A topic created through the Kafka admin API without a KafkaTopic is not visible to these checks. Restoring a topic-metadata backup taken on Kafka 3.x skips the three removed settings and raises a smaller `segment.bytes` to 1 MiB, with a warning for each. In-place downgrades are unsupported. The default 10-minute Helm timeout can leave a long broker roll Failed until its retry succeeds. The migration does not run automatically on every platform variant. Only the `isp-*` variants run it automatically. On other variants, run `/migrations/61` from the matching migrations image before upgrading, as the Kafka README describes. This includes clusters that run no Kafka but have the kafka-operator package, from the `paas` bundle or `bundles.enabledPackages`. Their Strimzi CRDs still store `v1beta2` even with no objects. The migration converts Strimzi resources and stored Helm references to `v1`. It stamps platform version 62. Running it manually also skips earlier migrations on a later move to an `isp-*` variant. Before it stops the operators, migration 61 refuses objects that the Strimzi 0.51 conversion tool would reject and names each one, for example a Kafka with `.spec.kafka.resources` or with OAuth, Keycloak or OPA settings. A failed conversion can leave the old operators stopped until the migration succeeds and the operator release upgrades. The failed conversion Job stays for diagnosis, but its ClusterRole, binding and ServiceAccount are removed. A Job that is still running when the wait times out keeps them, because the retry waits for it. Known limitations. Migration 61 converts with the old operator stopped, while Strimzi's conversion guide expects a running operator of 0.49 or later. I stop it because 0.45 keeps writing the Kafka status through `v1beta2`, but I have not checked this on a live cluster. Objects Strimzi created keep `ownerReferences` to `v1beta2` until Strimzi 1.2 reconciles them. Deleting a Kafka before that can leave dependents behind, and the chart's pre-delete hook covers only StrimziPodSets. The conversion image is pulled from quay.io by digest with no values override, so an air-gapped cluster has to mirror it under the same name. The full offline unit run passed on Linux on `1171d63adfafb45be34214fb9a0f565723e255fd`: 2,576 cases, no failures, errors or skipped tests. Later changes were checked on `69c704499fa4` with the Bats tests for migration 61, the migration runner, the Kafka hooks and the Kafka backup scripts (102), the platform Helm suite (310 tests) and the Kafka Helm suite (91 tests). After the rebase onto `main` at `5a5d5cd3d85f`, `a48a2f259947` passes the same Bats tests (115) and the platform and Kafka Helm suites (326 and 103 tests). It also passes the new check against added `documentIndex` selectors. I have not validated this revision on a live cluster. Closes #4365 ### 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. --> Not a UI change. ### 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: https://github.com/cozystack/website/issues/805 - [ ] [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: The Terraform provider does not model the Kafka `version` field. The website issue covers the upgrade notes the `default` variant needs. ### 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 feat(kafka)!: upgrade to Strimzi 1.2.0 and Kafka 4.3 by default, with Kafka 4.2 also available. Platform migration 61 converts Strimzi resources to v1 and moves Kafka 3.x applications to v4.3. Every Kafka must have confirmed KRaft state before the upgrade, including on repeat runs. Upgrade through Cozystack v1.7 first. Kafka 4 drops clients older than Kafka 2.1 and the message.format.version, message.downconversion.enable and message.timestamp.difference.max.ms topic settings, and requires segment.bytes of at least 1 MiB; the chart and the upgrade refuse a topic that breaks either rule, and a topic-metadata backup taken on Kafka 3.x restores without the removed settings and with segment.bytes raised to 1 MiB. In-place downgrades are unsupported. ``` |
||
|
|
7145a67568 |
fix(backups): stop leaking MariaDB dumps of stuck runs and torn-down namespaces
A k8s.mariadb.com/Backup the BackupJob gave up on stayed for good: no Backup is made of such a run, so nothing deleted it, and while it stood short of Complete the dump cleanup counted its open window as a possible writer of every later dump of the application and kept each of them. Every failure exit of a started BackupJob in the MariaDB driver now goes through failMariaDBBackupJob: the deadline, the application, MariaDB CR or strategy going away, a run the operator failed at Complete=False, and a run that could not be created. It lists the job's runs on the API server, where the cache can trail a run created or completed a moment ago, and deletes each one short of Complete under the UID and resourceVersion it read, so a run that completes in between is handed to the success path instead. Deleting the run takes its Job and pod, so what held the pod up is first copied into the failure message. A Running or expired job takes its run from that listing and never starts another, so a retry after a failed status write cannot start a second. During namespace teardown the operator Backup, which carries no finalizer, is usually gone before the Backup finalizer runs, and the cleanup, which read the storage from it, left the dump behind. A Backup that recorded its dump on the platform bucket now has it deleted with the platform credentials, which do not go with the namespace, reading the storage from the snapshot in status.underlyingResources; the dump is still kept when another run could have written it. The snapshot and the storage URI now record the storage the run was created with rather than the strategy as rendered at completion, which a strategy edited during the run would otherwise send the cleanup away from. Closes: #5291 Assisted-by: LLM Signed-off-by: Andrey Kolkov <androndo@gmail.com> |
||
|
|
2495ebfaa0 |
fix(postgres): restore from an archive with the access it was written with (#5295)
## What this PR does Stacked on #5221; review that one first. Once it merges this PR retargets to `main`. A CNPG restore took the destination path and endpoint of the source from the Backup artifact, but the credentials Secret, its key names and the endpoint CA from the CNPG strategy as it reads at restore time. Once the strategy pointed at another bucket or endpoint, the restore combined the recorded location with access settings meant for a different one, and recovery failed after an in-place restore had already purged the target Cluster. The destination record that #5221 annotates on the `cnpg.io/Backup` now also carries the key names and the CA, and the artifact copies them into `driverMetadata["cnpg.io/archive-access"]`. The size probe reads them from there too. The restore picks the access as follows: 1. While the strategy still points at the same endpoint and S3 bucket as the artifact, the strategy's access is used, exactly as before. WAL archiving keeps proving that access against the archive, and it carries any credential rotation since the backup, after which the recorded Secret may already be revoked. The prefix inside the bucket is not compared, since access is taken to be granted per bucket. 2. Once the archive has moved, the recorded access is used if its Secret and CA Secret exist and hold non-empty values under the recorded keys. 3. Otherwise the strategy's access is used, as before, with a `RecordedArchiveAccessUnavailable` Warning event on the RestoreJob. Credentials wider than one bucket can still read the old archive with it. An unreadable record fails the RestoreJob, and an error reading a Secret is retried, both before the HelmRelease is suspended and the target is purged. Artifacts written before this change keep working: one that records only the Secret uses it with the strategy's key names and CA once the archive has moved, and one without any record uses the strategy. This narrows the behaviour the issue asks for ("the recorded Secret, key names and CA, falling back to the strategy only for artifacts that carry no record") in two places, points 1 and 3 above, so that rotating credentials for an archive that has not moved, and deleting the old Secret after a move, keep working as they did. One case remains uncovered: a recorded Secret that still exists but whose keys were revoked, after the archive moved, while the strategy's credentials could still read the old bucket. ### Screenshots Not applicable: no UI change. ### Downstream repositories The diff touches only `internal/backupcontroller`: no CRD, values, chart or naming change, so nothing in the trigger map applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [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 ```release-note fix(postgres): restoring a Postgres backup after its CNPG strategy moved to another bucket or endpoint now reaches the archive with the credentials Secret, key names and CA the backup was written with, as long as those Secrets still exist; otherwise, and for an archive that has not moved, the strategy's current access is used as before. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Restore operations now use the access settings recorded with the backup when the archive destination has changed. * When recorded access settings are unavailable, the controller falls back to the current strategy settings and issues a warning. Invalid access metadata or Secret read errors stop the restore before the target is patched. * **New Features** * Backup records now retain the credential key names and CA reference used to access the archive. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
2cd41b411f |
fix(backups): read the Strimzi Kafka CR through the v1 API
Strimzi 1.x no longer serves kafka.strimzi.io/v1beta2, so the Kafka backup driver's readiness check would fail on every backup and restore. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
4f813fb6b2 |
fix(postgres): hold the WAL archive destination for backups no job tracks (#5294)
## What this PR does Stacked on #5221; review that one first. Once it merges this PR retargets to `main`. After #5221 a Postgres BackupJob writes the shared WAL archive destination only while no other running BackupJob of the application has a `cnpg.io/Backup` in flight. A `cnpg.io/Backup` that no running BackupJob tracks was not counted: one created by hand or by a `ScheduledBackup`, or one whose BackupJob was deleted or had already finished. A BackupJob using another BackupClass could then rewrite the destination while CloudNativePG was running such a Backup, leaving its base backup in one place and the WAL it needs in another, so the backup could not be restored. Such a Backup now holds the destination while CloudNativePG executes it, that is in the `started` and `running` phases (`BackupStatus.IsExecuting` in CloudNativePG 1.30). While a Backup of a Cluster is in one of those phases, CloudNativePG's own `BackupList.CanExecuteBackup` starts no other Backup of that Cluster, so the hold never lasts longer than the queue the operator already imposes and needs no separate deadline. A `pending` Backup does not hold, including one that ran before and was sent back to `pending`: CloudNativePG starts its base backup over against the destination current at that time. These Backups are found by `spec.cluster.name` in the controller's cache, because a Backup created by hand need carry no label. The waiting BackupJob reports `Ready=False` with reason `WaitingForUntrackedBackup` and names the Backup. ### Screenshots Not applicable: no UI change. ### Downstream repositories The diff touches only `internal/backupcontroller`: no CRD, values, chart or naming change, so nothing in the trigger map applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [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 ```release-note fix(postgres): a Postgres BackupJob no longer rewrites the WAL archive destination while CloudNativePG is running a backup of the same cluster that no BackupJob tracks, such as one created by hand or by a ScheduledBackup; it waits with reason WaitingForUntrackedBackup. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Prevented shared WAL archive destinations from being written while an untracked backup is actively running. * Pending and finalizing backups no longer hold the destination, and the destination becomes available again after the active backup completes. * Improved handling of backup status and retry conditions when multiple backups are in progress. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
526f08e17d |
fix(mariadb): restore the dump a Backup was taken as (#5227)
## What this PR does A RestoreJob that names a MariaDB `Backup` restored the newest dump of the application, not the dump of that `Backup`. The driver created the operator `Restore` with only `backupRef`, and mariadb-operator then restores the dump nearest to the moment the restore starts, from the prefix every run of the app shares. Restoring an older `Backup` brought back the latest data, and when its own dump was already gone it silently restored another one. The `Backup` now records the dump its operator `Backup` wrote, the file name in `k8s.mariadb.com/dump-file` and the timestamp from that name in `k8s.mariadb.com/dump-time`. They come from the ownership-proven match the size probe already makes, and nothing is recorded when ownership is not proven. A restore first checks with a bounded S3 listing of the operator `Backup`'s own storage that the dump still exists, then sets `targetRecoveryTime` on the operator `Restore` to the dump's own timestamp, which mariadb-operator matches exactly. If the dump is gone the RestoreJob fails and names it. If the check cannot be made it waits with `Ready=False/DumpCheckPending` until the restore deadline and then fails with the cause. `Backup`s taken before this stay restorable. The restore makes the same ownership-proven match against their operator `Backup` and pins the dump when it is provable, otherwise it restores the newest dump as before and a `BestEffortDump` warning event on the RestoreJob says so. One case is not covered: the `Backup`'s own dump is gone, a neighbour's dump from within the minute of slack is still there and its operator `Backup` was deleted, so that dump is taken as the match. Nothing in the platform deletes operator `Backup`s, it needs someone to delete one by hand. A `Backup` made of an operator `Backup` whose Job failed (`Complete` with reason `JobFailed`) has no dump, so its RestoreJob now fails instead of restoring another run's dump. Stacked on https://github.com/cozystack/cozystack/pull/5223 and targets its branch until that merges, only the last three commits belong here. Checked on a test cluster with mariadb-operator 25.10.2. An operator `Restore` of an older `Backup` with `targetRecoveryTime` set to its dump timestamp restored exactly that dump (`obtained target backup` names it and a row inserted after it is absent from the target), the same `Restore` without the target restored the newest one. Against the real bucket and operator `Backup`s the recording probe attributed to each `Backup` the dump its backup pod logged, the existence check passed for those dumps and refused a pruned one, legacy `Backup`s with a provable dump got pinned while back-to-back runs fell back with the warning, and the two failed runs on that cluster were refused. The controller itself was not run on the cluster, only its code driven by a test against the real bucket. Fixes https://github.com/cozystack/cozystack/issues/5196 ### Screenshots Not a UI change. ### Downstream repositories The diff is confined to the backup controller's Go code. It changes no CRD or API type (`driverMetadata` is an opaque map), no chart, values, package layout or `hack/` script, so no entry of the trigger map applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [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 ```release-note fix(mariadb): a RestoreJob now restores the dump of the Backup it names instead of the newest dump of the application. It fails with a clear message when that dump no longer exists in storage, or when the Backup was made of a failed backup run. Backups taken before this release are restored by the one dump that can be matched to them, or else, as before, by the newest dump, with a BestEffortDump warning event on the RestoreJob. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * MariaDB backups now record the selected dump’s filename and timestamp, allowing restores to target the corresponding recovery time. * For older backups without dump metadata, restores use a uniquely matched dump when possible or fall back to the latest dump with a warning. * Restore processing verifies recorded dumps, retries temporary storage checks, and reports failures for invalid or missing recorded dumps. * **Bug Fixes** * Deleting a MariaDB backup now removes its associated dump and operator backup when ownership is verified and no restore is active. Cleanup avoids deleting artifacts when it cannot safely identify them. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
f6f0be308f |
fix(postgres): restore a moved archive recorded without credentials
The postgres chart refuses to render bootstrap.enabled without a credentials Secret, so a restore that patched the target with the access recorded for an archive written without one failed at render time, after the target Cluster had already been purged. Before the access was recorded such a restore used the strategy's credentials, which can still read the old bucket. A recorded access without a credentials Secret now counts as unusable, like one whose Secrets are gone: the restore takes the strategy's access and says so in a Warning event. The tests that stop a restore on an unreadable record or a failed Secret read now also check that the target Cluster, its volumes and its HelmRelease are left alone. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
f12300943d |
chore: clear golangci-lint findings and handle the errors they flagged (#5306)
## What this PR does
This clears the golangci-lint findings on main and fixes the errors
several of them pointed at. With the default linter set (errcheck,
govet, ineffassign, staticcheck, unused), main had 197 findings when
this branch started. Rebased on main at
|
||
|
|
5d453c4d23 |
test(backups): give the fake S3 bucket a StatObject
main added StatObject to the object lister interface, so the fake bucket the MariaDB cleanup tests use has to implement it to compile. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
8a37a70681 |
Merge branch 'main' into fix/mariadb-restore-dump
Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
7c46e1e384 |
fix(backups): give the barman-cloud sidecar an explicit CPU limit (#5280)
## What this PR does The barman-cloud sidecar of Postgres backups is deliberately left without a CPU limit, so that a throttled sidecar slows WAL archiving down instead of failing it. In a tenant with `resourceQuotas` set that intent does not hold: `packages/apps/tenant/templates/quota.yaml` creates the `tenant-range-limits` LimitRange, whose default CPU limit is `250m`, and the sidecar receives it. Full backups and WAL segments are then gzip-compressed on a quarter of a core. On a production tenant the first full backup of a 1.6 GB database took 30 minutes, uploading at about 0.5 MB/s with the sidecar pinned at its 250m limit, while a small database on the same destination finished in 35 seconds. This sets an explicit `limits.cpu: "1"` on the sidecar, in the two places that build its configuration: `barmanSidecarConfiguration` in the backup driver (platform-managed ObjectStores) and `cozy-lib.barman.sidecarConfiguration` (ObjectStores rendered by the postgres and keycloak charts). This mirrors how the memory request and limit there already override the LimitRange's 128Mi default. One core removes the 250m ceiling without letting the sidecar starve the instance. Inside a tenant it counts against the `limits.cpu` quota, one core per instance pod; the comments now say so. The sidecar is injected when the instance pod is created, so existing instances pick the new limit up at their next restart. Tests: the Go test that asserted the absence of a CPU limit now asserts one core, and so does `packages/apps/postgres/tests/barman_resources_test.yaml`. Both fail with the implementation reverted and pass with it. `go test ./internal/backupcontroller/`, `helm unittest packages/apps/postgres` (220) and `helm unittest packages/system/keycloak` (121) pass. ### Screenshots Not a UI change. ### Downstream repositories Walked the trigger map against the diff (the backup driver, `cozy-lib`'s barman template, two tests): no app, value, schema, default, CRD, annotation or tooling change, so none of the listed repositories restates anything touched here. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [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 ```release-note fix(backups): the barman-cloud sidecar of Postgres backups now has an explicit one-core CPU limit instead of inheriting the tenant LimitRange's 250m default, which made full backups and WAL archiving several times slower. Each instance pod of a tenant with a CPU quota now counts 750m more against `limits.cpu`; check the headroom before instance pods are recreated. Existing ObjectStores pick the limit up at their next backup (platform-managed) or HelmRelease upgrade (chart-rendered), and running pods at their next restart. ``` |
||
|
|
6cab97f010 |
style: use tagged switches and drop unused test assignments
Use tagged switches where staticcheck suggests them and drop two test assignments whose values are never read. Behaviour is unchanged. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
87b794a992 |
chore: handle errors dropped in cleanup paths and tests
The drain tests now assert that RunThenDrain returns the run's nil error, the idle-tail test fails on any error other than the stream ending or being cut, and a test fixture file fails the test when it cannot be closed. Removing a temporary directory and closing a response body that has been read are best-effort: a failure leaves nothing for the caller to act on and does not change any result, so those errors are discarded explicitly. The same holds for the stub servers' response writes, whose failure surfaces on the client side of the test. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
906eeb2372 |
feat(backups): add Kubernetes backup strategy for tenant clusters (#4931)
## What this PR does
Adds a `Kubernetes` backup strategy so a tenant Kubernetes application
can be backed up and restored through the backups framework, and routes
`apps.cozystack.io/Kubernetes` to it in `cozy-default`.
None of the existing strategies fits a tenant cluster:
- Its API state is a key prefix (`/<namespace>_<release>/`, the
TenantControlPlane's datastore schema) in the etcd `DataStore` shared by
every cluster of the tenant. The `Etcd` strategy snapshots the whole
DataStore, so restoring it would roll every tenant cluster back at once.
- Its control-plane CA, front-proxy CA, service-account key and Talos
secrets cannot be regenerated: new ones break every node, kubeconfig and
token issued under the old ones.
- Its PersistentVolumes are DataVolumes in the tenant namespace
(`pvc-<tenant pvc uid>`, labelled `cluster.x-k8s.io/cluster-name`), and
deleting the application deletes them.
**Backup** (`strategy.backups.cozystack.io/Kubernetes`, driver in
`internal/backupcontroller/kubernetesstrategy_*.go`):
1. Checks the control-plane and Talos certificates and sets a
`CertificatesExpiring` condition (plus a Warning event) when a CA
expires before the backup's TTL or a leaf within
`certificateWarningThreshold` (720h). This never fails the run.
2. A Job in the application namespace dumps the cluster's prefix with
`etcdctl` to the platform bucket. It authenticates with the cluster's
own `kubernetes-<name>-datastore-certificate`, the one its
kube-apiserver uses. It runs on a new `kubernetes-backup` image (alpine
+ curl + jq + etcdctl matching the platform's etcd).
3. A Velero backup takes the PKI Secrets (selected by
`kamaji.clastix.io/name` / `app.kubernetes.io/instance`; the driver adds
the instance label to the cert-manager-issued Talos CA Secrets, which
carry neither) and the data DataVolumes/PVCs. Worker system disks are
not backed up.
4. The Backup records the prefix, the endpoints, the data DataVolumes
and the HelmReleases of the cluster and its `KubernetesNodes` pools. The
HelmReleases are not in Velero because the lineage webhook labels worker
disks after the same applications, so a label selector for the releases
would also pick the disks.
**Restore** goes into the application the backup came from (rename /
cross-namespace is rejected). `RestoreJob.spec.options` takes `etcd` and
`volumes` (both default `true`) to restore either half alone:
- **Application gone**:
1. Restore the PKI Secrets and the volumes.
2. Recreate the cluster's HelmRelease. The Kamaji release this repo
ships gives a new TenantControlPlane a UID-keyed datastore schema, so
the restore waits for that schema.
3. Stop the new control plane, write the dump under the new prefix (keys
are moved from the old prefix), and start it again.
4. Recreate the worker pools last, so workers join the restored cluster
with the restored CA and Talos secrets rather than an empty one.
- **Application live**: suspend the cluster's HelmReleases, then stop
the MachineDeployments and the cluster-autoscaler (for `volumes`,
deleting the backed-up DataVolumes/PVCs once the Machines are gone), and
then the KamajiControlPlane (for `etcd`). Workers go first because CAPI
removes a worker's Node through the tenant API. Then write the selected
halves back and restore every replica count. Each original count is
recorded on the object it belongs to, so the cluster is put back on
success, on failure, after a 30-minute stop deadline, and when the
RestoreJob is deleted midway. A retry keeps the counts from before the
first attempt, and a HelmRelease suspended before the restore stays
suspended.
Before changing anything, a restore checks that the Velero backup is
still there and Completed, and that the dump object exists (a
verify-mode run of the Job). The restore mode is recorded in the
RestoreJob's status, so a RestoreJob cannot claim that a live cluster is
gone.
Before it runs `del --prefix`, the restore Job downloads and validates
the dump and saves the current prefix to `<dump>.pre-restore`. That copy
is never overwritten, so a retry cannot replace it with a partial
prefix, and it is dropped after a successful restore. The Job writes a
marker to its termination message, and the outcome depends on it:
- A failure before `del` resumes the cluster.
- A failure after `del` leaves the control plane stopped
(`KubernetesEtcdWriteFailed`) rather than started on a partial prefix.
- Deleting the RestoreJob while its restore Job runs also leaves it
stopped.
Events and master leases are skipped only as top-level resources. Velero
cannot overwrite an existing claim, so a live-cluster volume restore
deletes the current claims first; this is documented.
A backup whose Velero half fails deletes the etcd dump it already
uploaded, and a transient error creating the Backup is retried rather
than failing the run. Deleting a Backup removes the Velero backup
(DeleteBackupRequest) and the dump object plus its pre-restore copy (a
cleanup-mode Job, given up after five failed attempts with a Warning,
plus the same skip-artifact-cleanup escape hatch as Redis/Rabbitmq).
With `velero.bslEnabled=false` the strategy is not rendered, and the
DefaultObjectsGate does not count it as missing, the same as the Velero
strategies. Like every default strategy, it is also gated on its CRD
being established, so the upgrade that first ships the CRD to an
installed chart cannot wedge the release.
Also included: RBAC for
TenantControlPlanes/DataStores/KamajiControlPlanes/MachineDeployments/Machines/Deployments,
chart values (`kubernetesBackupClientImage`,
`kubernetesBackupActiveDeadlineSeconds`, `kubernetesBackupResources`), a
`make image-kubernetes-backup` target, docs in
`docs/operations/backup-classes.md`, and the
`examples/backups/kubernetes/` walkthrough.
### Verification
- `go test ./internal/backupcontroller/`: the new tests cover:
- the certificate windows, pool HelmRelease discovery, option parsing
and the restore-phase selectors;
- the full backup path;
- in-place restores with default options and etcd only;
- a pre-suspended HelmRelease;
- a failed etcd write leaving the control plane stopped, including on
RestoreJob deletion;
- RestoreJob deletion resuming a stopped cluster;
- the stop deadline;
- the preflight: missing or incomplete Velero backup, missing dump;
- a rebuild, and an unreadable HelmRelease record;
- rename rejection, a non-etcd datastore, and the cleanup attempt limit.
Each safeguard in the Go driver was checked by mutating it out and
confirming that a test fails. The rendered Job script has no committed
test: a unit test would have to extract the script from the rendered
chart, and its behaviour belongs in the chainsaw e2e follow-up instead.
It was run against stub `etcdctl`/`curl` in every mode and branch:
- a foreign key or an empty value stops it before any etcd call;
- an S3 answer other than 200/404 on the pre-restore copy stops it
before any etcd call;
- an existing copy is kept, and a missing one is uploaded before `del`;
- keys are moved from the old prefix to the new one;
- an object in a namespace named `events` is kept.
- `helm unittest` (29/29), `hack/backupstrategy-crd-gate.bats` and `helm
lint` on `backupstrategy-controller`.
- On a live cluster (Velero 1.18.1), with a tenant cluster holding a
ConfigMap marker and a file on a PVC:
- The same flow done by hand before the driver existed: back up, delete
the application, rebuild. The CA, front-proxy CA, SA key and Talos
secrets were byte-identical afterwards, the pre-backup admin kubeconfig
still worked, namespace and ConfigMap UIDs were unchanged, and the PVC
data came back.
- Through this driver: the BackupJob succeeded (432 keys dumped, Velero
backup Completed, Backup metadata as described above). The tenant
namespace holding the markers was then deleted, which also deleted its
PVC and the backing DataVolume, and a RestoreJob with default options
rolled the live cluster back. It stopped the workers and then the
control plane, wrote the prefix back, restored the volume, and restored
the control plane to 2 replicas, the pool and the autoscaler to 1, and
unsuspended the HelmRelease. A new worker joined. The namespace came
back with its original UID, the ConfigMap and the PVC (bound to the same
volume) with their data. That run caught an ordering bug, now fixed and
covered by a test: scaling the control plane down first left the old
Machine stuck in `Deleting`, because CAPI removes the Node through the
tenant API.
- On the current head, through the driver, against the same tenant
cluster:
- **Backup.** It succeeded. The volume list it recorded was taken before
Velero started.
- **`{"volumes":false}` restore after a ConfigMap was deleted and
another created.** The deleted ConfigMap came back and the newer one was
gone. The worker was left running and the volume data was untouched. The
restore waited for terminating control-plane Pods before writing. The
pre-restore copy was saved before `del` and dropped afterwards.
- **Rebuild after the application was deleted, with default options.**
It ran the full sequence: secrets, volumes, cluster HelmRelease,
datastore schema, stop, etcd write, resume. It succeeded in about 3
minutes. The CA and Talos CA were byte-identical, a new worker joined,
and the namespace and ConfigMap UIDs and the PVC data were back. The
tenant cluster runs on a Kamaji that still names schemas `<ns>_<name>`,
so this run did not exercise a prefix change; that path is covered by
the unit tests and the stub runs.
### Not in this PR
- A chainsaw e2e. The tenant Kubernetes suites are bounded by tight op
budgets that tests pin, so the round trip needs its own suite or a
budget change; it will be a follow-up.
- `rotationPolicy` on the Talos CA Certificate in the kubernetes chart
(cert-manager's default `Always` would rotate the CA key at renewal).
- Restore into another application name or namespace.
- The tenant's shared etcd DataStore runs with auth disabled, so any
cluster's datastore certificate can read its neighbours' prefixes. This
predates this change; the dump Job uses the same certificate the
cluster's kube-apiserver already holds.
### Screenshots
N/A — no UI changes.
### Downstream repositories
- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[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:
Walked against the diff: no package under `packages/apps|extra` is added
or renamed, `packages/core/platform` and installer values are untouched,
the new CRD is in `strategy.backups.cozystack.io` (not typed by
terraform-provider), and `RestoreJob.spec.options` stays opaque JSON.
### Release note
```release-note
feat(backups): tenant Kubernetes applications can now be backed up and restored through the cozy-default BackupClass. A backup captures the cluster's etcd state and its control-plane PKI and PersistentVolume data, and warns when a control-plane CA would expire before the backup does. A restore rebuilds a deleted cluster with its original CA or rolls a live one back, and can restore the etcd state and the volumes separately via RestoreJob options `etcd` and `volumes`.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
- **New Features**
- Added Kubernetes application backup and restore support, including
etcd data and persistent volumes.
- The default backup class now routes Kubernetes applications to the new
strategy.
- Added an end-to-end walkthrough for creating a cluster, backing it up,
restoring it in place or after deletion, and cleaning up.
- Backup status can report expiring certificates, and restore validation
helps protect cluster identity and state.
- **Documentation**
- Added guidance on backup contents, restore behavior, and walkthrough
configuration.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
04fa87ccd1 |
style(backups): clear staticcheck findings in overlapping controllers
Drop a field-manager constant nothing uses in the MariaDB driver, switch on the MongoDB operator's state as a tagged switch, and reword the error strings of the MongoDB driver and the workload monitor so they do not start with a capital. The errors keep their meaning and nothing matches their text. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
4c3a4b42cc |
style: clear unused code and style findings reported by staticcheck
Remove helpers and constants nothing references, escape format characters in test literals, and take the simplifications staticcheck suggests where they read the same. Error strings no longer start with a capital: they keep their meaning, with the kind or component name moved out of first position. Callers match errors by type, not text; the one test that matches text, for Kafka, keeps the phrase it looks for. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
e978ed7f2f |
fix(postgres): stop backup jobs from fighting over the WAL archive destination (#5221)
## What this PR does Part of #5202. A second PR will restore the last good destination when a job that changed it fails. The ObjectStore a Postgres Cluster archives its WAL to is shared by every backup of the application, yet every running BackupJob server-side applied its own strategy's destination onto it every five seconds with forced ownership. Two BackupJobs of one application with different BackupClasses flipped the destination back and forth until the healthy backup failed too, and a webhook or apiserver blip during that apply failed the BackupJob at once. - A BackupJob writes the destination and the Cluster plugin only before its `cnpg.io/Backup` exists. Afterwards it only reads the live Cluster, and a failed read is returned for a controller retry instead of failing the running backup. - Before writing, a BackupJob waits, with a `Ready=False` / `WaitingForOtherBackup` condition naming the other job, while another running BackupJob of the application has a `cnpg.io/Backup` in flight. The wait is not capped, for the same reason as in #5211. The queue reads the Cluster's own Backups from the apiserver; with leader election one reconcile runs at a time, so only a leader handover can still let two jobs through. An atomic per-application claim is #4559. - Before writing, a BackupJob also checks the apiserver for a restore of its application and holds while one runs, including a job released from the queue: a write landing during the restore would put the restored Cluster back on the source's WAL prefix. - Write errors that cannot succeed on retry (invalid, bad request, forbidden) still fail the job at once. Any other is retried with a `ClusterPluginApplyRetrying` condition for the backup deadline, counted from the first failure since the job last waited, and recorded in a new `DestinationApplied` condition. - The pass that creates the `cnpg.io/Backup` records on it the destination, endpoint, credentials Secret and serverName it wrote (`backups.cozystack.io/cnpg-written-destination`), and the artifact and its size probe are built from that record, so a strategy edited, or a Cluster re-rendered, while the backup runs does not redirect the artifact. A Backup without the record falls back to the strategy as before. - The plugin rollout deadline and the instance check count from the write that attached the plugin, not from the job's start. The apply that attaches it also stamps the time on the Cluster (`backups.cozystack.io/barman-plugin-attached-at`), so a lost BackupJob status write after the attach does not fall back to an older time, and a job that starts while another job's recent attach is still rolling waits for that rollout too. A stamp a few minutes ahead of the controller's clock is waited out; one further ahead is treated as corrupt. Tests drive the reconciler through a running backup that must not rewrite the destination, the queue and its release, a restore starting while a job waits, each class of write error, a recovered write, a failed Cluster read while the Backup runs, lost status writes around the attach, another job's rollout, clock drift on the attach stamp, the recorded destination and serverName, and the rollout deadline. Each guard was checked by mutation. ### 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. --> - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [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(postgres): Postgres BackupJobs of the same application no longer overwrite each other's WAL archive destination: a job writes it only before its backup starts and waits while another backup or a restore of the application is in flight. A transient error while writing it is retried instead of failing the job at once, and the backup artifact names the destination and serverName the backup was actually written to. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Reliability** * CNPG backups wait while another backup or restore is using the shared destination, and retry temporary destination-write failures while observing the backup deadline. * Backup artifacts and size checks use the destination recorded when the backup was created, even if destination settings later change. * Backup processing handles plugin rollout timing and destination-hold release more consistently. * **Restore** * Restore operations account for shared WAL archive destination conflicts and guard against incompatible backup selections. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
a130813f44 |
fix(postgres): restore from an archive with the access it was written with
A CNPG restore took the destination path and endpoint of the source from the Backup artifact but the credentials Secret, its key names and the endpoint CA from the strategy as it reads at restore time. Once the strategy pointed at another bucket or endpoint, the restore combined the recorded location with access settings meant for a different one, and recovery failed after an in-place restore had already purged the target Cluster. The destination record on the cnpg.io/Backup now also carries the key names and the CA, and the artifact copies them. A restore uses them once the strategy points elsewhere and their Secrets still hold the keys; otherwise it keeps the strategy's access, as before, which credentials wider than one bucket can still read the old archive with. While the strategy points at the same endpoint and bucket its own access is kept: WAL archiving keeps proving it against that archive, and it carries any rotation since the backup, after which the recorded Secret may already be revoked. The size probe reads the recorded access too. An unreadable record fails the restore before the purge instead of falling back. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
9bd8d12cb8 |
fix(postgres): hold the WAL archive destination for backups no job tracks
A BackupJob rewrote the shared WAL archive destination while a cnpg.io/Backup of the Cluster was running if nothing tracked that Backup through a running BackupJob: one created by hand or by a ScheduledBackup, or one whose BackupJob was deleted or had already finished. The base backup then stayed where it started while the WAL it needs went to the new location, and the backup could not be restored. Such a Backup now holds the destination while CloudNativePG executes it. Only the phases in which CloudNativePG itself starts no other Backup of the Cluster count, so the hold never outlasts the queue the operator already imposes: a Backup that waits in pending, or was sent back to it, starts its base backup over against the destination current then. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
583f18437d |
test(clickhouse): give the credentials-wait BackupJob a UID
The test pins that a backup held for late bucket credentials keeps its archive name, and a run's archive name now carries part of the BackupJob's UID, so the fixture needs one for the name it expects to be the name the controller mints. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
dae76d186c |
Merge branch 'main' into fix/clickhouse-idle-before-backup
main pins the archive name a backup Pod keeps across a wait for late bucket credentials, against the controller's archive helper. That helper now names a run's archive with part of the BackupJob's UID, so the merged test has to give its BackupJob one. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
5c6fc10a23 |
test(postgres): pin three guards no test caught when changed
A job whose own Backup exists skips the wait for another job's plugin rollout, and the size probe keeps the strategy's Secret key names while it takes the Secret from the record, adding a credentials block only when the strategy has none. Each of these could be changed with the suite still green: dropping the own-Backup check, or forcing the missing-credentials branch either way. Cases for a job with a running Backup next to a recent foreign attach, a strategy without credentials and a strategy with custom key names now fail on each change. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
b3ca798bc4 |
fix(backups): read the runs that may own a MariaDB dump uncached
Before deleting a dump the cleanup checks every other operator Backup on the same prefix that could have written it, and it read them from the informer cache. A run whose operator Backup had not reached the cache yet but had already uploaded its dump was missed, and its dump deleted as this Backup's. Both the recorded and the legacy paths now list the runs from the API server, as the restore checks already do. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
238b3ee491 |
fix(seaweedfs): enforce S3 bucket lifecycle rules (#5228)
<!-- 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 SeaweedFS accepts and stores an S3 bucket lifecycle configuration, but only the `s3_lifecycle` job of its plugin worker applies it, and that job is scheduled by the admin server. Cozystack deployed neither, so a lifecycle rule returned 200 and no object ever expired, on the platform backup bucket and on tenant buckets alike. That also made the documented way to bound backup storage a no-op. This PR adds the admin server and a worker to Simple and MultiZone SeaweedFS instances, behind a new `lifecycle.enabled` value that is **off by default**. A Client instance is unchanged, because its rules are enforced where the instance it connects to runs. The worker registers for `s3_lifecycle` only, so vacuum, balancing and erasure coding are not started as a side effect. The admin keeps its job state on a 1Gi volume on `lifecycle.storageClass`, or on the cluster default when that is empty; `volume.storageClass` is not reused, because in MultiZone it can name a class local to one zone or node. The admin UI is protected by a generated password, because a tenant namespace admits traffic from the whole cluster. The dashboard Role lists the two new WorkloadMonitors. Enabling the worker alone was not enough on SeaweedFS 4.45. Its chart renders no `[grpc.s3]` section, so the s3 gateway served its internal gRPC in plaintext while the worker dials it with mTLS, and every lifecycle delete failed the TLS handshake. The section is backported from upstream (seaweedfs/seaweedfs#11157, released in 4.46) as a chart patch, applied with `--forward` so the next `make update` stops at the point where the patch must be dropped instead of silently reversing it. The s3 pods are restarted once so they load the section. This also repairs IAM cache propagation between s3 replicas, which failed in the same way, and it applies whether or not lifecycle is enabled. The data-plane release now retries a failed install or upgrade in place (`RetryOnFailure`) instead of rolling it back. With the previous default remediation and unlimited retries, an upgrade that waited out its timeout, for example on a tenant quota with no room for the admin volume, rolled back and retried forever, restarting the s3 pods twice per cycle. The worker's hostname anti-affinity is relaxed to a preference so a rollout finishes on a single-node cluster. #### Why lifecycle is off by default The daily walk that SeaweedFS uses to expire objects sends its deletes without an object identity, and the s3 server skips its compare-and-swap when no identity is given; it does not re-check the object's age either. A key overwritten between the walk's listing and the delete loses its new content. This path is unchanged from 4.45 through 4.52 and on upstream master (`weed/s3api/s3lifecycle/dailyrun/walker_dispatcher.go`, `identityMatches` in `weed/s3api/s3api_internal_lifecycle.go`). Backup buckets write unique keys and are barely exposed; a tenant bucket that rewrites a fixed key is. On top of that, turning enforcement on would start applying, on upgrade, every rule that was stored and ignored until now. Both are retention changes an operator should choose, so nothing changes for existing instances until `lifecycle.enabled` is set. Making it the default again is left to a separate PR that carries object identity on the walk path; upstream report: https://github.com/seaweedfs/seaweedfs/issues/12451. #### Turning lifecycle on and off When `lifecycle.enabled` is set, rules that have been stored but ignored start applying within minutes, and objects they have already expired are deleted on that first pass, so review existing bucket lifecycle rules first. Set `lifecycle.storageClass` before enabling, and prefer a replicated class: the class is part of the admin StatefulSet's volume claim template, which cannot change, so changing it while lifecycle is on makes every upgrade of the instance fail until it is reverted. Moving the volume means disabling lifecycle, deleting the `admin-data-seaweedfs-admin-0` PVC, changing the class and enabling lifecycle again. Each instance gains two small pods and a 1Gi PVC; when the tenant quota has no room for them, the data-plane release keeps retrying in place until it has. When `lifecycle.enabled` is turned off again, the parent release removes the admin credentials Secret while the data-plane release removes the admin StatefulSet only on its own reconcile, shortly after. An admin pod that restarts in that window fails to start on the missing Secret until the StatefulSet is gone; nothing is lost, and the order is left as is. The admin PVC stays until the instance is deleted, and a later re-enable starts the admin with a new password. Verified on a test cluster with the 4.45 chart: without the backport, the worker found the expired objects and every delete failed with `tls: first record does not look like a TLS handshake`; with this branch and lifecycle enabled, a rule with a past expiration date removed the matching objects and left the others, both on a manual run and on the first scheduled pass. ### 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 - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up needed, not opened yet: `operations/services/backup-classes.md` (v1.7 and next) advises an S3 lifecycle policy, which the bundled SeaweedFS applies only once `lifecycle.enabled` is set; the SeaweedFS reference page gains `lifecycle.enabled` and `lifecycle.storageClass` from the regenerated README on the next release - [ ] [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: The terraform provider does not model the SeaweedFS application, so the new values do not reach it. ### 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(seaweedfs): S3 bucket lifecycle rules can now be enforced. Simple and MultiZone SeaweedFS instances run the SeaweedFS admin server and a lifecycle worker when the new `lifecycle.enabled` value is set; it is off by default, so existing instances keep their current behaviour. It stays off by default because the upstream daily expiry walk deletes without checking that the object it listed is still the one stored, so an object overwritten in that window can be deleted although it is new. When enabled, rules that were stored but ignored start applying within minutes and objects they have already expired are deleted on that first pass; review existing rules first. Each enabled instance gains two small pods and a 1Gi volume, placed on `lifecycle.storageClass` or the cluster default. Independently of the switch, the s3 gateway now serves its internal gRPC over mTLS, which repairs IAM cache propagation between s3 replicas and restarts the s3 pods once on upgrade. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added optional, daily S3 bucket lifecycle-rule processing for supported SeaweedFS configurations. It is disabled by default; Client instances rely on lifecycle rules configured on the connected SeaweedFS. * Added configurable storage for lifecycle job state and dashboard visibility for lifecycle components. * Enabled the S3 gRPC server to use its internal TLS identity when security is configured. * **Bug Fixes** * Improved storage-class handling so numeric-looking names remain strings and unset classes are omitted where appropriate. * Clarified backup cleanup guidance, including when lifecycle rules apply and how to reclaim storage. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
3badbdef74 |
fix(clickhouse): let a running backup sidecar pick up system-bucket credentials (#5232)
<!-- 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 A ClickHouse release with `backup.useSystemBucket: true` can start before the platform projects `cozy-backups-creds` into its namespace. Its `clickhouse-backup` sidecar took the S3 settings from environment variables, which are fixed when the container starts, so the first BackupJob or RestoreJob of such a release failed with `no EC2 IMDS role found` until the Pod was restarted, and a rotated key stayed stale the same way. The projector now also writes a `clickhouse-backup.yml` key into `cozy-backups-creds` (bucket, `https://` endpoint, region when set, keys, `force_path_style` from `backupStorage.forcePathStyle`). On the system-bucket flow the chart mounts that key as an optional Secret volume and points `CLICKHOUSE_BACKUP_CONFIG` at it, instead of setting `S3_*` variables. clickhouse-backup reloads its config file in each API handler that reaches S3 (among them the `create_remote`, `restore_remote` and `list` calls the strategy makes; the `status` and `actions` reads it polls with do not) and kubelet rewrites a mounted Secret in place, so credentials projected after the Pod started, or rotated since, reach the running sidecar. `S3_PATH` stays in the environment because the prefix belongs to the release. Kubelet takes about a minute to refresh the volume, so the projector stamps `backups.cozystack.io/credentials-updated-at` when the projected content changes, and the Altinity driver holds a new backup or restore Job for up to two minutes after that stamp, with `Ready=False` and reason `WaitingForCredentials`; the condition is dropped once the Job runs. A stamp that cannot be read, or one further ahead than clock skew explains, is logged and ignored rather than holding the namespace's jobs for good. The hold applies to every Altinity job in a namespace whose projected Secret just changed, including releases on their own Secret, where it is only a delay. The new e2e Test `clickhouse-3-system-bucket-roundtrip` starts a ClickHouse on the system bucket with no projected Secret, then runs a backup and an in-place restore through `cozy-default` and checks that the sidecar that started without credentials served both jobs. In CI the system bucket's advertised host `s3.example.org` neither resolves nor gets an ACME certificate, so for the duration of its own step the Test serves a SeaweedFS-CA certificate under the S3 Ingress TLS Secret name and adds a marked `rewrite name exact` line for that host to the host CoreDNS Corefile, removing both on exit; it proves the served certificate before any job starts. The bug was reproduced on a test cluster running the code before this change: a ClickHouse started before the projection failed its first BackupJob with `no EC2 IMDS role found`. The new e2e Test has not run green yet outside CI, because it edits the host CoreDNS, which is shared on that cluster. ### 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#799 (draft until this PR merges): `operations/services/backup-classes.md` for the mounted config file, the credentials wait and the upgrade window, without the Pod restart this change removes - [ ] [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 release on the platform system bucket (`backup.useSystemBucket: true`) now backs up and restores without a Pod restart when its namespace had no projected backup credentials at start, and picks up rotated credentials while running. The sidecar reads its S3 settings from a `clickhouse-backup.yml` file in `cozy-backups-creds` instead of environment variables, so the upgrade rolls every such ClickHouse Pod once. The first Altinity backup or restore in a namespace after its projected credentials change waits up to two minutes (`WaitingForCredentials`) for them to reach the sidecar. Upgrade the platform as a whole: a system-bucket BackupJob started while the new chart runs against the previous controller fails, because that controller does not write the new key. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * ClickHouse system-bucket backups now use a projected configuration file for S3 settings, supporting HTTPS endpoints and optional region and path-style settings. * Backup and restore jobs wait briefly for recently updated projected credentials before starting. * Path-style settings accept common true and false values and are normalized consistently across backup storage integrations. * **Tests** * Added end-to-end coverage for system-bucket backup and restore, verifying restored data without restarting the ClickHouse Pod or backup sidecar. * Added checks for TLS certificate validation and safe restoration of shared network and ingress settings. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
1d22013646 |
fix(postgres): hold a backup until the plugin sees its new destination
The plugin-barman-cloud sidecar reads the ObjectStore through its own cache, kept for ten seconds (DefaultTTLSeconds in plugin-barman-cloud v0.13.0) and invalidated only by the sidecar's own writes, and WAL archiving keeps it warm. The pass that changed the destination created the cnpg.io/Backup a moment later, so the base backup could be taken against the previous destination while the artifact names the new one, and a restore from it finds nothing. On a live cluster with the shipped plugin, a Backup created two to four seconds after switching the destination landed in the old bucket in two of three tries; with a fifteen second wait it landed in the new one every time. The apply that changes the ObjectStore configuration now stamps the time on the ObjectStore itself, so the record cannot be lost apart from the change, and the job creates its Backup only once that change is older than the cache can be. A change is judged on the configuration a server-side dry run of the same apply returns, so values the apiserver defaults or another field manager owns do not read as a change on every pass. That wait leaves a job with the destination written and no Backup yet, which the queue, looking only for Backups in flight, did not see: a second job with another destination wrote its own, the first took that as a change and stamped again, and the two restarted each other's wait forever. Every apply of the ObjectStore therefore also names the job that made it, which only a job without a Backup of its own and let through by the queue does, and the queue holds every other job while that one runs and has no Backup yet. Once it has one, that Backup holds the destination for as long as CloudNativePG runs it, as before, so a job stuck after its Backup finished does not hold every later backup of the application. This also covers a job waiting for the rollout of the plugin it attached, during which a second job used to switch the destination as well, including when its own write left the configuration as a restore had re-rendered it. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
5a95bcdd64 |
fix(clickhouse): keep a run's archive name within the old name's length
The archive name is part of every object key, a key is capped at 1024 bytes, and the legacy s3PathOverride prefix has no length limit. The full UID made the name 37 characters longer than before, so a prefix that fit the old name pushed the manifest key past the cap and failed the backup. The run's name now drops "clickhouse-" and the "T" and "Z" of the timestamp and spends the room on the first 12 hex digits of the UID, so it is exactly as long as the old name for every application. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
a6a704768c |
test(backups): pin a failed RestoreJob listing in the MariaDB cleanup
A RestoreJob listing that fails says nothing about whether a restore reads the dump. Swallowing that error left the whole suite green, while it would let the cleanup delete the dump under a running restore. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
f2507b4b84 |
docs(backups): name what the MariaDB cleanup reads uncached
The reader's comment named only RestoreJobs, and the restore path said the cleanup holds a Backup only for RestoreJobs it can see, while the cleanup now lists both RestoreJobs and operator Restores straight from the API server. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
0195a66fae |
fix(backups): release a MariaDB Backup when the operator CRDs are gone
Listing the operator Restores of a Backup before reading its operator Backup made the cleanup fail on a cluster without the mariadb-operator CRDs, retried for good, so the Backup and its namespace never went away. The operator Backup read that follows already releases the Backup in that case; with no Restore kind no restore can run, so the listing now lets the cleanup reach it. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
8246808289 |
fix(backups): hold a MariaDB dump while an operator Restore reads it
The cleanup waited for a restore by the phase of its RestoreJob, but the phase is not the restore: a RestoreJob fails on its deadline while the operator Restore it created keeps running, and that Restore still reads the dump. Deleting the dump then made mariadb-operator restore the nearest other one. The cleanup now also holds the Backup while an operator Restore of its operator Backup has not been marked Complete, which mariadb-operator does once the Restore's Job has completed or failed, so what keeps the dump is the restore that reads it rather than the status of the request. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
ee6404a0c8 |
fix(backups): retry a failed lookup of a MariaDB operator Restore
The lookup now goes to the API server, which can time out or throttle, and a failed lookup failed the RestoreJob. It says nothing about whether the operator Restore exists, so the RestoreJob could be failed while its Restore was running, and the Backup's cleanup would then stop waiting for it and delete the dump the Restore reads. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
14a842ad16 |
fix(backups): find a MariaDB operator Restore the cache has not seen
The MariaDB restore creates its operator Restore once and then follows it, finding it by label in the informer cache. Nothing watches operator Restores, so a reconcile that ran before the new Restore reached the cache saw none: it created a second one, or, now that a restore refuses a Backup being deleted, failed the RestoreJob while its Restore was still running, after which the cleanup deleted the dump that Restore was reading. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |