mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
e41d10df6fc65f73d660f719acfecb7cb616fd97
7886
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e41d10df6f |
fix(postgres): keep users.app's password across pod restarts (#4984)
## What this PR does
A Postgres app that declares a user named `app` loses that user's
password every time its pod restarts. Clients keep the password
advertised in `<release>-credentials` and start failing with `password
authentication failed for user "app"`, with nothing changed on their
side.
`app` is the owner role CNPG bootstraps, with a generated password in
`<release>-app`, and a declared `users.app` adopts that role (the
init-script says so). The init-job sets the role's password from
`<release>-credentials`, but CNPG's instance manager re-applies the
owner's password from the bootstrap secret whenever it meets a secret
version it has not applied yet (`refreshCredentialsFromSecret` →
`reconcileUser` in
`internal/management/controller/instance_controller.go`). Its cache is
in memory, so every pod start re-applies `<release>-app` and silently
undoes the init-job. Only releases whose two secrets happen to differ
break, which is every release where `users.app` was declared at
creation.
This PR renders a `<release>-app-owner` basic-auth Secret from the same
password `<release>-credentials` holds, and sets
`spec.bootstrap.<method>.secret.name` to it, so both writers agree on
one value. CNPG resolves the owner secret through that field before
falling back to `<release>-app`, never rewrites the data of a secret it
does not own, and its webhook accepts a bootstrap change on an existing
Cluster. The secret goes on the method the live Cluster was bootstrapped
with, read through `lookup`, because CNPG rejects two methods and a
restored Cluster keeps `bootstrap.recovery` in its live spec. A release
with no `users.app` renders exactly what it rendered before, and a
restore in progress (`bootstrap.enabled`) is left alone, since the chart
flags its credentials as pending until the init-job runs.
We hit this in production: the cluster-wide pod restart of a platform
upgrade broke two of the four apps that declare `users.app`; the two
others survived only because their two secrets held the same value.
`tests/app_owner_secret_test.yaml` covers the shared password (preserved
and freshly generated), the initdb and recovery methods, a release
without `users.app`, and an in-progress restore. Without the template
change, 5 of its 8 tests fail. The full chart suite passes (217 tests).
### Screenshots
Not a UI change.
### Downstream repositories
Walked against the diff: two templates and one test file under
`packages/apps/postgres`. No package is added or renamed, `values.yaml`,
`values.schema.json` and `README.md` are untouched, and no output Secret
or Service is renamed (a new Secret is added; the Terraform provider
reads only `-credentials`, `-rw` and `-ro`).
- [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 user named `app` no longer loses its password when the Postgres pod restarts. CNPG re-applied its own generated password to the `app` owner role on every pod start; the chart now hands CNPG the password stored in `<release>-credentials`.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
- **New Features**
- Added owner credentials when the `app` user is configured.
- PostgreSQL clusters now use those credentials during initialization or
recovery, while preserving compatible recovery settings for restored and
actively recovering clusters.
- **Bug Fixes**
- Ensured generated or existing `app` passwords are reused for owner
credentials.
- **Tests**
- Added coverage for credential reuse, password generation, omitted-user
behavior, and cluster recovery scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Backported-from:
|
||
|
|
42fa67a1e2 |
docs(gateway): stop saying the route-hostname policy admits hostname-less routes (#5352)
## What this PR does
Refs #4938
The edge-termination section of `packages/extra/gateway/README.md` said
that on a class sharing one edge address the class controller has to
keep route hostnames inside the tenant apex, "since the platform's
route-hostname policy admits routes that declare no hostnames at all".
That stopped being true in 1.7.
`packages/system/cozystack-basics/templates/route-hostname-policy.yaml`
now requires `spec.hostnames` to be present and non-empty for
`HTTPRoute`, `TLSRoute` and `GRPCRoute` in `tenant-*` namespaces
(#3475), and it rejects any hostname outside the namespace's
`namespace.cozystack.io/host` apex. The policy doesn't depend on the
Gateway class. This PR replaces the sentence with one that says so and
links to the policy's entry under "Security model".
This fixes only the line the issue points at. I didn't audit the rest of
the README against the code, so I used `Refs` and not `Closes`. The
issue asks for that full review, and it should stay open for it.
`make generate` (cozyvalues-gen) only rewrites the parameter table, and
this change doesn't touch it.
### Screenshots
Not a UI change.
### Downstream repositories
I left every box below unticked on purpose. The only downstream copy of
this text is the Gateway reference page on cozystack/website. Per
`docs/agents/contributing.md`, the release bot regenerates that page
from this README on the next stable tag, so I don't think any manual
follow-up is needed. A maintainer should confirm that.
- [ ] 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
docs(gateway): the Gateway README no longer says the route-hostname policy admits routes without hostnames; since 1.7 it rejects them in tenant namespaces.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Documentation**
* Clarified that the route-hostname policy applies to `HTTPRoute`,
`TLSRoute`, and `GRPCRoute` resources in `tenant-*` namespaces on
creation and update. It rejects routes with no hostnames or hostnames
outside their namespace’s apex. Routes stored before the policy is
installed are not rejected unless they are subsequently updated.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Backported-from:
|
||
|
|
e3b200e8d8 |
fix(postgres): keep users.app's password across pod restarts
CNPG bootstraps an "app" owner role with a generated password stored in
<release>-app, and a declared users.app adopts that role. The init-job
then sets the role's password from <release>-credentials, but CNPG's
instance manager re-applies the owner's password from the bootstrap
secret whenever it meets a secret version it has not applied, which
includes every pod start. Any restart therefore reverts users.app to
CNPG's generated password, and clients holding the advertised one get
"password authentication failed" with nothing changed on their side.
Render the owner's bootstrap secret from the same password the
credentials Secret holds, and point the live bootstrap method at it, so
both writers agree on one value.
Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
(cherry picked from commit
|
||
|
|
c214b9deb1 |
fix(securitygroups): reject port ranges and malformed FQDNs on the SecurityGroup path (#5134)
<!-- 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
Fixes #5130.
`validatePortRules` sent any non-numeric port to `IsValidPortName`, so
`"80-90"` came back as "must contain at least one letter (a-z)". A
`first-last` value now gets "port ranges are not supported; list each
port as its own entry" on the same field. `PortProtocol` carries a
single port and Cilium's `endPort` is not exposed, so the limit itself
is unchanged.
`validateFQDNs` only checked that a selector was not empty. A malformed
`matchName` or `matchPattern` passed, and the backing write then failed
on the CiliumNetworkPolicy CRD, which surfaced as an error about a
`cilium.io` object. The validator now applies the CRD's own rules for
`spec.egress[].toFQDNs[]`, with a field error on the SecurityGroup path:
`^([-a-zA-Z0-9_]+[.]?)+$` for `matchName`, `^([-a-zA-Z0-9_*]+[.]?)+$`
for `matchPattern`, `maxLength: 255` for both, and the `oneOf` that
allows only one of the two per selector. These are copied from the CRD
served by Cilium 1.19.5 and match the agent's `FQDNSelector.sanitize`,
which also refuses a selector that sets both fields.
`TestCreateRejectsInvalidPortOrFQDN` lists each rejected value and
checks that the error carries a single cause, on the expected field,
with the expected reason. All 13 cases fail on `main`.
`TestCreateAcceptsValidPortOrFQDN` lists accepted values (named port
`http-8080`, trailing dot, underscore labels, `**.` prefix, infix and
lone `*` patterns, 255 characters) and checks they project 1:1. `go test
./pkg/registry/sdn/...` passes.
As a cross-check, every FQDN value in both tables was also sent to the
CiliumNetworkPolicy CRD of a lab running Cilium 1.19.5, with `kubectl
create --dry-run=server`. The CRD rejects exactly the values the
validator rejects and accepts exactly the ones it accepts.
### 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
The diff touches `pkg/registry/sdn/securitygroup/validate.go` and its
tests only: the SecurityGroup schema does not change, and no package,
chart, CRD, `hack/` or convention is touched. Neither the website nor
the Terraform provider documents or models SecurityGroup fields.
<!--
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(securitygroups): a port range now gets a clear "port ranges are not supported" error, and a malformed toFQDNs matchName or matchPattern is rejected on the SecurityGroup field instead of failing on the backing CiliumNetworkPolicy.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Security group egress rules now reject port ranges with a clear
validation error; list each port separately.
* FQDN selectors are checked for supported name or pattern formats,
required selector fields, and a maximum length of 255 characters.
* Invalid egress settings are rejected without creating a policy, while
valid ports and FQDN selectors can be saved.
* **Documentation**
* Updated guidance to reflect egress port and FQDN validation rules.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Backported-from:
|
||
|
|
f6c5ec8527 |
docs(gateway): stop saying the route-hostname policy admits hostname-less routes
Since 1.7 cozystack-route-hostname-policy requires spec.hostnames to be
present and non-empty on HTTPRoute, TLSRoute and GRPCRoute in tenant-*
namespaces, so the edge-termination section no longer matches the
platform. The website builds its Gateway reference page from this
README, so the stale sentence would be published as is.
Refs: #4938
Assisted-by: LLM
Signed-off-by: Adham Kiwan <adhamkiwan@outlook.com>
(cherry picked from commit
|
||
|
|
bda0ddac6a |
docs(securitygroups): record the port-range and FQDN validation in the design
The design still listed FQDN matchName/matchPattern syntax as deferred
and passed through to Cilium. Create and update now reject a malformed
selector, a selector setting both fields and a port range on the
SecurityGroup path, so the deferred list keeps only cross-rule
consistency.
Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
(cherry picked from commit
|
||
|
|
9767340062 |
fix(securitygroups): reject port ranges and malformed FQDNs on the SecurityGroup path
A port such as "80-90" fell through to the named-port check and was
refused because it "must contain at least one letter", which says
nothing about the actual limit: a SecurityGroup port carries one port,
and Cilium's endPort is not exposed.
FQDN selectors were only checked for being non-empty. A malformed
matchName or matchPattern passed validation and was then refused by the
CiliumNetworkPolicy CRD on the backing write, so the tenant got a schema
error about an object they never wrote. Apply the CRD's own rules
instead: its two patterns, its 255-character limit, and its oneOf
between matchName and matchPattern.
Fixes #5130
Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
(cherry picked from commit
|
||
|
|
664120d688 |
fix(backups): delete the Velero backup of a failed BackupJob (#5364)
<!-- 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 #5355
A BackupJob whose Velero backup ends `Failed` or `PartiallyFailed`
leaves that `backup.velero.io` object and its data in the backup bucket
(partial resources, logs) until Velero's TTL expires it, 720h by
default. No `Backup` is created for a failed run, and the `Backup`
finalizer was the only code that asked Velero to delete backup data;
deleting the BackupJob does not remove it either, because the Velero
backup is only labelled for the job, not owned by it.
The first commit requests deletion of the failed Velero backup through a
`DeleteBackupRequest`, and turns the reconcile of a `Failed` BackupJob,
which returned at once, into a sweep over the Velero backups still
labelled for the job. That sweep also cleans up backups leaked by
earlier versions after an upgrade. The request creation is shared with
the `Backup` finalizer and named after the Velero backup, so repeated
reconciles converge on one request. The failure message is unchanged.
The second commit narrows that sweep and makes it converge:
- Only `Failed`, `PartiallyFailed` and `FailedValidation` Velero backups
are deleted. A `Completed` one is never touched from a job-level
failure: a job can fail after Velero completed (creating or recording
the `Backup` failed), and that Velero backup may be the only copy of
good data.
- Deletion is requested only after `Failed` is persisted. The strategy
no longer sends the request inline, so a failed status write cannot
leave a retried run without the backup it reports the failure from. The
BackupJob watch has no predicate, so the `Failed` status update itself
triggers the sweep.
- While a failed backup still exists, the job is requeued every 5
minutes. Nothing watches `DeleteBackupRequest`, so this is how a request
Velero processed with errors is noticed and replaced. A backup that is
still running is rechecked every minute.
- Backups that reference the Velero backup are read through the uncached
API reader before anything is deleted.
- The ClusterRole of `backupstrategy-controller` gains `delete` on
`deletebackuprequests`, needed to replace a processed-with-errors
request. The `Backup` finalizer shares the helper, and without the verb
that path would fail with 403.
The third commit makes a deletion that Velero could not finish converge,
and makes it visible:
- A Velero backup in `Deleting` goes through the same request path.
Velero sets that phase before it removes the data and leaves it there
when removal fails, so skipping it left the data in place until the TTL.
- Our own request that Velero processed while the backup still exists is
replaced, whether it carries errors or not. The second case is a backup
that the BSL sync brought back.
- Each replacement emits a `VeleroBackupDeletionFailed` Warning event on
the BackupJob with Velero's `status.errors`, and doubles the wait before
the next replacement, 5 minutes up to 1 hour (enforced from the recorded
attempt time since the fourth commit). The count is kept in the
`backups.cozystack.io/velero-deletion-retries` annotation on the
BackupJob. A missing, read-only or unavailable BSL therefore shows up in
`kubectl describe` instead of being retried silently every 5 minutes.
The fourth commit makes the backoff binding rather than advisory:
- Each request the sweep creates records its time in the
`backups.cozystack.io/velero-deletion-attempted-at` annotation, next to
the retry counter. A request Velero has processed is replaced only once
the backoff for the current retry count has passed since that time.
Writing the annotations triggers a reconcile at once, because the
BackupJob watch has no predicate; that reconcile now only computes the
remaining wait. Before, with a BSL that fails instantly, it could
replace the request again right away.
- A request Velero has not processed yet, and a Velero backup still in
`New` or with no phase, are checked again after as long as they have
already waited: between 5 minutes (1 minute for a running backup) and 1
hour. Waiting emits no event.
- If the job was deleted before the annotations are written, the sweep
stops quietly. Any other error writing them is logged, and the computed
requeue is kept, because the request already exists.
Points for the reviewer:
- The sweep matches on the BackupJob labels, not on the strategy kind,
because a `Failed` job's BackupClass may be gone. The Kubernetes
strategy labels its Velero backup the same way and has the same leak on
failure, so a failed Kubernetes strategy run is cleaned up by the sweep
as well.
- The Velero strategy still treats a `FailedValidation` Velero backup as
in progress and requeues the BackupJob indefinitely. That is unchanged
here; the sweep already treats `FailedValidation` as deletable.
- After the upgrade, the Velero backups of BackupJobs that already
failed are deleted. An operator who wants one of them for a manual
`velero restore` must copy it first.
### 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. -->
N/A — no UI changes.
### 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.
-->
The diff touches Go code in `internal/backupcontroller/` and one chart
file, `packages/system/backupstrategy-controller/templates/rbac.yaml`,
which adds the `delete` verb on `deletebackuprequests` to the
controller's ClusterRole. Walked against the trigger map:
- website: no package, platform value, variant, component, release
asset, ApplicationDefinition, Talos or tooling change. The ClusterRole
is not documented there.
- terraform-provider-cozystack: no app, schema field, enum, default,
`kind`/`plural`, prefix, or `Package`/`Plan`/`RestoreJob` CRD change.
- ansible-cozystack, talm, examples: no installer value, namespace,
variant, platform value, node prerequisite, or object the role waits on.
- ccp, external-apps-example: nothing under `hack/`, no package layout,
`-rd` path, variant, `tags.yaml`, `ApplicationDefinition` CRD or
commit-convention change.
- cozyhr, cozy-proxy, cozystack-telemetry-server, community: none of
their annotations, labels, metrics, `hack/package.mk` targets, PR
template or commit convention change.
No entry 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
<!-- 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(backups): a BackupJob whose Velero backup ends Failed, PartiallyFailed or FailedValidation now asks Velero to delete that backup and its data in the bucket, instead of leaving them until Velero's TTL expires. A Velero backup that completed is never deleted this way. If Velero cannot carry out the deletion (for example, the backup storage location is missing, read-only or unavailable), the BackupJob gets a `VeleroBackupDeletionFailed` Warning event with Velero's errors, and the deletion is retried at a growing interval of up to one hour. After upgrading, the Velero backups of BackupJobs that already failed are deleted as well; to keep one for a manual `velero restore`, copy it before the upgrade. The backupstrategy-controller ClusterRole gains `delete` on `deletebackuprequests`.
```
Backported-from:
|
||
|
|
4fec6e0c47 |
fix(seaweedfs): remove identities left behind by deleted BucketAccesses (#4915)
## What this PR does Removes SeaweedFS identities left behind by deleted BucketAccesses. The COSI driver up to v0.3.1 revokes only from the legacy `identity.json`, while SeaweedFS since 4.08 keeps each identity in its own file, so those files stayed (seaweedfs/seaweedfs-cosi-driver#11). The upstream driver v0.4.0 from #5284 deletes the file on revoke, so no new files are left. Files that v0.3.1 already left behind still hold working keys and stay until something removes them. A post-install/post-upgrade hook in `seaweedfs-system` removes them. It lists the identity files before the BucketAccesses, so a file whose BucketAccess still exists is never taken for a left-over one. The rest of the rules are in the commit message and at the top of the script. When it is unsure, it removes nothing, and the errors it handles do not fail the release. A filer that other clusters use through Client topology holds identities whose BucketAccesses this cluster cannot see. The new `cosi.orphanIdentities` value of the SeaweedFS application decides what happens there. The default `auto` only reports when `filer.grpcHost` is set and removes otherwise, and an operator can force `report` or `delete`. This builds on #4893, which is now merged. Tested with bats against a fake `weed shell` and with helm-unittest. A mutation that swaps the two listings back makes the ordering test fail. An earlier revision of the script, which also skipped recently changed files, was tried on a live cluster with SeaweedFS 4.45 and driver v0.3.1. It only reported in report mode and removed left-over files in delete mode while live identities kept working. With BucketAccess listing forbidden, it removed nothing. The current revision has not been run on a live cluster. No run has checked that the keys of a removed identity are then rejected. On |
||
|
|
0bd46bc014 |
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>
(cherry picked from commit
|
||
|
|
17cbb9aa75 |
fix(vpa): shorten the admission webhook timeout to 5s (#5242)
## What this PR does
The VPA admission controller registers its Pod CREATE webhook in every
namespace with `failurePolicy: Ignore` and a 30s timeout. When its pod
is down and the Service IP blackholes (a cold start after a full cluster
shutdown, before the CNI is back), each Pod creation waits the full 30s
on top of the other webhooks and fails with `context deadline exceeded`.
That includes the CNI's own DaemonSet pods, so the cluster cannot
recover without deleting the webhook configuration by hand.
Seen on Cozystack (Talos, 3 nodes) after a full shutdown and power-on:
the Cilium DaemonSet stayed at 1/3 and Kube-OVN's `ovn-central` could
not reach quorum until `vpa-webhook-config` was deleted. Once it was
deleted, everything recovered, and VPA re-registered its webhook on
start.
A mutation takes milliseconds; 5s keeps slow responses working and keeps
the total wait of the sequential Pod CREATE webhooks well inside the
request deadline. Uses the admission controller's documented
`--webhook-timeout-seconds` flag through the chart's `extraArgs`.
Refs #3125 (this covers the VPA part of it; `lineage` and
`linstor-scheduler-admission` are separate). Supersedes #4903, rebased
onto current `main` (no conflicts); `helm unittest` of the chart passes.
### Screenshots
No UI change.
### Downstream repositories
Walked the trigger map: the diff is one value in
`packages/system/vertical-pod-autoscaler/values.yaml` (a system package,
no app schema, no platform value, no tooling).
- [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:
### Release note
```release-note
[vpa] Shorten the VPA admission webhook timeout to 5s so pod creation does not stall cluster-wide while the admission controller is unreachable.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Configuration**
* The vertical pod autoscaler admission controller now uses a 5-second
webhook timeout.
* Configuration comments clarify the timeout and its behavior during Pod
creation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Backported-from:
|
||
|
|
ff21a70985 |
fix(seaweedfs): remove identities left behind by deleted BucketAccesses
Since SeaweedFS 4.08 the S3 gateways move every identity from
/etc/iam/identity.json into /etc/iam/identities/<name>.json, and the
COSI driver up to v0.3.1 revokes only from identity.json. Every
BucketAccess deleted on such a filer left its identity file behind,
with its keys still accepted (seaweedfs/seaweedfs-cosi-driver#11). A
driver that deletes the file on revoke does nothing for the files
already left.
A post-install/post-upgrade hook removes a ba-<uid>.json file when no
BucketAccess in any namespace names it, by uid or by
status.accountID. The uid covers a BucketAccess still being granted,
the accountID one restored with its status. The identity directory is
listed before the BucketAccesses: a BucketAccess exists before its
grant writes a file, so a file seen in the first listing whose
BucketAccess still exists is always named by the second. File ages are
not used, because grants and gateway migrations rewrite left-over
files as well. A failed or empty listing removes nothing. Each removal
is logged and recorded as an Event on the HelmRelease. The hook runs
before the Object Lock hook, so in delete mode a left-over identity is
removed before that hook grants it anything.
A filer published for Client-topology clusters holds identities whose
BucketAccesses live in those clusters, so cosi.orphanIdentities
defaults to auto: report there, delete otherwise. An operator can
force either.
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
(cherry picked from commit
|
||
|
|
e8cec92626 |
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>
(cherry picked from commit
|
||
|
|
73d7822952 |
fix(vpa): explain that the webhook waits add up within one request
failurePolicy Ignore applies only after the timeout; the Pod CREATE
webhooks are called sequentially within one request, so their waits
accumulate and can pass the request deadline.
Assisted-by: LLM
Signed-off-by: Yasar Rahman <yasar.rehman@gmail.com>
(cherry picked from commit
|
||
|
|
e1d3161e75 |
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>
(cherry picked from commit
|
||
|
|
f07c1065f3 |
fix(vpa): shorten the admission webhook timeout to 5s
The VPA admission controller registers its Pod CREATE webhook in every
namespace with failurePolicy Ignore and a 30s timeout. When its pod is
down and the Service IP blackholes (a cold start after a full cluster
shutdown, before the CNI is back), each Pod creation waits the full 30s
here on top of the other webhooks and fails with "context deadline
exceeded". That includes the CNI's own DaemonSet pods, so the cluster
cannot recover without deleting the webhook configuration by hand.
A mutation takes milliseconds; 5s keeps slow responses working and lets
Ignore actually ignore. Uses the admission controller's documented
--webhook-timeout-seconds flag through the chart's extraArgs.
Refs #3125
Assisted-by: LLM
Signed-off-by: Yasar Rahman <yasar.rehman@gmail.com>
(cherry picked from commit
|
||
|
|
eeab99ae1a |
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>
(cherry picked from commit
|
||
|
|
b8cc7b6f3e |
fix(workloadmonitor): report a bucket's workloads not ready until its claim is provisioned (#5096)
## What this PR does
A Bucket app reports WorkloadsReady=True while its BucketClaim is never
provisioned. On a v1.6.5 cluster a tenant got a BucketClaim for bucket
class `tenant-root`, the root tenant there runs no SeaweedFS, and for
three days the claim had no status while the objectstorage controller
kept emitting `FailedCreateBucket` with
`bucketclasses.objectstorage.k8s.io "tenant-root" not found`. The Bucket
app showed Ready and WorkloadsReady the whole time.
The WorkloadMonitor controller already writes a Workload per BucketClaim
with `Operational` set from `status.bucketReady`, but the monitor itself
counts only pods. The bucket chart renders its monitor with `replicas:
0` and `minReplicas: 0`, so the monitor stays operational whatever
happens to the claim.
The monitor now names every selected BucketClaim that is not provisioned
in `status.message`, sets `status.reason` to the new
`BucketClaimNotReady` and turns `Operational` false, the same way it
already reports a DataVolume that is not ready. A DataVolume verdict
keeps the fields when both apply. BucketClaims are listed on every pass,
so a stored BucketClaim verdict is recomputed rather than kept like an
unread DataVolume verdict, and it clears once the claim is provisioned.
Any monitor whose selector picks a BucketClaim follows its readiness,
which is what the Workload objects already say. The Application then
shows WorkloadsReady=False with that message and reason. Its Ready
condition keeps following the HelmRelease, as
`pkg/registry/apps/application/rest.go` intends.
Three new tests cover a provisioned claim, a claim not provisioned with
and without a class, a claim outside the selector, the verdict clearing
after provisioning with and without a DataVolume reader, and the
DataVolume verdict winning over the BucketClaim one. Against the
controller on main the four not-provisioned and clearing cases fail and
the rest pass. `go test ./internal/controller/...` and `go vet` pass.
`make generate` does not run on my machine, gengo fails to parse the
go1.27.1 standard library, so I ran the controller-gen `object` and
`crd` steps of `hack/update-codegen.sh` for `./api/v1alpha1/...`
directly. The deepcopy file is unchanged and the generated
WorkloadMonitor CRD matches
`packages/system/cozystack-controller/definitions/cozystack.io_workloadmonitors.yaml`.
I have not run the change on a live cluster.
#5083 changes the Workload names of the same BucketClaims and does not
touch the monitor status, so the two do not overlap.
### Screenshots
Not a UI change.
### Downstream repositories
The controller, one exported constant and its tests. No CRD schema,
values key, default, telemetry metric or package change, so no trigger
map entry 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(workloadmonitor): a Bucket app reports WorkloadsReady=False with reason BucketClaimNotReady while its BucketClaim is not provisioned, instead of WorkloadsReady=True.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **New Features**
* Workload monitors now report when a selected bucket claim is not
provisioned and mark the monitor as non-operational. Status messages
include the bucket class when available and list multiple unprovisioned
claims in sorted order.
* **Bug Fixes**
* The bucket-claim status clears when the claim is provisioned or no
longer selected. When DataVolume information is available, its status
takes precedence over the bucket-claim status.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Backported-from:
|
||
|
|
7c2123c3be |
fix(seaweedfs, cozy-lib): cap the Go heap so components survive their memory limit (#4234)
<!-- 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
Every SeaweedFS component is a Go binary running under a cgroup memory
limit, and none of them set `GOMEMLIMIT`. The collector then works from
`GOGC` alone, which is a target relative to the live heap with no
absolute ceiling, so a burst of allocation grows the heap past the limit
and the kernel kills the container.
This is not a leak. On the cluster where it showed up, the S3 gateway
held 6.4 GiB of `heap_sys` against an 8 GiB limit while `heap_inuse` was
389 MiB: the container was killed over memory the runtime was holding
and not using. Ten kills in seven days, each one an interruption of the
object store every tenant writes its backups to. Raising the limit does
not help, because nothing bounds the growth; it only moves the ceiling
the heap climbs to.
This PR adds a `cozy-lib.resources.goMemLimit` helper next to the
existing `javaHeap` one and wires it into the master, volume, filer and
s3 components and into every volume pool and zone, each sized from the
memory limit already computed for it. Pools need their own value because
the subchart merges `volume` into every entry of `volumes`: without one,
a `t1.nano` pool would inherit the value sized for the default volume's
512Mi limit, above its own 128Mi. The value is 75% of the limit, the
same fraction `javaHeap` uses for the JVM; the remaining quarter covers
what `GOMEMLIMIT` does not account for, goroutine stacks and mmap'd
regions among them.
The lifecycle admin and worker run the same binary under limits the
parent chart does not set (256Mi and 512Mi in
`packages/system/seaweedfs/values.yaml`), so their value is pinned next
to those limits at the same 75%: 192MiB and 384MiB.
A limit under 4/3 Mi (1398102 bytes) floors to `0MiB`, which Go accepts
and then collects almost continuously, so the helper fails the render
instead.
The upstream chart already supports `extraEnvironmentVars` on every one
of these components, so nothing had to change there. No values key is
added, so this needs no configuration and changes no public schema.
Tested with `helm unittest`: a suite on the seaweedfs package asserts
the value tracks the memory limit rather than a fixed string, for the
default volume, Simple pools, MultiZone zones and zone pools; the system
seaweedfs suite asserts the admin and worker env; and a helper suite in
`cozy-lib-tests` pins the unit grammar and the rejection of a zero
value. Reverting each fix makes its suite fail.
### 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(seaweedfs): set GOMEMLIMIT on master, volume (and each pool and zone), filer, s3 and the lifecycle admin and worker so the Go runtime collects before the container hits its memory limit instead of being OOM-killed
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **New Features**
* SeaweedFS master, volume, pool, zonal volume, filer, and S3 workloads
now receive a Go memory limit set to 75% of their configured memory
limit.
* Pool workloads use their own resource settings when provided, falling
back to the default volume preset when needed.
* SeaweedFS admin and worker components now have Go memory limits
aligned with their configured memory limits.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Backported-from:
|
||
|
|
0755bb50b9 |
fix(workloadmonitor): keep a bucket not ready until its claim is provisioned
A bucket WorkloadMonitor has no pods and minReplicas 0, so it stayed
operational, and the Bucket app stayed Ready, while its BucketClaim was
never provisioned. A tenant whose nearest S3 ancestor runs no SeaweedFS
gets a claim for a bucket class that does not exist, and the dashboard
showed a ready bucket that was never created.
Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
(cherry picked from commit
|
||
|
|
4475660610 |
fix(postgres): accept a standard five-field backup schedule (#5119)
## What this PR does
The postgres app hands `backup.schedule` to a CloudNativePG
`ScheduledBackup`, and the field asks for the six-field CloudNativePG
cron with leading seconds. The mongodb app takes a standard five-field
cron in the same field, and so do backup Plans and the Plan form in the
console, so tenants copy a value from one app into the other and support
has to explain the difference.
CloudNativePG does not reject a five-field value. CloudNativePG 1.30.0,
which main pins, parses the schedule with `cron.Parse` from robfig/cron
v1.2.0 in both the ScheduledBackup webhook and the controller. That
parser takes five or six fields, reads the first one as seconds and
makes day-of-week optional, and the webhook only returns a warning when
the count is not six. CloudNativePG's own webhook test "warn the user if
the schedule has a wrong number of arguments" covers this with `1 2 3 4
5`. So `0 2 * * *`, meant as every day at 02:00, fires every hour at
minute 2, and `5 * * * *` fires every minute.
The chart now counts the fields. A five-field value gets a leading `0`
seconds field, so `0 2 * * *` renders `0 0 2 * * *`. A six-field value
and a descriptor such as `@daily` or `@every 6h` render exactly as
before. Any other field count fails the render with a message that shows
both forms, where before it reached the webhook and was rejected there.
An empty schedule still renders no ScheduledBackup. The field
description that the dashboard form shows and the README now name both
forms.
One thing changes on upgrade. A release that already sets a five-field
value gets the standard meaning of it, so `0 2 * * *` moves from hourly
to daily. Before this change such a value was outside the documented
format and drew the webhook warning.
`packages/system/keycloak` renders its own CloudNativePG ScheduledBackup
from its `backup.schedule`, with a six-field default and a values
comment that says so. It is a platform component with its own template,
so it is not changed here. The other apps with a backup schedule
(mongodb, mariadb, clickhouse) and backup Plans already take five
fields.
- Ran robfig/cron v1.2.0 `Parse` locally from 10:00:00. `5 * * * *`
fires at 10:00:05, 10:01:05 and 10:02:05, and `0 2 * * *` at 10:02:00
and 11:02:00. With the leading `0` they fire at 10:05:00 and 11:05:00,
and daily at 02:00.
- Rendered the whole chart with helm 3.17.3 and the `configured` render
fixture. The output matches main for the defaults, for `0 2 * * * *` and
for `@daily`, and for `0 2 * * *` only the `schedule` line differs.
Unit tests with `helm unittest` 1.1.2, the version CI pins.
`packages/apps/postgres` passes 216 of 216 in 27 suites, against 209 in
26 on main. The new suite has seven cases. With the old template five of
them fail. The six-field and descriptor cases pass on both, and they
fail when the template prepends to six fields too or drops the
descriptor check.
### Screenshots
Not a UI change. The dashboard form picks up the new field description
from the schema.
### Downstream repositories
Walked the trigger map in `docs/agents/contributing.md` against the
diff. A chart template, a new test suite, one field description and the
README, schema, Go types and cozyrd regenerated from it. No field is
added, removed or renamed and no default or enum changes. The terraform
provider does not model `backup.schedule`. The website reference page
for postgres is generated from this README on a stable tag, and the Go
types example there uses a six-field schedule, which keeps working.
- [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): backup.schedule accepts a standard five-field cron such as 0 2 * * *, and the chart prepends a 0 seconds field before handing it to CloudNativePG, which reads the first field as seconds. Six-field values and descriptors render as before, and any other field count fails the render. A release that already sets five fields gets the standard meaning on upgrade, so 0 2 * * * moves from hourly to daily.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **New Features**
* PostgreSQL backup schedules support standard five-field cron
expressions as well as six-field expressions with a leading seconds
field. Five-field schedules are converted automatically; six-field
schedules and cron descriptors are used as provided.
* **Schedule Changes**
* After upgrading, `0 2 * * *` runs daily at 02:00 instead of hourly at
minute 2. To keep the previous hourly schedule, use `0 2 * * * *`.
* Invalid schedule formats produce a rendering error. Empty schedules
continue to disable chart-managed backups.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Backported-from:
|
||
|
|
0e92bc9862 |
fix(cozy-lib): state the real lower bound in the goMemLimit error
The limit that floors to 0MiB is anything under 4/3 Mi, not under 2Mi:
1536Ki still yields 1MiB. The message named the wrong bound and the
tests pinned 2Mi and 1Mi, neither of which sits on the edge.
Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
(cherry picked from commit
|
||
|
|
c24bb4c16f |
fix(clickhouse): keep failed backup attempts out of the bucket (#5229)
<!-- 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 BackupJob attempt that fails during upload leaves its local
backup on the data volume, and with the upstream defaults the
clickhouse-backup sidecar never prunes local backups and resumes every
unfinished upload when it starts. On the next sidecar restart the failed
attempt is uploaded to the bucket as an archive no Backup refers to, and
while that resumed upload runs the sidecar answers new operations with
423, which burns the strategy Job's retries in seconds. The strategy
itself only waited for the sidecar API to respond and then started its
operation regardless.
The sidecar now runs with `API_COMPLETE_RESUMABLE_AFTER_RESTART=false`,
so a failed attempt is never published, and `BACKUPS_TO_KEEP_LOCAL=-1`,
so at most the newest local backup is kept and it is removed once its
upload succeeds. Backups already left on existing volumes are cleaned up
by the first backup after the upgrade. The Altinity strategy now waits
until the sidecar has no operation in progress before it starts a backup
or a restore, and fails the attempt with a clear message instead of
proceeding when the sidecar stays busy or unreachable.
Waiting for an idle sidecar changes what a retried strategy Pod does.
The Job retries a failed Pod up to twice, and a Pod can die after its
operation was accepted (a dropped poll under errexit, an eviction, a
node drain) while the sidecar keeps running it. Before, the retry hit
423 and failed; with the idle gate it would wait for the running
operation to finish and start it again. For a restore that is
destructive, because `restore_remote` drops every table it restores
before recreating it, so the second run discards whatever was written
after the first one finished. A retried restore therefore takes over a
`restore_remote` of the same archive that is still running and waits for
its result instead of starting another. Once an operation is accepted,
polls tolerate up to six failures in a row before the attempt fails, and
the sidecar losing the operation from its in-memory action log, or
ending it cancelled, fails the Pod instead of leaving it polling.
A retried backup works from the archive name the controller records for
its BackupJob. That name is now `<application>-<YYYYMMDDHHMMSS>-<first
12 hex digits of the BackupJob UID>`, so two runs of one application
started in the same second, as two Plans on one schedule are, never
share an archive. It is exactly as long as the previous
`clickhouse-<application>-<YYYYMMDDTHHMMSSZ>`, so an `s3PathOverride`
prefix that fit before still keeps every object key within the 1024-byte
limit. A retry takes over a `create_remote --resume` of its archive that
is still running, counts an upload of its archive whose latest run ended
in `success` as its own result instead of uploading the archive again,
and otherwise resumes the upload. Restoring a Backup that records no
archive still picks an archive by timestamp, and that path accepts only
`clickhouse-<application>-<timestamp>` names, so it never picks a
per-run archive.
One limit remains. A finished `restore_remote` row is not taken over:
the sidecar never trims its action log, so a `success` row of the same
archive may be left by an earlier RestoreJob, and counting it as this
one would report a restore that never ran. A retry that arrives after
the restore it replaces had already finished, but before that Pod saw
the result, therefore still runs the restore a second time.
Upgrading changes the ClickHouseInstallation pod template, so ClickHouse
pods with `backup.enabled` are rolled once. A backup Job started before
the upgrade by a controller that named archives the previous way is not
re-rendered and keeps writing that name, so the controller records the
previous name when the new one is not on the Job. The local copy of the
latest failed attempt stays on the volume until the next backup. Objects
partially written to the bucket by an upload that fails midway are not
removed by clickhouse-backup and are left for a follow-up.
### 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(clickhouse): failed ClickHouse backup attempts are no longer uploaded to the bucket when the backup sidecar restarts, local backups no longer accumulate on the data volume, the backup strategy waits for the sidecar to be idle instead of failing with HTTP 423, a retried ClickHouse restore takes over the restore that is still running instead of starting it a second time, and a retried ClickHouse backup takes over or reuses its own upload instead of starting a new one. Every ClickHouse backup run now writes an archive of its own, even when two runs start in the same second, under a name no longer than before. ClickHouse pods with backups enabled are restarted once on upgrade.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **New Features**
* Backup and restore operations wait for the backup service to become
idle and join a matching operation already in progress rather than
starting a duplicate.
* Restore operations use the archive the Backup records and fail when it
is not in remote storage; only a Backup that records no archive falls
back to the newest eligible archive by timestamp.
* New backups use distinct archive names, including for runs started in
the same second.
* Local backup copies are discarded after upload, and completed uploads
are not resumed after a service restart.
* **Bug Fixes**
* Operations now fail when the service cannot be queried, an operation
disappears from its activity log, or it ends with an error or
cancellation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Backported-from:
|
||
|
|
c822846b0a |
docs(postgres): note how an existing backup schedule changes on upgrade
A release that already sets backup.schedule to "0 2 * * *" runs hourly
at minute 2 today and daily at 02:00 after this change. The README now
says so and gives "0 2 * * * *" for keeping the hourly run.
Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
(cherry picked from commit
|
||
|
|
bef343133a |
fix(seaweedfs, cozy-lib): cap the Go heap so components survive their memory limit
Every SeaweedFS component is a Go binary running under a cgroup memory
limit, and none of them set GOMEMLIMIT. The collector then works from
GOGC alone, a target relative to the live heap with no absolute ceiling,
so a burst of allocation grows the heap past the limit and the kernel
kills the container.
Seen on an S3 gateway holding 6.4 GiB of heap_sys against an 8 GiB limit
while only 389 MiB was actually in use: ten kills in seven days, each one
an interruption of the object store every tenant writes its backups to.
Raising the limit does not help, since nothing bounds the growth; it only
moves the ceiling the heap climbs to.
Derive the value from the limit already computed for each component, at
the same 75% the javaHeap helper uses for the JVM. The remaining quarter
covers what GOMEMLIMIT does not account for, goroutine stacks and mmap'd
regions among them.
Volume pools and zones carry their own value: the subchart merges volume
into every entry of volumes, so a pool would otherwise inherit the value
sized for the default volume's limit, above its own. The lifecycle admin
and worker run the same binary under limits the parent chart does not
set, so their value is pinned next to those limits.
A limit under 2Mi floors to 0MiB, which Go accepts and then collects
almost continuously; the render fails instead.
Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
(cherry picked from commit
|
||
|
|
ca1b59243e |
fix(postgres): accept a standard five-field backup schedule
The mongodb app and backup Plans take a standard five-field cron, but
the postgres chart hands backup.schedule to a CloudNativePG
ScheduledBackup, which parses it with robfig/cron v1 Parse. That parser
reads the first field as seconds and makes day-of-week optional, so a
five-field value passes admission with only a warning and runs one
field off. 0 2 * * * runs hourly and 5 * * * * every minute.
A five-field schedule now gets a leading 0 seconds field. Six fields
and descriptors pass through, and any other field count fails the
render. A release that already sets five fields gets the standard
meaning on upgrade, so 0 2 * * * goes from hourly to daily.
Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
(cherry picked from commit
|
||
|
|
d78b9294ac |
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>
(cherry picked from commit
|
||
|
|
7fd7b59dd4 |
fix(clickhouse): match a backup Job's archive by its whole name
The archive a backup Job carries was found as a substring of its Pod
spec. The name without the BackupJob's UID starts the name with it,
and a strategy may append to either, so a Job that wrote a longer
archive could get the shorter name recorded on its Backup, and a
restore of that Backup would read another archive.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
d677869549 |
fix(clickhouse): keep the archive name of a backup running across the upgrade
A backup Job created before archive names carried the BackupJob's UID
writes its archive under the name without it, and the Job is not
re-rendered when the controller is upgraded. Matching only the new
name left that Backup with no archive recorded, so its restore fell
back to guessing by timestamp.
The name without the UID is matched second, because it is a prefix of
the one with it.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
751cf28e98 |
test(backups): drop the comment restating what accepted() returns
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
2660954027 |
fix(clickhouse): give every backup run an archive of its own
An archive was named from the application and the BackupJob's start
time, which has one-second resolution. Two runs of one application
started in the same second, as two Plans on the same schedule are,
wrote the same archive. The strategy takes a finished upload of its
archive as an earlier attempt of its own run, so the later run could
succeed on the other run's upload and record an archive missing any
table created since.
The BackupJob's UID now ends the name. It goes after the timestamp so
names keep sorting chronologically, and the restore of a Backup that
records no archive, which accepts only a bare timestamp after the
release prefix, never picks one of these.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
14f06074e5 |
fix(backups): keep a ClickHouse archive an earlier attempt finished
A backup Pod that loses sight of its upload, by dying or by losing six
polls in a row, is retried while the sidecar finishes that upload. The
retry found it in the action log as a success, took the sidecar for
idle and asked for create_remote with resume again. clickhouse-backup
then rebuilds the local backup and uploads it once more over the
archive already in the bucket, which is left broken if that second
upload dies halfway.
The archive name belongs to one BackupJob, so a success row of exactly
this upload can only be an earlier attempt's, and the retry now takes
it as its result. An error or cancel row still leads to a resumed
upload, and a restore still runs again, since a restore is not named
per RestoreJob.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
c90765771e |
test(backups): cover a ClickHouse restore against an unreachable sidecar
The restore path resolves its archive from list/remote before the start
gate runs, so it carries its own wait for a sidecar that is not up, and
only the backup path had a test for a sidecar that never answers. The
retry comment also miscounted: the limit is attempts, not retries.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
817b59a45a |
fix(backups): take over a running ClickHouse restore on Job retry
restore_remote drops every table it restores before recreating it, so
running it twice discards whatever was written after the first run
finished. The strategy Job retries a failed Pod up to twice, and with
the start gate waiting for an idle sidecar instead of hitting 423, a
retry whose predecessor died after its POST waited for that restore to
finish and then started a second one. A retry now takes over a
restore_remote of the same archive that is still running.
A finished row is not taken over: the sidecar never trims its action
log, so a success row of the archive may belong to an earlier
RestoreJob, and treating it as this one would report a restore that
never ran. A retry that arrives after the restore finished therefore
still runs it again.
Once the operation is accepted, one failed poll no longer ends the
attempt under errexit; six in a row do. An operation that ends
cancelled now fails the Pod instead of being polled forever.
A retried backup still starts a new create_remote, because its archive
name changes on every attempt; taking it over needs a name fixed for
the whole BackupJob.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
668ddded49 |
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 -->
Backported-from:
|
||
|
|
1e5e3a45df |
fix(backups): fail a ClickHouse backup whose operation the sidecar lost
The sidecar keeps its action log only in memory, so a sidecar restart
after create_remote was accepted drops the operation's row, and the
strategy kept polling for it forever under a Job with no deadline.
Until now the resumed upload re-added a row ending in the archive name
and ended the loop, but resume is now off so a failed attempt never
reaches the bucket, which leaves nothing to end it. The row is logged
before the POST is acknowledged, so its absence means the operation is
gone and the attempt has to fail.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
48aa4188b4 |
fix(seaweedfs): keep the metadata database storage class a string
db.storageClass went unquoted into the values of the database release
and again into its CNPG Cluster. A class name made only of digits,
which Kubernetes allows, became a number that the Cluster rejects, and
a line break in the value could add keys to the database release
values. It is quoted at both steps.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
8b76529539 |
fix(backups): wait for an idle ClickHouse backup sidecar before starting
The sidecar refuses a new operation with 423 while another one is in
progress, but the strategy only waited for the API to answer, and went
on to start its operation even when it never did. An operation already
running in the sidecar therefore failed the attempt within seconds.
Poll the action log until nothing is in progress, and fail the Pod
instead of proceeding when the sidecar stays busy or unreachable, so
the failure names the cause rather than surfacing as a 423 or a
connection error from the operation itself.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
48c14268fe |
fix(seaweedfs): escape pool and zone storage classes in the release values
Pool and zone storage classes were wrapped in quotes by hand, which
does not escape a quote or a backslash in the value: a quote closes the
string early and the data-plane release values stop parsing, with a
YAML error that does not name the field. They are now quoted like the
volume and admin classes.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
84a5f9ee64 |
fix(clickhouse): stop the backup sidecar from publishing failed attempts
create_remote keeps its local backup when the upload fails, and with
the upstream defaults the sidecar never prunes local backups and
resumes every unfinished upload when it starts. A strategy attempt that
fails mid-upload therefore lands in the bucket on the next sidecar
restart as an archive no Backup refers to, and restore can pick it as
the newest one. The resumed upload also holds the API lock, so the
strategy Pods racing it get 423 and burn the Job's retries.
Turning the resume off keeps a failed attempt out of the bucket, and a
negative local retention leaves at most the newest local backup and
drops it once its upload succeeds, so leftovers no longer accumulate on
the data volume.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
1a01f171ea |
fix(seaweedfs): quote every storage class the upstream claims carry
The master, filer, volume index, log and all-in-one claims of the
upstream chart write storageClassName unquoted, like the data claims
did, so a class name made only of digits renders as a number and the
claim is rejected. None of them is set by Cozystack today, but they
are values of the same chart that a later change can start handing on,
and the patch already exists for the data claims. They follow the same
rule: quoted, and left out when no class is named so that the cluster
default applies. The deprecated filer.enablePVC claim is left alone:
it renders only with filer.data unset, and the template fails earlier on
an unset filer.data, so it cannot be reached.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
bb1af44417 |
fix(seaweedfs): keep storage class names strings in the volume claims
The upstream admin and volume StatefulSets write storageClassName
unquoted, so a class name made only of digits, which Kubernetes allows
and the parent chart now hands on as a string, turned back into a
number there and the claim was rejected. The field is quoted, and left
out when no class is named: quoting an empty value would set an empty
storageClassName, which disables dynamic provisioning instead of using
the cluster default. Upstream 4.52 and master still write both fields
unquoted, so this is a chart patch, applied with --forward so make
update stops once upstream carries an equivalent change.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
7a6aac9ede |
fix(seaweedfs): hand storage class names to the data plane as strings
The volume and admin storage classes were written unquoted into the
values of the data-plane release. A class name made only of digits,
which Kubernetes allows, arrived there as a number, and a value with a
line break could add keys next to the field, past the schema that is
the tenant's input gate. Both are now quoted. lifecycle.storageClass,
new in this release, also carries the StorageClass name rules in its
schema, so a value that cannot name a class is refused when the
application is written instead of leaving the admin claim pending.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
9a6715502d |
fix(seaweedfs): give the lifecycle admin volume its own storage class
volume.storageClass is picked for volume server data, and in a
MultiZone instance it can name a class whose volumes exist in one zone
or on one node. Reusing it for the admin volume would tie the admin to
that zone or node, so losing it would stop lifecycle enforcement for
the whole instance, a placement nobody chose for the admin. The admin
volume now takes lifecycle.storageClass, and the cluster default when
that is empty.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
e59a9db440 |
fix(seaweedfs): keep bucket lifecycle enforcement off unless enabled
The daily walk that expires objects sends its deletes without an object
identity, and the s3 server skips its compare-and-swap when none is
given (walker_dispatcher.go and identityMatches, unchanged from 4.45
through 4.52). It does not re-check the object's age either, so a key
overwritten between the walk's listing and the delete loses its new
content. Backup buckets write unique keys and barely meet that window;
a tenant bucket that rewrites a fixed key does.
Turning enforcement on by default would also start applying, on
upgrade, every rule that was stored and ignored until now. Both are
retention changes an operator should choose, so the admin server and
the worker now run only where lifecycle.enabled is set. On by default
can return once the walk carries identity.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
df3f13354c |
fix(seaweedfs): let the lifecycle worker roll out on a single node
The worker is a one-replica Deployment, so a rollout surges a second
pod before stopping the first, and the subchart pins worker pods apart
with a hard hostname anti-affinity. On a single-node cluster the surge
pod never schedules and the release waits out its timeout on every
change to the worker template. A preference keeps the spread where
there are nodes for it, as the master and s3 settings here already do.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
b444b9d1d0 |
fix(seaweedfs): let the dashboard read the lifecycle monitors
The dashboard reads an application's WorkloadMonitors by name through
its resource-map Role, so the admin and worker monitors the lifecycle
switch adds were invisible to the tenant: the components ran, but the
application page never listed them.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
2305b5cd3e |
build(seaweedfs): stop make update when the [grpc.s3] backport lands
The backport becomes redundant once the vendored chart reaches 4.46.
Re-applied to a chart that already carries the section, BSD patch takes
it as reversed, removes the section and exits 0, so a re-vendor would
quietly return the s3 gRPC listener to plaintext. --forward refuses an
already-applied patch with a non-zero exit, which stops the update at
the point where the patch should be dropped.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
849d8449d7 |
fix(seaweedfs): retry the data-plane release instead of rolling it back
The admin volume and the two lifecycle pods are new demands on tenant
quota, so an upgrade into a namespace with no headroom can wait out its
timeout. Flux's default remediation then rolls the release back, and
with unlimited retries it does so on every attempt: each rollback drops
the [grpc.s3] section and the s3 restart annotation, each retry brings
them back, and the s3 pods restart twice per cycle until quota frees up.
RetryOnFailure keeps what was applied and retries it, as the parent
release that the apiserver builds for the application already does.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|
||
|
|
ae779b1416 |
docs(backups): say who applies a bucket lifecycle rule
The notes that send a tenant to a bucket lifecycle rule for a backup
object Cozystack leaves behind read as if some policy were already in
place. None is: the rule has to be set on the bucket, and it is applied
only by an object store that implements lifecycle, which the bundled
SeaweedFS now does once a day while lifecycle.enabled is on.
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
(cherry picked from commit
|