Commit Graph
5213 Commits
Author SHA1 Message Date
toribru 00a540eb62 fix(ingress): restore visitor IPs through SSL passthrough
With cloudflareProxy enabled, HTTPS reaches nginx from the
ssl-passthrough proxy on loopback. Without trusting that proxy, the
whitelist sees 127.0.0.1 instead of the visitor address; trusting it
without checking the PROXY-protocol peer would reopen the spoofing
closed by #4444.

Checking the transport peer before the whitelist preserves that
protection, while port 80 needs its direct peer because no
PROXY-protocol address exists there.

Tested with helm-unittest and an isolated ingress-nginx controller:
trusted PROXY peers pass the whitelist with the restored visitor
address, while spoofed headers on HTTP and HTTPS return 403.

Closes: #5327
Assisted-by: LLM
Signed-off-by: toribru <161638395+toribru@users.noreply.github.com>
2026-11-26 01:30:15 +03:00
Aleksei Sviridkin 8cab9b7d7b refactor(tenant): make gateway a plain bool (#5408)
<!-- 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 #4542.

Makes `tenant.spec.gateway` a plain boolean defaulting to `false` and
removes the unset-specific helper branch. Both `false` and an omitted
key retain the existing behavior: the tenant owns no Gateway and
inherits the nearest ancestor Gateway. Setting `true` still gives the
tenant its own Gateway.

The API now serializes `gateway: false`, and the dashboard shows the
`gateway` checkbox next to `ingress`, unchecked by default. The chart
test now verifies the rendered namespace label for both `false` and
`true`.

### 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

### 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.
-->

I walked the trigger map against the diff. The tenant `gateway` default
and API serialization change reaches the hand-written Terraform
provider's documentation and key-presence/null assumptions. Follow-up is
tracked in cozystack/terraform-provider-cozystack#88; no provider change
is included in this PR. The website already lists tenant in its managed
app set, and its stable-tag automation regenerates the tenant reference
from README, so no manual website follow-up is required. No other
downstream trigger applies.

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: cozystack/terraform-provider-cozystack#88
- [ ]
[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
refactor(tenant): make `gateway` a plain boolean defaulting to `false`; the dashboard now shows the `gateway` checkbox next to `ingress`, unchecked by default. Existing routing behavior is unchanged: `false` or an omitted value inherits the nearest ancestor Gateway, while `true` gives the tenant its own Gateway.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Documentation**
* Clarified that `gateway: false` is the default and uses the nearest
ancestor’s Gateway, falling back to Ingress when no ancestor owns one.
* Updated tenant configuration references to display the Gateway setting
and its class in the dashboard.
* **Bug Fixes**
* Confirmed that `gateway: false` inherits the parent Gateway without
creating a tenant-owned Gateway, while `gateway: true` identifies the
tenant namespace as owning its dedicated Gateway.
* Tenant configuration now includes the Gateway value explicitly when it
is false.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-26 00:44:33 +03:00
Aleksei Sviridkin 22843c5c5c fix(kubernetes-nodes): surge one worker at a time during a pool rollout (#5399)
<!-- 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

A worker pool rollout (instance type, image or version change) currently
surges up to `maxReplicas` new VMs before draining an old one, so a pool
running 8 workers under a ceiling of 10 can reach 18 VMs at its peak.
Those VMs land in the tenant's namespace: today they count against its
`ResourceQuota`, and under [tenant quotas as reservation
limits](https://github.com/cozystack/community/pull/48), where a pool
reserves `maxReplicas` workers, they are capacity nobody reserved. This
PR fixes the surge at one Machine per pool.

The surge is treated as platform margin rather than tenant budget:
rollouts are mostly platform-driven, and charging them to the tenant
would block a platform upgrade for any tenant whose pool sits at its
ceiling. Bounding that margin is what this PR does. `maxUnavailable` is
untouched, so a node is still only drained once its replacement is up
(#5153).

The value is the open question for maintainers. **1** keeps the loan to
a single worker per pool and is what this PR ships; a large pool then
rolls one worker at a time. **2** halves the rollout time of a large
pool at twice the margin. I would rather not make it a chart value,
since tenants write the values and would then size the platform's margin
themselves.

Tested with `helm unittest` on `kubernetes-nodes`; the three golden
renders change only in `maxSurge`.

Refs: cozystack/community#48, cozystack/cozystack#5397

### Screenshots

Not a UI change.

### Downstream repositories

<!--
Cozystack is upstream for repositories that are NOT kept in sync with it
automatically, and nothing in CI compares the two sides, so a change
here can break them silently.

Which change forces what, and which file to touch, is the trigger map in
docs/agents/contributing.md under "Downstream Repositories". Walk it
before you tick anything.

IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM
TO FILL IN:

1. Walk the trigger map against the actual diff of this PR, file by
file. Do not decide from the PR title or from your memory of what you
changed.
2. For every repository you tick, open the follow-up PR there and link
it on the same line. A ticked box with no link claims work that does not
exist, which is worse than an empty box. Search that repository for an
open PR or issue covering it first, and link that instead of filing a
duplicate.
3. When the follow-up is out of scope, or needs a decision that is not
yours to make, open an issue in that repository instead, link that, and
say so in the PR body. Do not push a speculative PR into another
repository just to fill a line here.
4. Do not tick "No downstream repository is affected" to make the
checklist go away. If you are unsure, leave every box empty and say so
in the PR body, so a human decides.
-->

I walked the trigger map against the diff: one template line, its
comment and its tests. No values key, schema, default, version enum or
release name changes.

- [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(kubernetes-nodes): a worker pool rollout now adds one replacement worker at a time instead of up to the pool's maxReplicas, bounding the extra capacity a rollout uses in the tenant's namespace. Large pools roll out more slowly.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Behavior Changes**
* Rolling updates now allow a fixed surge of one worker at a time,
regardless of the pool’s maximum replica count. Pools with higher
replica limits no longer increase the surge allowance. This change
applies even when the pool’s minimum and maximum replica counts are both
set to five. The existing default and explicitly configured
`maxUnavailable` behavior remain unchanged.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-25 22:21:10 +03:00
Aleksei Sviridkin 054b4ef4bc fix(linstor): gate group snapshots on the v1 group snapshot API (#5430)
## What this PR does

The linstor group snapshot gate and the linstor
`VolumeGroupSnapshotClass` were tied to
`groupsnapshot.storage.k8s.io/v1beta2`, on the grounds that
piraeus-operator probes v1beta2. On main it does not: piraeus-operator
v2.12.1 probes v1, csi-snapshotter v8.7.0 reads the content and class
kinds at v1, and snapshot-controller v8.7.0 watches all three kinds at
v1. The vendored chart serves v1, v1beta1 and v1beta2 today, so nothing
is broken yet, but once upstream stops serving v1beta2 the gate would
turn group snapshots off while every component that acts on them could
still use them.

The first commit gates on v1 and moves the class to v1. It also replaces
the comment that said csi-snapshotter stalls when the gate is on and the
API is missing: v8.7.0 logs a warning and runs without group snapshots.
Velero 1.18 reads group snapshots at v1beta2, so the vm-instance hook,
which gates on v1beta2 for Velero, stays as it is.

The second commit rewrites the snapshot-controller CRD test. It pinned
the vendored chart's layout (six CRD documents, v1beta2 as the storage
version, no v1alpha1) and would go red on a correct `make update` that
moves storage to v1. It now asserts what the platform needs: every group
snapshot CRD serves v1 and v1beta2, the three volume snapshot CRDs are
rendered, and every rendered CRD is kept on uninstall.

On upgrade, an install running the CRDs from this chart sees no change
in the gate and no csi-controller rollout. The class is updated in
place, since Helm matches release objects by group and kind. The only
install that flips is one whose distribution ships group snapshot CRDs
with v1beta2 but not v1: the gate goes from on to off and the class is
removed, and csi-snapshotter there was already disabling the feature at
startup.

I left the `-eq 3` check in the platform `image-migrations` target
alone. It stops an image from shipping where migration 62 deletes the
old CRDs and has nothing to recreate them from; asserting the three file
names instead would copy the list migration 62 already holds, and the
count fails loudly if upstream adds a CRD.

Tested with `helm unittest` on `packages/system/linstor` and
`packages/system/snapshot-controller`. I also checked that the new CRD
test fails when v1 or v1beta2 stops being served, when `keepCRDs` is
false, and when no CRD renders. Nothing was run against a cluster.

### Screenshots

Not a UI change.

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
fix(linstor): enable volume group snapshots based on the groupsnapshot.storage.k8s.io/v1 API that csi-snapshotter and snapshot-controller use, so they keep working once upstream stops serving v1beta2.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* LINSTOR group snapshot support now uses the stable
`groupsnapshot.storage.k8s.io/v1` API when all required resources are
available.
* Group snapshot resources are served through both v1 and v1beta2,
supporting components that use either API version.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-25 19:52:11 +03:00
Aleksei Sviridkin 7067313c95 fix(kubernetes): stop refusing extraOutputs hooks monitoring-agents accepts (#5427)
## What this PR does

The tenant Kubernetes application checked fluent-bit `extraOutputs` with
a regular expression over the text of an `outputs` override, written
against the exact layout of the default hook. The monitoring-agents
chart decides the same question by rendering `outputs`, so a hook
written with `{{- if .Values.config.extraOutputs }}` / `{{
.Values.config.extraOutputs }}` / `{{- end }}`, or a bare `{{
.Values.config.extraOutputs }}`, was refused by the application although
monitoring-agents renders it into `fluent-bit.conf`. I confirmed this
with `helm template` on both charts.

I kept a check in the application, because the addon fails in a
HelmRelease the tenant cannot read and the Application status reflects
only its own release. It now only requires `outputs` to mention
`.Values.config.extraOutputs`. The check stays textual because executing
a tenant template in this chart would run it in the management cluster,
and the exact check is already made by the monitoring-agents render
guard.

A new test covers the `if` form. The application tests for a
commented-out or newline-trimming hook are removed, since only the
monitoring-agents guard catches those now, and it already has tests for
both.

Follow-up to #5376.

### Screenshots

Not a UI change.

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
fix(kubernetes): an `addons.monitoringAgents.valuesOverride` that overrides fluent-bit `outputs` and emits `extraOutputs` with an `if` block or a bare `{{ .Values.config.extraOutputs }}` is no longer refused by the application.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Monitoring-agent output configuration now accepts a wider range of
template formats when including extra destinations, including
conditional hooks. Validation still requires the configuration to
reference the extra destinations setting.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-25 19:51:54 +03:00
Aleksei Sviridkin 0d75b0e352 fix(seaweedfs): stop reserving storage pool name suffixes (#5426)
## What this PR does

The SeaweedFS chart refused any storage pool named `public` or ending in
`-lock`, `-readonly` or `-public`. A second check in the same template
compares the class names each pool actually renders, against each other
and against the instance's base classes, and it already refuses every
one of those names that clashes with something. `public`, `lock` and
`readonly` clash with the base classes. `x-public`, `x-lock` and
`x-readonly` clash only when a pool `x` exists. The suffix list
therefore refused only names that clash with nothing, such as
`cdn-public` with no pool `cdn`, and it would have needed another
breaking change for every new class variant.

I removed the suffix list and kept the rendered-name check as the only
rule. Every values set that rendered before renders the same objects
now. Names that were refused without a real clash are now accepted.
Nothing that was accepted is refused, so this is not a breaking change.

The tests now cover both sides of the rule. `cdn-public`, `cdn-lock` and
`cdn-readonly` without a `cdn` pool are accepted, in `volume.pools` and
in a zone. A pool next to its own `-public`, `-readonly` or `-lock`
variant is refused with the clash message, and so is a pool named
`public`.

Related: #5316 is already handled on main by the rendered-name check
(pools named exactly `lock` or `readonly` are refused there). #5412
takes the opposite approach and extends the reserved-name list in the
same files.

### Screenshots

Not a UI change.

### Downstream repositories

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: the storage pools page says pool names ending in `-lock` or
`-readonly` are reserved; it should say a pool name must not render a
class name another pool or the base classes already use.
- [ ]
[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(seaweedfs): storage pool names are no longer refused for a reserved suffix; a pool is refused only when one of its BucketClass or BucketAccessClass names is already rendered by another pool or by the instance's base classes.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Pool names ending in `-public`, `-lock`, or `-readonly` are now
accepted when their rendered class names don’t conflict with another
pool or a base class.
* Name collisions are still rejected with errors that identify the
conflicting rendered class.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-25 19:51:46 +03:00
Aleksei Sviridkin ea9ef1f7ed refactor(computeplane): stop copying pool defaults into the default md0 (#5425)
## What this PR does

When a ComputePlane has no `nodeGroups`, the module renders a default
`md0` pool. That pool also wrote `maxReplicas: 10`, `instanceType:
u1.medium` and `diskSize: 20Gi`, which are copies of the KubernetesNodes
schema defaults. That put the pool's size in two places, and the next
change to the KubernetesNodes defaults would leave the ComputePlane copy
behind.

The comment that justified the copy said a reservation read from the
release would otherwise need to know another chart's defaults. That is
not how the evaluator works: `pkg/reservation` defaults stored values
against the kind's own structural schema before evaluating, and
`TestEvaluateDefaultsStoredValues` already checks that a sparse `{roles,
minReplicas}` pool reserves exactly what the explicit one does.

This PR returns `md0` to what it was before the copy was added, `{roles:
[ingress-nginx], minReplicas: 0}`, and drops the comment. The unit test
now pins the whole `spec.values` of the default pool rather than each
copied key.

Upgrade: the md0 HelmRelease loses three keys from `spec.values`, so
Flux runs one Helm upgrade of the pool release. I rendered the
kubernetes-nodes chart with the old and the new md0 values (instance
type lookups mocked) and the output is byte-identical, including the
content-hashed KubevirtMachineTemplate name. The pool keeps its size and
does not roll. The copy has not shipped in any release tag.

### Screenshots

Not a UI change.

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

The diff touches one template and its unit test. No values key, schema
or package is added, renamed or removed.

### Release note

```release-note
refactor(computeplane): the default md0 pool no longer duplicates the KubernetesNodes size defaults; rendered pools are unchanged.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Configuration**
* The automatically created `md0` pool now specifies only its ingress
role and a minimum of zero replicas. Maximum replicas, instance type,
and disk size are no longer explicitly set there and use the pool
chart’s defaults instead.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-25 19:51:39 +03:00
Timofei Larkin 194d681c20 feat(vpc): cozyplane variant of the VPC application (#4508)
## What this PR does

Stacked on #3149. The cozyplane networking variant skips the
kube-ovn/multus-backed `virtualprivatecloud` application, which left the
VirtualPrivateCloud catalog kind absent on cozyplane clusters. This PR
adds an **alternative flavor of the same catalog kind**, backed by
cozyplane's `sdn.cozystack.io` API, and wires it in as a second variant
of the existing delivery:

- **`packages/apps/vpc-cozyplane`** — a chart that creates a namespaced
`VPC` (address ranges may overlap between VPCs; isolation is by
overlay), the owner-namespace `VPCBinding` (attachment is default-deny
even for the owner), one `VPCPeering` half per declared peer
(bidirectional declaration, same UX as the kubevirt flavor's `peers`),
and an optional `VPCGateway` (`gateway.enabled` / `nat` /
`ingressLoadBalancer` / `loadBalancerClass`).
- **`virtualprivatecloud-rd`** now selects which ApplicationDefinition
it installs by a `variant` value: both flavors register the same kind
with the same release prefix, but each definition must point at its own
variant's ExternalArtifact. The cozyplane definition is generated by the
same `hack/update-crd.sh` flow; the script now honors `VARIANT`/`OUT`
from the environment instead of always reading `variants[0]` of the
PackageSource.
- **`cozystack.virtualprivatecloud-application`** gains a `cozyplane`
variant whose ordering edge is `cozystack.cozyplane-apiserver` (the
group is aggregated-only) instead of `cozystack.multus`, and the iaas
bundle selects the flavor by `bundles.system.networkingVariant`,
replacing the previous skip.

Covered by helm-unittest suites in all three places: chart rendering
(binding always present, gateway/peering shapes, `loadBalancerClass`
absent when empty), rd variant selection (exactly one definition,
correct chartRef, unknown variant fails the render), and platform wiring
(bundle flavor selection, dependency edges with no multus edge on
cozyplane).

Not in scope, deliberately: cross-namespace VPCBindings (sharing a VPC
with another tenant's namespace), reserved NAT identities
(`addressClaimName` waits on the address substrate), and e2e —
real-cluster validation of the whole cozyplane stack is tracked on
#3149.

**VM attachment (added 2026-10-08).** `vm-instance` now joins a VM to a
cozyplane VPC: when the cluster serves `sdn.cozystack.io` (API
discovery, the same gate as the Kube-OVN IP pinning), the chart stamps
`sdn.cozystack.io/vpc: virtualprivatecloud-<networks[0].name>` on the
virt-launcher pod and renders no multus networks and no secondary
interfaces — the VM keeps its single pod interface. The values contract
is unchanged for consumers: `networks: [{name: <VPC catalog name>}]`,
the name without the `virtualprivatecloud-` prefix, same convention as
`peers[].vpcName`; at most one entry (more fails the render by name,
since a cozyplane pod joins exactly one VPC). The Cilium-variant multus
path is untouched and both branches are unit-tested.

**Route table (added 2026-11-20).** `vm-instance` takes `routeTable`,
the name of a cozyplane RouteTable in the VM's namespace (a DNS-1123
name, empty by default). When it is set and the VM joins a VPC through
`networks`, the chart renders `sdn.cozystack.io/route-table:
<routeTable>` on the virt-launcher pod next to `sdn.cozystack.io/vpc`;
empty renders nothing and leaves the VPC's default table in effect.
Setting it without a VPC network, or on a cluster that does not serve
`sdn.cozystack.io`, fails the render by name.

Still to verify on a live stand, not by rendering: which KubeVirt
interface binding the default interface needs on cozyplane (the template
uses `bridge: {}`; masquerade may be required), whether the guest
acquires the VPC address over DHCP, and whether
`kubevirt.io/allow-pod-bridge-network-live-migration` still applies —
the CNI stamps `sdn.cozystack.io/vpc-ip`/`-mac` on the launcher pod to
check against.

### Compatibility

Existing installations are unchanged. `bundles.system.networkingVariant`
defaults to `kubeovn-cilium`, which keeps the `kubevirt` flavor of
`cozystack.virtualprivatecloud-application` and its
ApplicationDefinition exactly as before; the `cozyplane` flavor is
selected only together with `networkingVariant: cozyplane`. On a running
cluster that switch changes the `cozystack.networking` variant, which
the platform render refuses unless `networking.acknowledgeVariantChange`
names the new variant (#3149). No migration moves kube-ovn-backed VPCs
onto the cozyplane flavor.

### Screenshots

Not a UI change.

### Downstream repositories

The trigger map fires for cozystack/website (a new package under
`packages/apps/` needs an entry in the website Makefile's app lists, and
the variant recomposition touches the variants page) and arguably for
terraform-provider-cozystack (the VirtualPrivateCloud spec differs per
flavor, so the hand-maintained schema will not match cozyplane
clusters). Both follow-ups are deferred while this stack is draft —
filing them against an unmerged experimental variant would be noise;
they should be opened when #3149 leaves draft. Boxes left unticked so a
human decides.

- [ ] 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
feat(vpc): the cozyplane networking variant now serves the VirtualPrivateCloud application, backed by sdn.cozystack.io — namespaced VPCs with peering and an optional north-south gateway
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Added a Cozyplane-backed VirtualPrivateCloud option with configurable
network ranges, peer connections, and optional gateway, NAT, and ingress
settings.
* The platform now selects the VPC option based on the configured
networking variant.
* VMs using Cozyplane networking can join one VirtualPrivateCloud while
retaining a single pod interface; multiple network entries are rejected.
* **Documentation**
* Updated VPC and VM networking guidance, including configuration
options and Cozyplane-specific behavior.
* **Tests**
* Added coverage for VPC configuration, networking variant selection,
and VM attachment behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-25 15:11:53 +00:00
myasnikovdaniil a1be486fb6 fix(platform): do not gate cert-manager-issuers on ClusterIssuer readiness (#5210)
## What this PR does

This PR makes the cert-manager-issuers release stop waiting for
ClusterIssuers to become Ready. ClusterIssuer is Ready only after
cert-manager registered an ACME account with the CA, so when
letsencrypt-stage can't reach the staging endpoint, helm upgrade of the
release hangs until timeout with `timeout waiting for:
[ClusterIssuer/letsencrypt-stage status: 'InProgress']`. The release
stays not Ready and every package that dependsOn cozystack.cert-manager
stays in DependencyNotReady, even when letsencrypt-prod works and all
certificates are already issued.

Fix is `healthCheckExprs` with `current: "true"` for ClusterIssuer on
the component, the same mechanism vm-default-images uses. It covers the
prod issuer too, I did not special-case staging because the wait is the
same.

Issuers keep their own status and retry registration, so they start
issuing when the CA is back. Certificate requests that come before that
stay Pending with `IssuerNotReady`, they are not failed.

Downside is that unreachable CA no longer shows up as non-Ready Package.
Only signal left is ClusterIssuer's own Ready condition and Certificates
at `Ready=False`, and there is no alert on ClusterIssuer in monitoring
packages yet.

On a cluster where the release is already stuck, the running upgrade has
to time out first (10m by default), then the retry uses the new spec.

letsencrypt-stage is still rendered on every cluster. Making it optional
needs a migration, because the issuers carry
`platform.cozystack.io/no-delete`, so it is not part of this PR.

Checked on a 3-node dev cluster running v1.7.0. I made the staging ACME
host unreachable from the cert-manager controller, so letsencrypt-stage
went to Ready=False with ErrRegisterACMEAccount, and forced an upgrade
of cert-manager-issuers. Without the expression the release hung in the
upgrade action and 23 releases went to DependencyNotReady within 15
seconds (67 of 124 at the peak). I then added the expression to the
PackageSource by hand, since I did not install a build of this branch.
The stuck upgrade ran until its timeout, the retry came right after it
and the release was Ready within 2 seconds, a second forced upgrade took
8 seconds, and all 124 releases converged with letsencrypt-stage still
False. After I made the host reachable again the issuer registered by
itself in about 30 seconds.

### Screenshots

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
fix(platform): the cert-manager-issuers release no longer waits for ClusterIssuers to become Ready, so an unreachable ACME endpoint (staging included) does not hold other platform packages in DependencyNotReady.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Updated cert-manager issuer release checks to use the ClusterIssuer’s
current status and polling. Releases are no longer held up by ACME
readiness, which can remain unavailable even when issuance may recover
without intervention. This also helps prevent dependent packages from
being delayed while waiting for ACME services to become reachable.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-25 18:23:05 +05:00
toribru 9bb661408a refactor(tenant): make gateway a plain bool
Assisted-by: LLM
Signed-off-by: toribru <161638395+toribru@users.noreply.github.com>
2026-11-25 16:08:29 +03:00
Timofei Larkin 37486083b9 feat(vm-instance): choose a cozyplane route table
cozyplane routes a pod by the RouteTable its sdn.cozystack.io/route-table
annotation names, and the VPC's default table when it names none. A VM
had no way to pass one, so a route such as 0/0 to the internet could only
be reached by annotating the VM by hand. routeTable renders the
annotation next to the VPC one, and fails the render where no VPC or no
cozyplane would read it.

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-25 12:00:48 +01:00
Timofei Larkin a24bdb758b feat(vm-instance): join a cozyplane VPC by pod annotation
On the cozyplane networking variant there is no multus, so a VM that
listed a network rendered a multus attachment that can never resolve
and sat Pending forever. When the cluster serves sdn.cozystack.io —
detected by API discovery, the same way the Kube-OVN IP pinning is —
the chart now stamps sdn.cozystack.io/vpc:
virtualprivatecloud-<networks[0].name> on the virt-launcher pod (the
bare name resolves in the VM's own namespace) and renders no multus
networks and no secondary interfaces: the VM keeps its single pod
interface and the CNI gives it its VPC identity. A cozyplane pod joins
exactly one VPC, so more than one network entry fails the render by
name rather than attaching silently to the first. The Cilium-variant
multus path is unchanged, and the suite pins both branches.

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-25 12:00:48 +01:00
Timofei Larkin e4ac5dbb9c feat(vpc): cozyplane variant of the VPC application
The kubevirt flavor of virtualprivatecloud is kube-ovn/multus-backed,
so the cozyplane networking variant skipped it and the
VirtualPrivateCloud catalog kind was simply absent there. This adds an
alternative flavor serving the same kind from sdn.cozystack.io: the
chart creates a namespaced VPC, the owner-namespace VPCBinding
(attachment is default-deny even for the owner), one VPCPeering half
per declared peer, and an optional VPCGateway as the north-south
boundary.

Delivery follows the networking variant: the PackageSource gains a
cozyplane variant whose ordering edge is the aggregated sdn apiserver
instead of multus, the iaas bundle selects the flavor by
networkingVariant, and virtualprivatecloud-rd installs the matching
ApplicationDefinition. Each flavor's definition must point at its own
variant's ExternalArtifact, which is why hack/update-crd.sh now honors
VARIANT from the environment instead of always reading variants[0].

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-25 12:00:48 +01:00
Aleksei Sviridkin 30ce2a3cb1 fix(postgres): move tenant PostgreSQL to patched standard-trixie images (#5405)
## What this PR does

Moves the tenant `postgres` application to PostgreSQL minors that fix
CVE-2026-116331, and makes the upgrade repair the indexes that the move
can break.

### Why the images change

CVE-2026-116331 is a type confusion in the min/max aggregate
optimisation: a role that can create objects runs code as the operating
system user of the server. Tenants hold such roles, so this application
is the exposed one. The fixed minors are 18.7, 17.12, 16.16, 15.20 and
14.25.

The default flavor pins bare image tags (`postgresql:17.7`). A bare tag
is the `system` variant on Debian bullseye, and upstream stopped
building it: the fixed minors are published for bookworm and trixie
only. This PR takes `standard-trixie`: the standard variant, because
backups go through the barman-cloud plugin and need none of the barman
binaries the `system` variant adds, and trixie, because the postgis
flavor is on it already, so both image families share one Debian
release. `hack/update-versions.sh` selects bare tags, so it would have
settled on 17.11 and 18.6, which are still affected.

This PR:

- pins `<minor>-standard-trixie` for the default flavor and bumps every
major to its fixed minor;
- bumps the postgis flavor to the same minors (it was already on
`standard-trixie`), which moves PostGIS from 3.6.1 to 3.7.0;
- teaches `hack/update-versions.sh` to pick minors from
`standard-trixie` tags.

PostgreSQL 13 has no fixed release. It keeps the minor 13.22 and stays
exposed to the CVE, and it moves to the trixie variant with every other
major, so it takes the base image change and the index rebuild without
getting the fix. 14.25 is the last release of the 14 line.

### Why the upgrade needs a repair step

For a running default-flavor cluster the image moves from bullseye to
trixie, so glibc goes from 2.31 to 2.41 and ICU's collator version from
153.14 to 153.128 under an existing data directory. An index ordered by
a collation of either library is then ordered by rules the server no
longer applies. PostgreSQL only logs a warning.

Reproduced on a live cluster with 60 000 rows of mixed Unicode text:

| Index collation | After the image change |
|---|---|
| `C` (what the chart creates by default) | intact |
| libc `en_US.utf8` | intact on this data, version mismatch warning |
| ICU `en-x-icu` | `amcheck`: item order invariant violated; 2 604 rows
not found through the index |

A database the chart created with its defaults uses `C` and is not
affected. A tenant who declared `COLLATE` on a column, used an ICU
collation, or created a database with a locale is.

### What the init Job does now

The post-install/post-upgrade Job gets one more pass. It runs after the
passes that manage roles and databases, so a rebuild that fails or runs
out of time costs none of them. In every connectable database it:

1. finds the indexes that depend on a collation whose recorded library
version differs from the one the server reports. PostgreSQL records a
collation for an index only where it orders a key, so the collations of
the columns an index reads in its expressions and its predicate count as
well;
2. rebuilds them with `REINDEX INDEX CONCURRENTLY` (plain `REINDEX` for
an exclusion constraint's index, which cannot be rebuilt concurrently,
so its table is neither read nor written meanwhile);
3. refreshes the recorded versions with `ALTER COLLATION ... REFRESH
VERSION` and `ALTER DATABASE ... REFRESH COLLATION VERSION`, once every
rebuild in that database succeeded.

**Timing.** Helm runs the hook as soon as the `Cluster` is patched,
while CloudNativePG is still rolling the instances, so the primary can
answer from the old image for minutes. The Job runs the new image, so it
waits until the server reports the same PostgreSQL version and Debian
release as its own `psql`. The rebuild counter of the package is left
out, because a tag is rebuilt in place and the Job can pull a newer
rebuild than the instances run. It waits only when an index depends on a
versioned collation; a cluster with nothing to rebuild is not delayed.

**Retries.** `REINDEX CONCURRENTLY` gives an index a new OID, so the
highest OID seen when a repair begins separates the indexes still to
rebuild from the ones already done. That mark is kept as a setting of
the database (`cozystack.collation_repair`) with a fingerprint of the
stale collations and the list of indexes rebuilt in place, and removed
when the repair is complete. A retry therefore continues instead of
starting over.

**Failures.** A rebuild that fails does not stop the others. The pass
reports the failures and exits non-zero at the end. A failed or
interrupted `REINDEX CONCURRENTLY` leaves an invalid `_ccnew` index on
the table; two of those mean two runs failed there, and the pass then
leaves that table's stale indexes to an operator instead of scanning the
table again on every retry. A rebuild that succeeds drops the leftovers;
dropping them by hand lets the next run try again. An in-place rebuild
leaves no such trace, so the setting records each attempt with the
index's storage file: a changed file means the index was rebuilt, by a
run or by hand, and two attempts on the same file leave it to an
operator. A rebuild that waits for a lock behind an open transaction
gives up when the Job runs out of time, and an in-place rebuild is cut
off at the same point, so no backend is left waiting or holding the
table after the Job is gone. A concurrent rebuild that is already
running is not cut short.

**Privileges.** The Job connects as the superuser, so every session of
the pass sets `search_path` to `pg_catalog, pg_temp`. A function or
operator that a tenant defined in `public` cannot be picked in place of
a built-in.

**Before PostgreSQL 15** the server records no version for a database's
default collation. The version recorded for the libc collation of the
same locale stands in for it; the two are matched as glibc matches them,
so `en_US.UTF-8` finds `en_US.utf8`. A locale with no such collation
cannot be checked, and a run that saw the image change says so in a
warning that names the database.

**Range partition keys.** Rebuilding an index does not move a row to the
partition the new ordering assigns it. A collation that such a key
depends on keeps its recorded version, so PostgreSQL keeps logging the
mismatch, and the Job prints a warning that names the table on every
run. Its indexes are still rebuilt, once.

The pass is driven by the version mismatch, not by this particular image
change, so it also applies to later glibc or ICU bumps.

### Verified

`helm unittest` passes for the chart (236 tests). The e2e suite gains a
step that creates a collation with a stale version, upgrades the release
and checks that the index was rebuilt and the version refreshed.

On a live cluster, applications were installed from the v1.7.0 chart and
upgraded with this change applied on top of v1.7.0. Each had a client
holding a connection, which is what makes the primary restart take
minutes.

| Case | Outcome |
|---|---|
| v17, two instances, default `C` collation only | Job finished in 15 s
without waiting; data identical; `amcheck` clean |
| v17, two instances, ICU, libc, expression, unique, exclusion and
partition indexes | Job waited about 3.5 min for the primary, rebuilt
seven indexes; `amcheck` clean; every row found through the ICU index
again (run with the first revision of the pass) |
| v17, two instances, backups to the system bucket | a backup taken
before and one taken after the upgrade both succeed; WAL archiving
continues with no failed segment, so the barman-cloud plugin covers the
binaries the `standard` variant lacks |
| v18, an application that had been running for months (18.1 to 18.7) |
row counts identical; `amcheck` clean |
| v14 (14.20 to 14.25) and v13 (13.22, base image only) with the same
index set | Job waited, rebuilt six indexes; `amcheck` clean |

The pass itself was also run against a live server for the cases an
upgrade does not produce on demand:

- a second run does nothing;
- a failed rebuild leaves the other indexes rebuilt, and a later run
rebuilds only the failed one;
- after two failed runs the index is left alone until it is rebuilt by
hand, and the pass then completes;
- an exclusion constraint's index is rebuilt in place once, not again by
a retry; when a writer blocks it twice it is left alone, and after a
manual `REINDEX INDEX` the pass completes;
- a collation under a range partition key stays stale and its indexes
are not rebuilt twice;
- a rebuild blocked by an open transaction fails on its lock wait and
leaves no waiting backend; it succeeds once the transaction ends;
- a tenant function named like a built-in is not called by the pass,
while a session with the default `search_path` does call it;
- on PostgreSQL 14 an index on the database default collation is
rebuilt, also when the locale is spelled `en_US.UTF-8`, and a database
with a locale that has no stand-in gets the warning only in a run that
saw the image change;
- an index whose expression or partial-index predicate reads a column of
a stale collation is rebuilt, although PostgreSQL records no collation
for it.

### Known limits

- **A window of wrong results.** Between the primary restart and the end
of the rebuild, queries through an affected index can miss rows and a
unique index can accept a duplicate. The index cannot be built ahead of
time, because it has to be built by the new library. A duplicate that
slipped in makes that index's rebuild fail until the duplicate is
removed.
- **The hook budget.** The wait ends 120 seconds before the Job's
deadline. A roll that takes longer fails the Job, and the next run finds
the server ready. One index must be rebuilt within one run of the Job. A
very large index on a non-`C` collation does not fit that: after two
attempts the pass stops trying and asks for a manual `REINDEX`, and the
release stays failed until then.
- **Range partition keys** are reported, not repaired.
- **Other dependents** of a collation, such as `CHECK` constraints and
materialized views, are not examined.
- **PostgreSQL 13 and 14, default collation.** A database whose locale
has no libc collation in the catalog has no stand-in. Its
default-collation indexes are not rebuilt; the Job warns about it and
names `REINDEX DATABASE` as the remedy.
- **Collations inside expressions.** An index is found through the
collations that order its keys and through the columns its expressions
and predicate read. A collation that an expression applies to a column
of another collation, with `COLLATE` inside the expression, leaves no
trace in the catalog and is missed.
- **The wait is not in the e2e suite.** The e2e step does not swap the
image, so it runs the rebuild but not the wait for the roll. That part
is covered by the live runs above.
- **PostGIS 3.6.1 to 3.7.0** on the postgis flavor is not exercised
here.
- **Upstream `REINDEX` advice for these minors** is not automated. The
17.12 [release
notes](https://www.postgresql.org/docs/17/release-17-12.html) ask for a
`REINDEX` of btree indexes on unconstrained `bpchar` columns and of
`gist_trgm_ops` indexes, among others.

The flavor guard is unchanged in behaviour; its comment and messages no
longer claim that the two image families always differ in Debian
release.

### Screenshots

N/A — no UI changes.

### Downstream repositories

Walked the trigger map against the diff: two version maps, the image
template, the init script, a comment in `db.yaml`, the version update
script and one unit test of `packages/apps/postgres`, plus one e2e
suite. The `version` enum, `values.yaml`, `values.schema.json`, the
README, the `ApplicationDefinition` and the release prefix are
untouched.

- [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): tenant PostgreSQL moves to the minors that fix CVE-2026-116331 (18.7, 17.12, 16.16, 15.20, 14.25) on the standard-trixie image variant. Upgrading rolls every Postgres instance.

- PostgreSQL 13 has no fixed release: it keeps 13.22 and stays exposed to CVE-2026-116331, and it still takes the image move and the index rebuild described below. 14.25 is the last release of the 14 line. Plan a move to a newer major for clusters on 13 and 14.
- For the default flavor the image moves from Debian bullseye to trixie, which changes glibc and ICU. The upgrade rebuilds the indexes that depend on a non-C collation. Until that rebuild finishes such an index can return incomplete results and a unique one can accept duplicates, so plan a maintenance window if you use ICU or locale-specific collations. Databases created with the chart defaults use the C collation and are not affected.
- An exclusion constraint's index is rebuilt in place, and its table is neither read nor written meanwhile.
- When a rebuild cannot finish inside the upgrade Job, the release stays failed and the Job is retried. After two failed attempts the Job stops rebuilding that index, names it in its log and keeps failing until an operator steps in. Expect this for a large index on a non-C collation: rebuild it by hand with `REINDEX INDEX CONCURRENTLY`, drop the invalid `_ccnew` indexes the failed attempts left on its table, and the next run completes. A unique index fails the same way while it holds duplicates, which have to be removed first.
- Tables range-partitioned on a text key with a non-C collation need a manual check, after which the collation version is refreshed by hand.
- On the postgis flavor PostGIS moves from 3.6.1 to 3.7.0, and the upgrade does not update the extension in existing databases: once the new image has rolled out to the primary, run `ALTER EXTENSION postgis UPDATE` in each database that uses it.
```
2026-11-25 13:26:41 +03:00
IvanHunters 907d369813 feat(postgres): add an audit toggle for access and statement logging (#5404)
## What this PR does

Managed Postgres can already load pgaudit through the
`sharedPreloadLibraries` allowlist and set
`pgaudit.log`/`log_connections` through `postgresql.parameters`, but
that leaves an orchestrator such as a customer-facing panel depending on
internal parameter names to answer "who connected and what did they
run". This adds an `audit` block that bundles access and statement
auditing behind a single switch.

With `audit.enabled`, the chart adds `pgaudit` to
`shared_preload_libraries` and seeds `pgaudit.log` (set by `audit.log`,
default `write, ddl, role`), `log_connections` and `log_disconnections`.
The audit parameters are seeded as defaults, so an explicit
`pgaudit.log` or `log_connections` in `postgresql.parameters` still
takes precedence. The audit records go to the instance log, which the
platform log stack already collects, so they are queryable per database
by its labels without extra wiring. `audit` is off by default, and
toggling it restarts PostgreSQL because pgaudit is a preloaded library.

Postgres only; MariaDB, MongoDB and ClickHouse auditing are left for
follow-ups.

### Screenshots

Not applicable — no UI change.

### Downstream repositories

Walked the trigger map against the diff. One repository is reached:
`cozystack/terraform-provider-cozystack` hand-models each postgres
`values.schema.json` field, and this diff adds the `audit` block to that
schema, so the provider would need the field added to its postgres
schema and its expand/flatten pair. That is separate work there, tracked
in cozystack/terraform-provider-cozystack#87. The website postgres
reference page regenerates from the package `README.md` on release, so
it needs no manual follow-up, and `ansible-cozystack` carries no
postgres values key.

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: cozystack/terraform-provider-cozystack#87
- [ ]
[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
feat(postgres): managed PostgreSQL gains an `audit` toggle that enables pgaudit statement auditing and connection logging, with the audited classes set by `audit.log` (default `write, ddl, role`).
```
2026-11-25 13:16:04 +03:00
Aleksei Sviridkin 90e52bb633 test(snapshot-controller): assert the group snapshot versions consumers read
The CRD test pinned the vendored chart's layout: exactly six CRD
documents, v1beta2 as the storage version of each group snapshot CRD
and no v1alpha1. None of that is something the platform relies on, and
an upstream release that moves storage to v1 or adds a CRD would turn
the test red on a correct make update.

What the platform needs is that each group snapshot CRD serves v1,
which snapshot-controller, csi-snapshotter and the linstor gate read,
and v1beta2, which Velero 1.18 and the vm-instance hook read. The test
now asserts those two served versions, that the three volume snapshot
CRDs CDI and the CSI drivers read are rendered, and that every rendered
CRD is kept on uninstall, without counting documents. Removing either
served version, dropping a volume snapshot CRD, setting keepCRDs to
false, or rendering no CRDs fails it.

Fixes: 892d9c9b34 ("feat(platform): upgrade snapshot-controller to v8.7.0")
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-25 13:09:44 +03:00
Aleksei Sviridkin f9308e1e02 refactor(computeplane): stop copying pool defaults into the default md0
The default md0 pool wrote maxReplicas, instanceType and diskSize with
the same values the KubernetesNodes schema already defaults to, so the
pool's size lived in two places and would drift on the next change to
the pool defaults. The comment justifying the copy was wrong: the
reservation evaluator defaults stored values against the kind's own
schema, so a sparse release reserves the same as one with its defaults
written out.

md0 again names its cluster, the ingress role and the scale-from-zero
lower bound, and leaves its size to the pool defaults. The pool chart
renders byte-identical manifests from either set of values, so an
existing ComputePlane neither resizes nor rolls its default pool.

Fixes: a231f8d22b ("refactor(extra): write the ComputePlane default pool's size into its release")
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-25 12:40:22 +03:00
Aleksei Sviridkin 08c22a2f99 fix(linstor): gate group snapshots on the v1 group snapshot API
The CSIVolumeGroupSnapshot gate for csi-snapshotter and the linstor
VolumeGroupSnapshotClass were rendered only when
groupsnapshot.storage.k8s.io/v1beta2 is served. The components that
act on group snapshots read v1: csi-snapshotter v8.7.0 builds its
content and class informers on v1 and checks for those v1 kinds at
startup, snapshot-controller v8.7.0 watches all three kinds at v1, and
piraeus-operator v2.12.1 probes v1 VolumeGroupSnapshot. The chart
serves v1, v1beta1 and v1beta2 today, so the outcome is the same, but
once upstream stops serving v1beta2 the gate would switch group
snapshots off while every consumer could still use them. A
distribution that serves v1beta2 without v1 got the gate on, and
csi-snapshotter then disabled the feature at startup anyway.

The class moves to v1 with the gate. Helm matches release objects by
group and kind, so the existing class is updated in place. Velero
1.18 still reads the class at v1beta2, which the chart serves.

The comment claiming csi-snapshotter stalls with the gate on and the
API missing is replaced: v8.7.0 logs a warning and runs without group
snapshots. What the render-time gate buys is a csi-controller rollout
on the first linstor upgrade that sees the API, because csi-snapshotter
looks for it only when it starts.

Tested with helm unittest on packages/system/linstor; a cluster
serving the three kinds at v1beta2 only now renders the gate off and no
class.

Fixes: d89bce58e8 ("feat(linstor): enable VolumeGroupSnapshots for linstor-csi")
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-25 12:22:57 +03:00
Aleksei Sviridkin 2b4371dae4 fix(kubernetes): stop refusing extraOutputs hooks monitoring-agents accepts
The tenant Kubernetes application refused fluent-bit extraOutputs
unless an outputs override spelled the hook exactly as the default
outputs do, matched by a regular expression over the template text.
monitoring-agents decides the same question by rendering outputs, so
a hook written with if, or a bare {{ .Values.config.extraOutputs }},
was refused by the application although the addon renders it.

Keep a check in the application, because the addon fails in a
HelmRelease the tenant cannot read, but reduce it to whether outputs
mentions .Values.config.extraOutputs at all. That catches an override
that drops the hook and is never stricter than the addon for a hook
that names the value. It cannot be exact without executing the tenant
template, which here would run it in the management cluster; a hook
that is commented out or trims its newline is left to the addon's
render guard, which already tests both.

Fixes: 64fa40e255 ("feat(monitoring): add destinations to the agents without replacing the defaults")
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-25 12:22:24 +03:00
Aleksei Sviridkin f196ef6e4a fix(seaweedfs): stop reserving storage pool name suffixes
A storage pool named "public" or ending in "-lock", "-readonly" or
"-public" was refused outright. The check that compares the class
names each pool actually renders, against each other and against the
instance's base classes, already refuses every one of those names
that clashes with something: "public", "lock" and "readonly" clash
with the base classes, and "x-public", "x-lock" or "x-readonly" clash
only when a pool "x" exists. The suffix list on top of it refused
names that clash with nothing, such as "cdn-public" with no pool
"cdn", and had to grow, as a breaking change, with every new class
variant.

Drop the suffix list and keep the rendered-name check as the only
rule. This accepts names that were refused before and refuses none
that were accepted.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-25 12:18:40 +03:00
Andrey Kolkov b40be51a6b fix(postgres): move the default flavor to patched standard-trixie images
The default flavor pinned bare image tags, which are the system variant
on Debian bullseye. Upstream stopped building that variant, so the minors
that fix CVE-2026-116331 (18.7, 17.12, 16.16, 15.20, 14.25) are published
for bookworm and trixie only. The CVE is a type confusion in the min/max
aggregate optimisation that lets a role able to create objects run code
as the operating system user of the server, and tenants hold such roles.

Pin the patched minors on standard-trixie, and move the postgis flavor to
the same minors. The standard variant, because backups go through the
barman-cloud plugin and need none of the barman binaries the system
variant adds. trixie, because the postgis flavor is on it already, so
both image families share one Debian release. PostgreSQL 13 has no
patched release: it keeps 13.22 and moves to trixie with the rest.

For a running default-flavor cluster this changes the Debian release under
the data directory. The init Job rebuilds the indexes that depend on a
collation whose library version changed.

Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-25 15:55:03 +07:00
Andrey Kolkov a10e449a56 fix(postgres): rebuild indexes whose collation changed version
An operand image built on another Debian release ships another glibc and
ICU. An index ordered by a collation of either library is then ordered by
rules the server no longer applies: lookups through it miss rows, and a
unique index stops seeing duplicates. PostgreSQL only logs a warning.

The init Job compares the library version each collation was created with
against the one the server reports, rebuilds the indexes that depend on a
collation whose version changed, and refreshes the recorded versions once
every rebuild in the database succeeded. A database on the C or POSIX
collation with no explicitly collated index, which is what the chart
creates by default, has nothing to rebuild and is not delayed.

The pass has to hold on a hook that starts while the instances are still
rolling, runs as the superuser in databases tenants own, and is retried
after a failure:

- It runs after the passes that manage roles and databases, so that a
  rebuild that fails costs none of them, and it waits for the server to
  report the PostgreSQL version and Debian release of its own image when
  an index depends on a versioned collation. The rebuild counter of the
  package is left out of that comparison, because a tag is rebuilt in
  place.
- Every session pins search_path to pg_catalog, so that a function or an
  operator a tenant defined in public cannot stand in for a built-in.
- A retry continues where the last run stopped. REINDEX CONCURRENTLY gives
  an index a new OID, so the highest OID seen when a repair begins marks
  what is left; an index rebuilt in place keeps its OID and is told apart
  by its storage file. Both live in a setting of the database.
- A rebuild that cannot finish is not started for ever: after two
  attempts the index is left to an operator, the pass says how to clear
  it, and the release stays failed until then. Lock waits and in-place
  rebuilds are bounded by what is left of the Job.
- A collation that a range partition key depends on keeps its recorded
  version, because rebuilding an index moves no row between partitions.

PostgreSQL records a collation for an index only where it orders a key,
so the collations of the columns an index reads in its expressions and
predicate count as well. Before PostgreSQL 15 the server records no
version for a database's default collation, and the libc collation of the
same locale stands in for it.

The e2e suite creates a collation with a stale version and checks that an
upgrade rebuilds a unique index and an exclusion constraint's index on it,
refreshes the version and removes the repair setting.

Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-25 15:55:03 +07:00
Aleksei Sviridkin ba0ff0f8e8 fix(kafka)!: require SCRAM-SHA-512 on the external listener (#5156)
<!-- 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

With `external: true` the chart renders a Strimzi listener `external` on
port 9094, `type: loadbalancer`, with TLS on by default but **no
`authentication` block**. Anyone who can reach the public LoadBalancer
address can produce and consume on every topic; TLS only encrypts the
session. The entity operator's User Operator is already deployed, but
nothing declares a KafkaUser.

This PR:

- adds `authentication: {type: scram-sha-512}` to the `external`
listener. The internal listeners (9092 plain, 9093 TLS) are unchanged;
- adds a `users` map. Each key renders a `KafkaUser`
(`kafka.strimzi.io/v1`, `strimzi.io/cluster: <release>`,
`authentication.type: scram-sha-512`) named `<release>.<user>`; the dot
keeps it from spelling any Secret Strimzi derives from a cluster name,
this release's or another's. That name is also the SCRAM username and
the name of the Secret into which the User Operator writes the generated
password (`password`, `sasl.jaas.config`). The release prefix keeps two
Kafka instances in one tenant namespace from colliding;
- refuses user names that are not valid object names;
- lets the tenant read each user's Secret via the existing
`<release>-dashboard-resources` Role, and shows it in the tenant-secret
API: the Kafka ApplicationDefinition selects Secrets labelled
`strimzi.io/kind: KafkaUser`. The instance scope comes from the Secret's
ownership; a templated label value would never match, since only
`resourceNames` are rendered
(`internal/lineagecontrollerwebhook/kafka_rd_secrets_test.go` runs the
Strimzi Secrets through the matcher);
- rewrites the `tls.enabled` description, which said Strimzi provides no
authentication on this listener. Without TLS the data and the SCRAM
exchange are exposed, not the password itself;
- documents the client settings (SASL, truststore from
`<release>-cluster-ca-cert`) and two upgrade sequences in the README.

Passwords are always generated by Strimzi. I did not add a `password`
field like RabbitMQ's; that can come later.

**Known limit:** no ACLs. The cluster has no `authorization`, so every
authenticated user can read and write every topic. Per-user ACLs are a
follow-up.

**Breaking:** an instance with external access refuses unauthenticated
clients after the upgrade. The previous chart cannot create the users
from `users`, so the README gives two sequences: a maintenance window
(declare `users`, upgrade, then configure clients), or credentials
staged ahead by a cluster administrator through `KafkaUser` objects
carrying Helm's ownership metadata, which the upgrade adopts with their
passwords unchanged. Neither has been run on a live cluster.

**Tests**
- New `tests/external_authentication_test.yaml` (11 cases).
- The listener assertions in `kafka_test.yaml` and `kafka_tls_test.yaml`
now include the `authentication` block.
- `helm unittest packages/apps/kafka`: 114 passed.
- Not deployed on a live cluster.

**Backport:** none. Refusing existing clients after an upgrade does not
belong in a patch release, so this stays on `main` and lands in the next
minor (`backport/skip`).


### 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:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: cozystack/terraform-provider-cozystack#86 (issue: model the
`users` map on the Kafka resource and data source)
- [ ]
[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(kafka)!: the external listener (port 9094, enabled by external: true) now requires SCRAM-SHA-512 authentication instead of accepting anonymous clients. Declare clients in the new users map; each gets a KafkaUser named <release>.<user> whose generated password is in the Secret of the same name. External clients of an instance with external access are refused after the upgrade until they authenticate; see "Upgrading an instance that has external access" in the Kafka README for a maintenance-window sequence and one that stages the credentials ahead.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Configure SCRAM-SHA-512 users for external Kafka access. Each user
receives generated credentials and read/write access to all topics;
credential Secrets are available to tenant resources.
  * Invalid, reserved, or overlong user names are rejected.
* **Documentation**
* Clarified that external access requires SCRAM-SHA-512 authentication,
even when TLS is disabled. Without TLS, data is unencrypted and the
authentication exchange is exposed, but the password is not.
* Added external-client connection guidance, certificate trust
information, and upgrade instructions for configuring credentials.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-25 01:23:22 +03:00
Mattia Eleuteri d65fe65f0f fix(kubernetes): refuse Proxmox template tags naming another Talos
On Proxmox the template the tags select is the worker's boot disk, and
talos.version reaches only the installer in the machineconfig. The bump
of the default changes that machineconfig and rolls every pool, so a
pool still tagged for the previous release would clone the old template
and keep the vulnerable kernel while its config names the fixed one.
The template script tags each template talos-<version>, which is the
one link the chart can check; a tag set naming no release is left to
the operator.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-24 21:12:05 +03:00
Mattia Eleuteri 470e4c55a7 fix(kubernetes): bump tenant worker Talos to v1.13.12 (CVE-2026-99999)
Tenant worker VMs default to Talos v1.13.6, whose kernel predates the
upstream fix for CVE-2026-99999 (PwnEscape), Linux commit 6785011f8b16
("ipv4: validate checksum_start before completing checksum"). The bug
lets a guest escape into its host, and a tenant worker is a host
whenever the tenant runs nested virtualization inside it. The fix was
backported in Linux 6.18.57, which Talos v1.13.12 ships.

The workers stay on the v1.13 line rather than following the host
nodes to v1.14: Talos v1.14 drops Kubernetes 1.31 and 1.32, which the
tenant chart still offers, so a v1.14 default would fail the
support-matrix guard and break the render of those clusters. The v1.13
matrix entry is unchanged.

The new release changes the worker machine config and the golden image
name, so the content-hashed TalosConfigTemplate names and the default
golden DataVolume name pinned in the chart tests move with it.

Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
Assisted-by: LLM
2026-11-24 21:12:05 +03:00
Aleksei Sviridkin 7b9b4347b2 fix(ingress-nginx): turn off TLS session tickets for CVE-2026-97629 (#5407)
## What this PR does

Turns off TLS session tickets in the ingress-nginx controller
(`ssl-session-tickets: "false"`).

[CVE-2026-97629](https://nginx.org/en/security_advisories.html): with
session tickets on and no fixed ticket key, nginx rotates its ticket
keys and, before 1.30.6 and 1.31.7, leaves one of them uninitialized in
the worker processes, which may allow a session to be forged. The
platform sets tickets on and no `ssl-session-ticket-key`, so it runs
exactly that path, and the controller nginx 1.25.5 does not carry the
fix ([`fdedba03`](https://github.com/nginx/nginx/commit/fdedba031b))
yet. It will come with the next rebuild of the controller image; this
change closes the hole without waiting for it.

What it costs is small. TLS session resumption keeps working through
`ssl_session_cache`, which the controller has on. And with no fixed
ticket key every pod had its own keys, so a ticket never resumed a
session on another replica anyway.

`make test` in the chart passes.

### Screenshots

N/A, no UI changes.

### Downstream repositories

Walked the trigger map against the diff: one controller ConfigMap value
in `packages/system/ingress-nginx/values.yaml`. No package, platform
values key, schema or app README changes.

- [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(ingress-nginx): TLS session tickets are turned off in the ingress-nginx controller (CVE-2026-97629). TLS session resumption keeps working through the shared session cache.
```



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Security**
* SSL session tickets are now disabled for ingress connections. TLS
session resumption remains available through the shared session cache,
so existing session reuse behavior continues without session tickets.
This changes how session resumption is handled while preserving the
cache-based option.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-24 20:50:13 +03:00
Andrei Kvapil 3002f3183b fix(ingress-nginx): turn off TLS session tickets for CVE-2026-97629
With tickets on and no fixed ticket key, nginx rotates the keys and,
before 1.30.6 and 1.31.7, leaves one of them uninitialized in the
worker processes, which may let a session be forged. The controller's
nginx 1.25.5 does not have the fix yet. Resumption still works through
the shared session cache, and with no fixed key tickets never resumed
across replicas anyway.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-24 17:19:40 +01:00
Aleksei Sviridkin 442768abb7 feat(kubernetes): give each tenant Kubernetes cluster its own etcd (#4817)
## What this PR does

A tenant Kubernetes cluster could not start until an ancestor `Tenant`
had `spec.etcd: true`. The chart read the datastore name from
`_namespace.etcd` and, with none, rendered only a
`<release>-awaiting-etcd` ConfigMap. Every cluster below that tenant
then shared one etcd, one CA and one disk, separated by key prefix only.
Whoever creates a cluster usually may not edit the `Tenant`, so anything
ordering clusters on a tenant's behalf (the portal's controller, for
one) had to flip `etcd: true` first.

This PR makes the `Kubernetes` application carry its own etcd. It
implements phases 1 and 2 of the per-cluster etcd design proposal,
[cozystack/community#25](https://github.com/cozystack/community/pull/25),
as three commits that can be split later:

1. `refactor(etcd)`: the etcd chart's `EtcdCluster`, cert-manager PKI,
`DataStore`, `WorkloadMonitor`, defrag `CronJob`, VPA and `VMPodScrape`
move into named templates in `cozy-lib`
(`packages/library/cozy-lib/templates/_etcd.tpl`), parameterised by the
cluster name. `packages/extra/etcd` calls them with `"etcd"`, and its
rendered output is byte-identical before and after (see Verification).
2. `feat(kubernetes)`: a new cluster renders its own `EtcdCluster` and
`DataStore` from those templates, and a cluster that already runs on a
shared tenant etcd keeps it.
3. `feat(platform)`: migration 63 → 64 reports which clusters stay on a
shared etcd and changes nothing.

Phases 3 and 4 (deprecating, then removing `Tenant.spec.etcd`,
`_namespace.etcd` and `cozy-lib.ns-etcd`) are left for later.

### Design

**Names.** For release `kubernetes-<name>` in namespace `<ns>`:

| Object | Name |
|---|---|
| `EtcdCluster`, its headless Service, members `<…>-xxxxx`, `<…>-client`
Service | `kubernetes-<name>-etcd` |
| Secrets | `kubernetes-<name>-etcd-{ca,client,server,peer,peer-ca}-tls`
|
| `DataStore` (cluster-scoped) | `<ns>.kubernetes-<name>` |
| DataStore endpoint | `kubernetes-<name>-etcd.<ns>.svc:2379` |

**Shared templates.** `cozy-lib.etcd.cluster` takes optional `labels`
and `annotations` and renders them into the `EtcdCluster`'s
`spec.additionalMetadata`, which etcd-operator copies onto every member
Pod and PVC. With neither set, it renders no `additionalMetadata` at
all.

**Values.** One new field, `etcd.replicas`: `3` (default) or `1`. The
schema bounds it to 1..3 and the chart refuses 2 at render time. Size
(4Gi), resources (1000m / 512Mi limits to start with) and the etcd
version (3.6.11, the etcd chart's default) are chart-internal. Where a
VerticalPodAutoscaler runs, it sizes each member's requests as it is
recreated, up to 5000m CPU / 8Gi memory divided by the platform's CPU
and memory allocation ratios (500m / 8Gi at the default ratios of 10 and
1), with the limits scaled in proportion; NOTES.txt and the README say
so.

**StorageClass.** Two new platform values,
`kubernetesEtcd.storageClassLocal` and
`kubernetesEtcd.storageClassReplicated`, reach the chart as
`_cluster.etcd-storage-class-local` (used with 3 members) and
`_cluster.etcd-storage-class-replicated` (used with 1 member). Empty
keys fall back to the namespace default StorageClass.
`spec.storage.storageClassName` is immutable on an `EtcdCluster`, so the
chart reads the live object's class on every render after the first and
never re-derives it; scaling 1 → 3 keeps the class the cluster started
with. Dropping from 3 members to 1 is refused at render time when the
etcd is on the class the platform names for 3 members, or off the class
it names for 1, because a single member would then hold the only copy of
the control-plane state on storage that does not replicate it. An etcd
that was created with one member keeps rendering whatever its class.

**New clusters vs existing ones.** The chart decides from the live
`KamajiControlPlane`, looked up by release name:

- no `KamajiControlPlane`, or one whose `spec.dataStoreName` is the
cluster's own name: own etcd;
- one that names any other `DataStore`: that `DataStore` is kept, and
the chart renders no etcd of its own.

Clusters stuck in the old awaiting-etcd state have no
`KamajiControlPlane`, so they get their own etcd on their next
reconcile. `_namespace.etcd` is deliberately not the signal.
`packages/system/cozystack-basics/templates/cozystack-values-secret.yaml`
hardcodes `etcd: tenant-root`, and
`packages/apps/tenant/templates/namespace.yaml` passes it down, so every
tenant publishes a value whether or not an etcd runs behind it.
Honouring it for new clusters would change nothing for anyone. Following
it for existing clusters is also wrong: today, switching on `spec.etcd`
for a mid-level tenant silently moves every cluster below it to a new
datastore, which is a Kamaji datastore migration. With this PR, the live
binding sticks.

An existing cluster renders exactly what it rendered before, pre-delete
hook included, apart from randomly generated Talos tokens, so the
upgrade rolls no control-plane pods. New clusters carry
`policy.cozystack.io/allow-to-etcd-cluster` instead of
`policy.cozystack.io/allow-to-etcd`, which only admits a cluster to its
tenant's shared etcd.

Both lookups the decision rests on read the chart's own live objects:
the binding its `KamajiControlPlane` already records, and the immutable
`storageClassName` of its `EtcdCluster`. Each gives the same output on
every render, and their empty branch is the new-cluster render offline
`helm template` sees, which is the kind of `lookup` the chart guidelines
allow.

**What goes away.** The `awaiting-etcd` beacon goes, along with the
`_namespace.etcd` gate on the ~25 addon and satellite templates
(`helmreleases/*`, `csi/deploy.yaml`, `kccm/manager.yaml`,
`cluster-autoscaler/deployment.yaml`, `ingress.yaml`, the Proxmox CCM
and CSI). A datastore now always exists, so these gates were always
true.

**Deletion.** The pre-delete hook deletes the `TenantControlPlane` and
waits up to 120s, and it exits 0 whatever is left, because a failing
pre-delete hook keeps the release and retries the same teardown; the one
exception is below. Kamaji's `finalizer.kamaji.clastix.io` drops the
tenant's etcd role, prefix and user and the datastore-config Secret's
finalizer, and it runs only while the `DataStore` is Ready and answers,
so a `TenantControlPlane` whose own etcd never came up or has lost
quorum would never finish deleting. On a cluster that owns its etcd,
those three objects live in the etcd this uninstall deletes next. So
when such a `TenantControlPlane` outlives the wait, the hook (Step 4a)
removes that one finalizer with a JSON patch that tests it at the index
it was read at, waits another 60s, and lets Step 4b clear the Secret's
finalizer as before. A `TenantControlPlane` on a shared `DataStore` is
left to Kamaji, since that etcd outlives the cluster. The hook also
deletes the etcd's five Certificates and then their Secrets (Step 8),
which cert-manager issues without an owner, in the same order and for
the same reason as Step 7 deletes the Talos PKI. Then:

- Helm removes the `EtcdCluster`, `DataStore` and the remaining objects;
- the member PVCs go by garbage collection, because the operator owns
them through the `EtcdMember`s.

If Step 4a's patch is rejected, or the `TenantControlPlane` cannot be
read, the hook prints its residue summary and fails before Step 8: Helm
would otherwise delete the etcd while Kamaji's finalizer still waits on
it, so the uninstall is retried with the etcd and its PKI in place.
Steps 4a and 8, that check and their RBAC (a `patch` on this release's
`TenantControlPlane`, and `delete` on the etcd Certificates and Secrets
by name) render only for a cluster that owns its etcd.

### Deviations from cozystack/community#25

- **DataStore name** is `<namespace>.<release>`, not
`<namespace>-<release>`. Tenant names are alphanumeric and nest with
dashes, so the dashed form collides: Kubernetes `foo` in `tenant-a`
gives `tenant-a-kubernetes-foo`, which is also the namespace, and
therefore the shared `DataStore` name, of tenant `foo` under tenant
`kubernetes` under `tenant-a`. A namespace cannot contain a dot. Kamaji
copies the `DataStore` name into the pod label
`component.kamaji.clastix.io/datastore`, so the name is capped at 63
characters, truncated with an 8-character hash past that.
- **No truncate-and-hash for `kubernetes.etcdName`.** The app name is
now capped at 32 characters (`@maxLength 32`, added with the nodes
split), so `kubernetes-<name>-etcd` is at most 48 characters. That is
inside the 56 the operator needs: the `<name>-client` Service and the
generated member names must fit in 63. The helper fails the render past
56 rather than rename anything.
- **"Honour an explicit `_namespace.etcd`"** means keeping a cluster on
the `DataStore` its live control plane names, for the reason above. It
does not mean following `_namespace.etcd` for new clusters.
- **`etcd.replicas` validation** is a schema range of 1..3 plus a
render-time refusal of 2, rather than a schema enum. `cozyvalues-gen`
v1.7.0, the version CI pins and the latest release, emits string members
for an integer enum, which would reject the default `3`. The aggregated
API does not validate an application's spec against its schema at all,
so neither an enum nor a CEL rule would refuse 2 at admission; Helm's
`values.schema.json` check and the render are where it is refused.
- **The delete-hook branch** keys on the same live-`KamajiControlPlane`
condition as the render, as #25 asks, and additionally checks at run
time that the `TenantControlPlane` names this cluster's own `DataStore`
before touching Kamaji's finalizer. Helm deletes release resources only
after the pre-delete hook, so the etcd outlives Kamaji's normal
finalization without any ordering inside the hook.
- **TLS** reuses the etcd chart's `secretRef` shape (chart-issued
certificates) rather than the operator's `certManager` mode. Kamaji's
`DataStore` needs the CA private key to sign each tenant's client
certificate, and `secretRef` keeps that key in a Secret the chart
controls. The server certificate also carries the operator's
`<name>-client` Service names, which the etcd chart's does not.
- **Satellites.** The `PrometheusRule` stays in the etcd chart only, so
a cluster's own etcd has no alert rules. `VMPodScrape`, VPA and the
`CiliumNetworkPolicy` render only where their APIs are served. The etcd
chart's `VMPodScrape` now selects `app.kubernetes.io/instance: etcd`
instead of `app.kubernetes.io/name: etcd`: etcd-operator stamps the
latter on every member it runs, so a tenant etcd would otherwise also
scrape the cluster etcds in its namespace and count their members as its
own.
- **Name budget.** The defrag `CronJob` is `<etcd name>-defrag`, which
reaches 55 characters for a 32-character app name while the apiserver
caps CronJob names at 52; past 52 the template truncates it and appends
an 8-character hash. The etcd chart's `etcd-defrag` is unaffected.
- **Defrag image.** The defrag container pulls
`ghcr.io/ahrtr/etcd-defrag:v0.13.0` through `cozy-lib.image`, pinned to
the multi-architecture index digest, so a configured registry mirror
applies; `_etcd.tpl` is tracked by Renovate and listed in
`IMAGE_REF_EXTRA_FILES`. This changes the etcd chart's CronJob too,
after the extraction commit. Contributed by @yankawai in #5387 and
folded in.
- **Migration.** The opt-in migration runbook is not implemented here
(see below), and no `talosconfig` is issued. The numbered migration only
reports, as #25 suggests.

### Gaps #25 did not cover

- **Backups.** Covered through the `Kubernetes` backup strategy (#4931),
which `cozy-default` routes `apps.cozystack.io/Kubernetes` to. It
resolves the datastore from the `TenantControlPlane`, so it dumps the
cluster's key prefix from its own etcd or a shared one alike. Its dump
Job runs in the application namespace, and the deny policy below would
refuse it, so the strategy's pod template now carries
`policy.cozystack.io/allow-to-etcd-cluster: {{ .Release.Prefix }}{{
.Release.Name }}-etcd`, which is inert for a cluster on a shared etcd.
The strategy's Velero half does not select the etcd's PVCs or TLS
Secrets and does not need to: the dump restores into whatever etcd the
control plane runs on.
- **Per-cluster network policy.** A `CiliumNetworkPolicy` named after
the etcd selects its member pods with `ingressDeny` on 2379/2380 against
two sets of pods and one entity. The first is pods in the tenant
namespace that are neither members nor carry
`policy.cozystack.io/allow-to-etcd-cluster: <etcd name>`, a label set on
the control-plane pods, the defrag Job and the backup dump Job. The
second is pods in any other namespace except `kube-system` and
namespaces labelled `cozystack.io/system: "true"`, which is where
Kamaji, its migrate Job and etcd-operator run. The entity is `world`,
which the tenant's `allow-external-communication` admits to every
endpoint, so sources off the cluster, such as Proxmox workers, are
denied too. The node's own `host` and `remote-node` traffic is not. Deny
rules are needed because the tenant's own policies allow all traffic
within a namespace and from ancestor tenants, and allow rules only add.
Metrics on 2381 stay open. The pods also carry `cozystack.io/service:
kubernetes-etcd` rather than `cozystack.io/service: etcd`, so the
tenant-wide `<tenant>-ingress-etcd` policy does not admit child tenants'
control planes to them. The policy renders only where Cilium serves
`cilium.io/v2/CiliumNetworkPolicy`.
- **Platform ordering.** `cozystack.kubernetes-application` now
`dependsOn` `cozystack.etcd-operator`. Both come with the isp-full
variants, the only ones the iaas bundle allows. The selective-install
fixture is unchanged (`hack/select-install.sh --disabled postgres`
produces the same set). The same edge makes an etcd-operator change
select the `kubernetes-latest`, `kubernetes-previous` and `computeplane`
e2e suites besides `etcd`, and `hack/select-e2e_test.bats` now expects
that.
- **e2e.**
- `hack/e2e-install-cozystack.bats` no longer turns on tenant-root's
etcd, which only Kubernetes clusters used, and no longer waits for it. A
cluster that fell back on a shared etcd would therefore not come up.
- `run_kubernetes_test` asserts the control plane names
`tenant-test.kubernetes-<name>` and that `kubernetes-<name>-etcd`
reaches `Available`.
- `kubernetes-latest` runs the shipped defrag CronJob once and asserts
the Job completes (from #5387), then probes the etcd client port with
`nc -z`: an unlabelled Pod in `tenant-test` and a labelled Pod in
`tenant-root` must be refused, and a labelled Pod in `tenant-test` must
connect as the control. Each Pod ends `Succeeded` only when its verdict
matches, so a probe that cannot run fails the step.
- `cozy_cleanup` waits up to 3m until the `EtcdCluster`, `DataStore`,
member PVCs and Secrets are gone, each read bounded by that deadline;
both Kubernetes suites' teardown op grows from 22m to 25m to cover it.
- The Proxmox suite's tenant drops `etcd: true` and the comment calling
it mandatory.
  - The ComputePlane suite's comment no longer cites #4726.
- `hack/admin-kubeconfig-invariant.bats` drops its two awaiting-etcd
cases, and the now-unused `tests/values-ci-no-etcd.yaml` goes with them.
- **Generated artifacts** come from the tooling. `make -C
packages/apps/kubernetes generate` produced `values.schema.json`, the
README table, `api/apps/v1alpha1/kubernetes/types.go` and
`packages/system/kubernetes-rd/cozyrds/kubernetes.yaml`. Root `make
generate` regenerated `zz_generated.deepcopy.go`, and
`pkg/generated/openapi` did not change. `make generate` in every touched
package leaves the tree clean.
- **Existing clusters.** Migration 63 → 64 lists every
`KamajiControlPlane` whose `DataStore` its own release did not render,
judged by Helm's release annotations on the `DataStore`, with that
`DataStore`'s endpoints. It writes nothing but the version stamp. Slot
check on 2026-11-23:
  - `main` ships through 62 (#5239) with `targetVersion: 63`;
- `release-1.7` ships through 60 (target 61), and `release-1.6` through
53 (target 54);
  - so this PR takes 63 and sets `targetVersion: 64`.
- **README.** `packages/apps/kubernetes/README.md` now describes the
cluster's own etcd, the case of a cluster that keeps its tenant's shared
one, the VPA sizing and the backup path. The ComputePlane README no
longer lists a tenant etcd as a prerequisite.

### Migrating an existing cluster (designed, not implemented)

Nothing here moves a cluster, and nothing should until the runbook below
has an e2e. It combines #25's runbook with SerjioTT's Talos measurements
of 2026-09-03 (about 20s copy, 43s from patch to Ready, reads
uninterrupted) and with what Kamaji 26.9.4-edge's code does.

1. **Opt-in.** The opt-in has to make the chart render the cluster's own
etcd beside the shared one, without switching `dataStoreName`. The
likely shape is a chart-internal value, or an annotation the chart
reads, that the operator sets. Wait for `Available=True`.
2. **Snapshot the source etcd.** This is the rollback path.
3. **Pre-flight reachability from the cluster's namespace, not
Kamaji's** (SerjioTT finding 1). Kamaji's migrate Job runs in Kamaji's
namespace and can reach any etcd, so the copy "succeeds" toward a target
the control-plane pods cannot dial; the new apiserver generation then
crash-loops and the cluster stays write-frozen. Run `nc -zv <target>
2379` from a pod carrying the control plane's labels in the cluster
namespace. For the per-cluster target this holds by construction (same
namespace, and the deny policy admits the control plane), but the check
stays because rollback goes the other way.
4. **Switch.** Point `KamajiControlPlane.spec.dataStoreName` at
`<ns>.<release>`, with the CAPI provider re-projecting it onto the
`TenantControlPlane`. `kamaji.clastix.io/migration-timeout` can go on
the `KamajiControlPlane`, because the provider copies annotations to the
`TenantControlPlane`. Before switching, delete any leftover
`migrate-<TCP UID>` Job in Kamaji's namespace:
- a leftover with identical arguments is taken as success and switches
the datastore without copying;
- one with different arguments is deleted and recreated, with the freeze
already installed.
5. **Verify writes, not status** (SerjioTT finding 2). Kamaji installs a
`kamaji-freeze` ValidatingWebhookConfiguration in the guest, and only
its soot controller removes it, only when the `TenantControlPlane`
status is exactly `Ready`. A paused `TenantControlPlane`, or one sitting
in `WriteLimited`, `Sleeping` or `Upgrading`, keeps the freeze. Node
leases are exempt and reads are untouched, so nodes and `kubectl get`
look healthy. The success criterion is a canary write through the guest
API; if `kamaji-freeze` is still in the guest after the
`TenantControlPlane` is `Ready`, delete it.
6. **Restart every worker kubelet, one node at a time** (SerjioTT
finding 3). Until it restarts, a kubelet keeps running existing pods but
never starts a newly bound one, so the cluster looks healthy and
silently stops starting workloads. The per-node check is a new pod
starting on that node.
- On Talos there is no operator path to the workers' API today: the
chart has a per-cluster `talos-ca` Issuer but issues no client
credentials from it, so the fallback is `virtctl restart` per VM.
- Issuing an operator `talosconfig` from that CA alongside the admin
kubeconfig is the follow-up that makes this step cheap. It is not in
this PR: it is a separate credential with its own exposure question.
- Any pod-based restarter must be deployed before the switch, because a
deaf kubelet will not start it.
7. Retain the source prefix and the snapshot for a cool-off period, then
reclaim. Kamaji does not clean the old prefix after a migration.
Rollback is the same procedure in reverse, against the retained
snapshot.

### Test plan

Done here, on today's `main`, no cluster involved:

- [x] `helm template` of `packages/extra/etcd` before and after the
extraction (commit 1) is byte-identical: 14 renders (default; 1 member +
local SC + 10Gi; resources with CPU and memory allocation ratios +
another version; a global topology spread; a hard affinity with 5
members and 512Mi; leftover `backup.*` values with 0 members; 1 member
at 8Gi with a CPU allocation ratio, for the defrag quota flag), each in
`tenant-root` and `tenant-abc`, all identical by sha256. After commit 2
the one difference in each is the `VMPodScrape` selector.
- [x] `helm template` of `packages/apps/kubernetes` with Cilium served.
With `_namespace.etcd` set to `tenant-root`, or empty, both with 3
members: `EtcdCluster/kubernetes-demo-etcd` replicas=3 on the namespace
default StorageClass, and `DataStore/tenant-demo.kubernetes-demo`
pointing at `kubernetes-demo-etcd.tenant-demo.svc:2379`. The
`KamajiControlPlane` names that `DataStore`, and the policy renders.
- [x] With the platform StorageClass keys set: 1 member uses
`replicated` and 3 members use `local`. 2 members is refused at render
time; 5 is refused by the schema.
- [x] An existing cluster (live-`KamajiControlPlane` lookup stubbed to
return `tenant-root`) renders identically to `main` with
`values-ci.yaml`, pre-delete hook included, apart from random Talos
tokens. A new cluster's render differs from `main` only by the old
shared `dataStoreName`, the shared-etcd pod label and the added etcd
objects.
- [x] helm-unittest:
- `packages/apps/kubernetes`: 392 tests. The 28-case
`tests/etcd_test.yaml` covers names, the second cluster in one
namespace, the 63-character `DataStore` cap, the 52-character defrag
`CronJob` cap at the longest app name, the defrag quota for a 4Gi etcd,
StorageClass choice and stickiness, the refused and the allowed drops to
one member, refusal of 2, the policy with its `world` deny, and the
hook's Step 4a/8 RBAC. For an existing cluster it covers staying on the
shared `DataStore`, ignoring a changed `_namespace.etcd`, keeping the
shared-etcd label, no own etcd and no Step 4a/8.
- `packages/extra/etcd`: 29, including the new scrape-selector case.
`packages/core/platform`: 335. `cozy-lib-tests`: 90.
`packages/system/backupstrategy-controller`: 67, now asserting the dump
Job's label. `packages/apps/tenant`: 89. `packages/extra/computeplane`:
18.
- [x] bats, 867 cases, all passing (`helmrelease-readiness` and
`bats-runner-coverage` included): every `hack/run-kubernetes*_test.bats`
(including two new cases pinning the teardown reads to their deadline),
`kubernetes-pre-delete-hook` (13, split into the shared and the own-etcd
branch, including the fail-closed exit before Step 8),
`check-render-matrix`, `chainsaw-op-budgets`,
`migration-62-shared-etcd-report` (new, 4),
`admin-kubeconfig-invariant`, `check-hook-request-timeout`,
`app-cleanup-hooks_test`, `bats-no-negated-assert`, `bats-no-exit-trap`,
`select-install_test`, `select-e2e_test`, `linstor-storage-mode_test`,
`cozystack-version-stamp` and `md-no-hardwrap`.
- [x] `go build ./...` and `go vet` on the `api/apps/v1alpha1`
Kubernetes package.
- [x] `make generate` in every touched package and at the root leaves no
diff; `hack/check-commit-trailers.sh origin/main..HEAD` passes.

Needs a live cluster:

- [ ] The e2e lanes: `kubernetes-latest`, `kubernetes-previous` and
`computeplane`, now without tenant-root's etcd. The Proxmox lane on its
self-hosted runner.
- [ ] Upgrade from `main` with an existing cluster on tenant-root's
etcd. It must stay on `tenant-root` with no control-plane rollout, and
migration 63 must list it. No CI lane runs a cluster on a shared etcd,
because the chart no longer creates one; an upgrade lane that installs
the previous release first is a follow-up.
- [ ] The deny policy beyond what `kubernetes-latest` now probes: from a
guest worker VM and from outside the cluster, `nc -zv
kubernetes-<name>-etcd.<ns>.svc 2379` must be refused. The control
plane, the defrag Job, a `Kubernetes` backup dump Job, an `EtcdSnapshot`
Job, Kamaji and etcd-operator must still connect, including a freshly
started control-plane pod (Cilium can briefly classify a new pod IP as
`world`).
- [ ] Delete a cluster whose own etcd never became Available (for
example, the quota case below). Step 4a must release the
`TenantControlPlane` and the uninstall must finish without manual work.
- [ ] A tenant whose `ResourceQuota` cannot fit 3 × 1000m/512Mi limits
and 3 × 4Gi requests must surface the quota error on the etcd member
pods.
- [ ] A backup and a restore through the `Kubernetes` strategy of a
cluster that owns its etcd, including the rebuild of a deleted cluster.

### Follow-ups, not opened

These are listed here at the maintainer's request rather than filed:

- **cozystack/website**:
- `content/en/docs/next/operations/configuration/platform-package.md`
gains `kubernetesEtcd.storageClassLocal` and
`kubernetesEtcd.storageClassReplicated`;
- `content/en/docs/next/kubernetes/relocate-etcd.md` describes the
shared tenant etcd as what a cluster uses;
- tenant and Kubernetes docs telling users to set `etcd: true` for a
cluster, which is now an obsolete workaround;
- the Kubernetes app reference is regenerated from the README on the
next stable tag.
- **cozystack/terraform-provider-cozystack**:
`internal/provider/kubernetes_schema.go` and `kubernetes_model.go` need
`etcd.replicas`, with the default of 3, a 1..3 range and the
expand/flatten pair.
- **cozystack/cozystack**, after this lands:
- an upgrade e2e lane that keeps a cluster on a shared etcd across the
upgrade;
  - alert rules for a cluster's own etcd;
  - the opt-in migration path and its e2e;
  - an operator `talosconfig`;
  - phases 3 and 4.

### Screenshots

Not a UI change.

### Downstream repositories

Follow-ups are listed above under "Follow-ups, not opened". By the
maintainer's decision they are not filed from this draft, so no box is
ticked.

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: listed above, not yet filed
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: listed above, not yet filed
- [ ]
[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
feat(kubernetes): each new tenant Kubernetes cluster now gets its own etcd (EtcdCluster `kubernetes-<name>-etcd` and Kamaji DataStore `<namespace>.kubernetes-<name>`), created and deleted with the cluster, so no ancestor Tenant needs `etcd: true` and the `awaiting-etcd` state is gone. The new `etcd.replicas` field chooses 3 members (default) or 1. Each member starts at 1000m CPU and 512Mi memory limits with a 4Gi volume, counted against the tenant's quota, and a VerticalPodAutoscaler may resize it as it is recreated. The platform values `kubernetesEtcd.storageClassLocal` and `kubernetesEtcd.storageClassReplicated` choose the StorageClass for 3 members and 1 member respectively. Existing clusters keep the shared tenant etcd they run on, unchanged; the upgrade lists them in the migration log. The `Kubernetes` backup strategy covers a cluster's own etcd as it covers a shared one. The tenant etcd's metrics scrape now selects only its own members.
```



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* New Kubernetes clusters now use dedicated etcd by default, with one-
or three-replica configurations and platform-selected storage.
* Clusters already using shared etcd continue to use it. Installation
notes show where control-plane state is stored and summarize resource
limits.
* Kubernetes add-ons can render independently of tenant-shared etcd
settings.
* **Bug Fixes**
* Cluster removal now waits for dedicated etcd resources to be
reclaimed.
* Platform upgrades report clusters still using shared etcd without
modifying them.
* **Documentation**
* Updated Kubernetes and ComputePlane guidance on dedicated etcd,
storage options, and migration considerations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-24 15:04:49 +03:00
Timofei Larkin e5f8a13d5d feat(platform): report the Kubernetes clusters left on a shared etcd
Existing tenant clusters keep the shared tenant etcd they run on, and
moving one is a per-cluster operator decision that the platform never
takes on an upgrade. Retiring Tenant.spec.etcd has to wait until no
cluster uses it, so the upgrade lists the clusters that still do. It
writes nothing beyond the version stamp.

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-24 09:04:49 +01:00
Timofei LarkinandYan Bondarenko 16da53637e feat(kubernetes): give each new cluster an etcd of its own
A tenant Kubernetes cluster could only start once an ancestor Tenant had
an etcd module turned on, which nobody creating a cluster may do, and
every cluster below that tenant then shared one etcd, one CA and one
disk. Anything that orders clusters on a tenant's behalf had to flip the
tenant's etcd on first.

A new cluster now renders its own EtcdCluster and DataStore, from the
cozy-lib shapes the etcd chart uses, and is created and deleted with
them. The awaiting-etcd state goes, since a datastore always exists.

An existing cluster stays on the DataStore its live KamajiControlPlane
names, and renders what it rendered before. Changing that name starts a
Kamaji datastore migration, which freezes the tenant's writes and leaves
every worker kubelet needing a restart, so no upgrade may do it.
_namespace.etcd cannot decide this: tenant-root publishes one to every
tenant whether or not an etcd runs behind it.

On uninstall, Kamaji's datastore finalizer drops the tenant's role,
prefix and user from an etcd this release deletes next, and it never
completes while that etcd is down. The pre-delete hook therefore removes
it from a TenantControlPlane on the cluster's own DataStore that
outlives the wait, and deletes the etcd's PKI, which cert-manager issues
without an owner. If the finalizer stays on, or the TenantControlPlane
cannot be read, the hook fails before the PKI goes, so the uninstall is
retried with the etcd still in place. A TenantControlPlane on a shared
DataStore is left to Kamaji as before.

A Cilium deny policy keeps the rest of the tenant namespace, ancestor
tenants and off-cluster sources off the etcd ports; the Kubernetes
backup strategy's dump Job carries the label it admits. The tenant
etcd's scrape now selects its own members by instance, because every
member etcd-operator runs carries app.kubernetes.io/name: etcd. The
platform waits for etcd-operator before offering the application.

The defrag job both charts share pulls its image through the configured
registry, pinned by digest to the multi-architecture index, so a
mirrored installation does not depend on ghcr.io for it.

Tested with helm-unittest on both the own and the shared branch, the
pre-delete hook's bats suite run against a stub kubectl for both, and a
render of an existing cluster that matches main byte for byte.
The guest e2e runs the defrag CronJob once, and probes the etcd client
port from a labelled Pod, an unlabelled one and one in tenant-root.

Co-authored-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-24 09:04:49 +01:00
Aleksei Sviridkin 86ad3870d1 fix(cozystack-basics): make the tenant super-admin VirtualMachine grant read-only (#4797)
<!-- 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

`cozy:tenant:super-admin:base` granted `'*'` on
`kubevirt.io/virtualmachines`, so a tenant super-admin could create a
`VirtualMachine` of any size in their namespace, or edit the one a
`VMInstance` release rendered and raise its guest size. Such a VM is not
a HelmRelease the tenant ordered, so nothing that accounts for
applications sees it. The grant arrived in #516 together with a `'*'` on
`helmreleases`; that one was removed since, this one was not.

Nothing in tree needs the write. Power goes through the
`virtualmachines/start|stop|restart` subresources and console/VNC
through the VMI subresources, both granted at the `use` level; size,
disks and networking go through `VMInstance` values; Forklift's Plan
admission check runs against the migration-controller's own service
account, not the tenant. The rule becomes `get`, `list`, `watch`.
`watch` stays on purpose: the dashboard's power controls and VNC/serial
tabs watch the `VirtualMachine` for its live state, and no other tenant
role grants it.

The tenant roles are aggregated from ClusterRoles in several packages
(`cozystack-basics`, `backup-controller`, `migration-controller`,
`cozystack-scheduler`), so a write path can reach a tenant without
touching the role that names it. A new test in
`hack/e2e-install-cozystack.bats`, right after `tenant-test` is created,
reads the effective rules of the `tenant-test-super-admin` group back
from the apiserver in a single `SelfSubjectRulesReview`, fails if that
review reports itself incomplete or carries an `evaluationError` (both
of which `kubectl auth can-i --list` lets through with exit 0),
subtracts what a bare `system:authenticated` identity already holds, and
fails on any write verb that
`hack/e2e-tenant-super-admin-write-verbs.yaml` does not name. A line
covered by a wildcard grant is folded into it, so a new
`apps.cozystack.io` kind does not need an allowlist edit. An allowlisted
entry the cluster does not grant is printed without failing, for lanes
that disable a package through `COZY_DISABLED_PACKAGES`. The allowlist
sits under `hack/e2e-*.yaml`, which `select-e2e.sh` already escalates to
the full suite. A helm-unittest on the role catches the same regression
on the unit lane.

Verified outside CI on a throwaway k3s v1.33 loaded with the rendered
tenant ClusterRoles and the tenant RoleBindings, through
`hack/cozytest.sh`: with `main`'s roles the test fails and names
`virtualmachines.kubevirt.io - *`; with this change it passes; with the
migration-controller roles removed it passes and prints the eight
`forklift.cozystack.io` entries as not granted. The two awk programs
give the same result under mawk and dash (`ubuntu:24.04`) as on macOS.
The new helm-unittest fails against `main`'s template and passes here.
`hack/bats-runner-coverage.bats`, `hack/bats-no-exit-trap.bats` and
`hack/select-e2e_test.bats` pass.

This change is the standalone fix of the RBAC prerequisite described in
the tenant-quota design proposal, cozystack/community#48, where review
asked for it to land on `main` independently of that design.

### Screenshots

No UI change.

### Downstream repositories

<!--
Cozystack is upstream for repositories that are NOT kept in sync with it
automatically, and nothing in CI compares the two sides, so a change
here can break them silently.

Which change forces what, and which file to touch, is the trigger map in
docs/agents/contributing.md under "Downstream Repositories". Walk it
before you tick anything.

IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM
TO FILL IN:

1. Walk the trigger map against the actual diff of this PR, file by
file. Do not decide from the PR title or from your memory of what you
changed.
2. For every repository you tick, open the follow-up PR there and link
it on the same line. A ticked box with no link claims work that does not
exist, which is worse than an empty box. Search that repository for an
open PR or issue covering it first, and link that instead of filing a
duplicate.
3. When the follow-up is out of scope, or needs a decision that is not
yours to make, open an issue in that repository instead, link that, and
say so in the PR body. Do not push a speculative PR into another
repository just to fill a line here.
4. Do not tick "No downstream repository is affected" to make the
checklist go away. If you are unsure, leave every box empty and say so
in the PR body, so a human decides.
-->

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

Walked the trigger map against the diff: an RBAC narrowing in
`cozystack-basics` plus e2e harness files touch no values key, CRD,
`ApplicationDefinition`, package list or tooling path. The one website
page that patches `virtualmachines.kubevirt.io` directly,
`networking/virtual-router.md`, is a procedure that "requires a
Cozystack administrator account", which this change does not affect.

### Release note

```release-note
fix(cozystack-basics): tenant super-admins can no longer create, edit or delete `kubevirt.io` VirtualMachines directly; they keep read and watch. Virtual machines are managed through VMInstance and VMDisk applications, power through the start/stop/restart actions. The install e2e now fails when a tenant super-admin gains a write verb outside a checked-in allowlist.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Access Control**
* Tenant super-admins can view KubeVirt virtual machines with read-only
permissions through the base role; it no longer grants broad write
access to these resources.
* Tenant super-admin write permissions are checked against an explicit
allowlist. Permissions outside the approved list cause the end-to-end
check to fail, while approved permissions not currently granted do not.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 21:00:19 +03:00
Aleksei Sviridkin 4bc9084ad7 feat(bucket): offer Object Lock without a default retention (#5050)
## What this PR does

A locked bucket can only be provisioned from the `-lock` BucketClass,
whose default retention is COMPLIANCE for 365 days. Backup tools such as
Veeam, restic and Kopia set the retention of each object themselves, and
other users want a shorter default or GOVERNANCE, which a bucket owner
can already set through the S3 API once the bucket exists. Nothing let
them start from a locked bucket without that year-long default, so users
left Object Lock off.

This adds a `-lock-noretention` BucketClass next to every `-lock` class:
in the COSI chart patch, for the Client topology, and for each storage
pool. It enables Object Lock and sets no default rule. The bucket app
gets a `lockingDefaultRetention` flag that selects it together with
`locking`. The flag defaults to `true`, so existing buckets and values
keep `-lock`, and it is read at creation only.

The new class keeps `deletionPolicy: Retain` like `-lock`. The driver
deletes a bucket through the filer without checking retention
([seaweedfs/seaweedfs-cosi-driver#17](https://github.com/seaweedfs/seaweedfs-cosi-driver/issues/17)):
on a lab cluster (SeaweedFS 4.31, driver v0.3.1), a BucketClass with
`objectLockEnabled` and `Delete` removed a bucket holding an object
still under COMPLIANCE retention, which S3 itself had refused to delete.
A pool named `x-lock-noretention` renders the same class name as the
`-lock-noretention` class of a pool `x`. That suffix is not reserved,
since such pools already exist and must keep upgrading; the template
instead checks every BucketClass and BucketAccessClass name the pools
render, across `volume.pools` and every zone's pools, against each other
and against the base classes, and fails only on an actual duplicate. The
same check catches pools named exactly `lock`, `readonly` or
`lock-noretention`.

Tested with helm-unittest in the three charts, each new suite checked to
fail with the template change reverted. On the same lab cluster, a
bucket from a class with only `objectLockEnabled` accepted a default
retention set afterwards with `PutObjectLockConfiguration`, per-object
`PutObjectRetention`, and Legal Hold. The class itself has not run on a
SeaweedFS 4.48 backend yet.

### Screenshots

No template change in the dashboard. The new field reaches the bucket
form through the schema, like `locking`.

### Downstream repositories

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: https://github.com/cozystack/website/pull/821
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
https://github.com/cozystack/terraform-provider-cozystack/issues/73
(issue)
- [ ]
[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 bucket app gains a field in its `values.schema.json`, so
`terraform-provider-cozystack` needs it in its bucket resource with a
default of `true`; filed as an issue there rather than a PR, since
whether the attribute should force a replacement is the provider
maintainers' call. The website's Buckets guide is hand-written and
described only the `-lock` class with its default retention, so it is
updated in cozystack/website#821. No other repository in the trigger map
is reached by this diff.

### Release note

```release-note
feat(bucket): add `lockingDefaultRetention` to provision a locked bucket with Object Lock enabled and no default retention, from the new `-lock-noretention` BucketClass, so the retention can be chosen through the S3 API.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* When bucket locking is enabled, choose whether newly created buckets
receive the default COMPLIANCE retention period of 365 days. Default
retention remains enabled by default.
* Turn off default retention to enable Object Lock without a preset
retention period. Retention can then be configured for the bucket or
individual objects through the S3 API.
* This setting is applied only when a bucket is created; changing it
later does not alter existing buckets.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 21:00:03 +03:00
Aleksei Sviridkin 94d710e50f fix(tenant): render the LimitRange only under a compute quota (#4954)
## What this PR does

The tenant chart rendered `tenant-range-limits` whenever
`resourceQuotas` was non-empty. Under a quota on something other than
compute, for example `{services.loadbalancers: "1"}`, `storage` or
`nvidia.com/gpu` alone, its 128Mi default memory limit still applied to
every container and refused any pod that requests more memory without a
limit of its own. virt-launcher is one of those, so VMs could not start
in such a tenant.

The LimitRange exists so pods without requests or limits pass a quota
that tracks `cpu`, `memory` or `ephemeral-storage`. This PR has it
default each of those three only when the flattened quota bounds that
resource (its `requests.*` or `limits.*` key), and renders no LimitRange
when the quota bounds none of them. A quota on all three renders the
LimitRange exactly as before, with the same values. The ResourceQuota is
unchanged. The system memory limits guide has moved to the website and
described the old condition in two places; the follow-up below updates
it. A second commit qualifies the comments in the operator, the tenant
quota controller, the backup controller and the barman and kafka charts
that still said every tenant with `resourceQuotas` gets a 128Mi memory
default.

Tests:

- New `packages/apps/tenant/tests/quota_limitrange_test.yaml` (9 tests):
no LimitRange under a quota on load balancers, storage or GPUs alone;
only the cpu, only the memory, or only the ephemeral-storage defaults
under a quota on that resource alone; only memory beside non-compute
keys; every default, values unchanged, under a quota on all three.
- Against main's template, 7 of the 9 tests fail. The two that pass are
the empty quota and the full cpu, memory and ephemeral-storage quota,
which keep their behaviour.
- `helm unittest` for the whole tenant chart: 23 suites, 98 tests pass.
- `helm template` of `templates/quota.yaml` under `{cpu, memory,
ephemeral-storage}` is identical to main.

I did not reproduce the virt-launcher admission failure on a live
cluster; the reproduction in the issue is from a test cluster on main.

Fixes #4930

### Screenshots

Not a UI change.

### Downstream repositories

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: cozystack/website#817
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
fix(tenant): the tenant LimitRange now defaults cpu, memory and ephemeral-storage only when resourceQuotas bounds that resource, so a quota without memory no longer gives containers a 128Mi default memory limit that kept VMs from starting.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* LimitRange settings are now rendered only when quotas bound CPU,
memory, or ephemeral storage. Defaults are included only for the bounded
resources; quotas limited to load balancers, storage, or GPUs do not
trigger a LimitRange on their own.
* **Documentation**
* Clarified when tenant namespaces receive LimitRange defaults,
including the resource-specific conditions for CPU, memory, and
ephemeral storage.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 20:24:30 +03:00
Andrey Kolkov eb284424d0 fix(platform): bump system PostgreSQL to 17.12 (#5403)
## What this PR does

Moves the PostgreSQL image pin of the system databases from
`17.7-standard-trixie` to `17.12-standard-trixie`.

PostgreSQL 17.7 is affected by CVE-2026-116331: a type confusion in the
min/max aggregate optimisation lets a role that can create objects run
code as the operating system user of the server. The 17.x line fixes it
in 17.12.

The pin lives in the `Cluster` templates of five system databases, and
the charts expose no value for it, so a release is the only way to move
them:

- Keycloak (`keycloak-db`)
- Harbor
- Grafana (`grafana-db`)
- Alerta (`alerta-db`)
- SeaweedFS (`seaweedfs-db`), together with its unit test

What an upgrade does on a running cluster:

- Every system database on a 17.x image is moved to 17.12. CloudNativePG
rolls the replicas first and then restarts the primary in place.
- The primary restart goes through the smart shutdown window (180
seconds by default) while clients hold connections, followed by a short
hard interruption. Plan for a few minutes per database.
- A database that was moved to another major keeps its image, as before.

The image variant and the Debian release do not change, so glibc and ICU
stay the same under the data directory and no index needs a rebuild.

Verified on live clusters, on both the 1.6 line (CloudNativePG 1.28) and
the 1.7 line (CloudNativePG 1.30):

- a two-instance cluster and a real Keycloak database went from 17.7 to
17.12 with identical row counts, `amcheck` clean on every btree index,
and streaming replication restored;
- Keycloak reported healthy, database check included, after the roll;
- collation versions were the same before and after.

Not in this PR: the tenant `postgres` application. It uses a different
image family and needs separate handling.

Migration 37 keeps its 17.7 target on purpose: it is a one-time step for
clusters coming from older releases, and the chart moves them to 17.12
right after.

### Screenshots

N/A — no UI changes.

### Downstream repositories

Walked the trigger map against the diff: five `Cluster` templates under
`packages/system/` and one unit test. No value, schema, API, CRD,
variant, package or asset changes.

- [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(platform): system PostgreSQL databases (Keycloak, Harbor, Grafana, Alerta, SeaweedFS) move from 17.7 to 17.12-standard-trixie, which fixes CVE-2026-116331. On upgrade each of these databases is rolled: replicas first, then the primary is restarted in place, with a brief interruption of a few minutes per database.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Updates**
* Updated the default PostgreSQL image to version 17.12 across database
services. Existing custom image handling remains unchanged.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-24 00:20:46 +07:00
IvanHunters 61e0839e0e fix(postgres): validate audit.log and match audit keys case-insensitively
Review on #5404 surfaced three issues with the audit toggle:

- audit.log was a free string, so a mistyped class (write, ddl, rol)
  rendered unchanged and pgaudit fell back to none at the next restart,
  silently disabling auditing. Add a schema pattern over the pgaudit
  class list so a bad class is rejected at admission.
- The explicit-parameter-wins guard matched keys case-sensitively, so a
  user key like pgaudit.LoG landed beside the lowercase seed and
  PostgreSQL, which is case-insensitive, picked the seed. Match the user
  keys lowercased.
- The connection-logging and empty-log guards were untested. Cover
  log_disconnections, an empty pgaudit.log, an empty audit.log and a
  case-variant key.

Also note in the field docs that write/all record statement text, so the
audit trail is readable by anyone with access to the log stack.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-11-23 18:34:42 +03:00
Mattia Eleuteri 6d5d0a4a72 Merge upstream main into fix/kubernetes-nodes-bounded-surge
Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 16:07:19 +01:00
IvanHunters 64c55898aa fix(postgres): make an explicit parameter win over the audit default
Seeding pgaudit.log and the connection-logging parameters through the
$defaults merge let a falsy explicit value lose: a tenant setting
log_connections: 0 while audit is on had it silently overwritten with
on, because sprig merge reads a zero value as unset. Seed each key only
when postgresql.parameters does not already set it, so an explicit value
wins unconditionally. Also enumerate the valid pgaudit.log classes in
the field description, since an unrecognised class makes pgaudit fall
back to none and silently disables auditing.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-11-23 17:38:54 +03:00
Aleksei Sviridkin ff7c2afdbd fix(kubernetes-nodes): label worker disks with the WorkloadMonitor selector (#5393)
## What this PR does

The worker WorkloadMonitor selects PVCs by its selector labels, but a
worker VM's disk PVC carried none of them, so it was never recorded as a
Workload.
CAPK stamps `cluster-name` and `role` on the VirtualMachine and its VMI
template only and copies dataVolumeTemplates verbatim apart from a name
prefix;
CDI then builds the PVC from the DataVolume's labels.
Putting the selector on the disk-system template is the only place the
labels reach the PVC without teaching the shared controller to walk PVC
-> DataVolume -> VirtualMachine owner chains.

The disk must not carry `cluster.x-k8s.io/cluster-name`: 
the Kubernetes backup strategy selects DataVolumes and PVCs by it, 
so every worker root disk would be copied into each backup and deleted
and restored by an
in-place restore as cluster data. 
The WorkloadMonitor selector therefore drops `cluster-name` and keeps
`deployment-name` and `role`;
`deployment-name` already names a single MachineDeployment in the
namespace,
and the virt-launcher Pods the monitor counts still carry both labels.

The KubevirtMachineTemplate is named by a hash of its content, so this
renames it and every KubeVirt worker pool rolls once on upgrade. That is
safe: the chart keeps any template a MachineSet still references, and
the adoption migration matches templates by the 6-hex suffix pattern
rather than by a fixed hash. Existing PVCs are not relabelled in place
(CDI sets labels only at creation); the roll replaces them with labelled
ones.

Proxmox pools do not render this template and do not roll.

Tested with helm unittest: 
cases assert the disk template carries exactly `deployment-name` and
`role` and NO `cluster-name`,
and that the WorkloadMonitor selector is those two labels; snapshot and
pinned
template-name literals are updated for the new hash.

### 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

```release-note
fix(kubernetes-nodes): Fixed worker node disks not showing up as workloads of their Kubernetes cluster. 
Worker disk PVCs now carry the `cluster.x-k8s.io/deployment-name` and `cluster.x-k8s.io/role` labels that the worker pool's WorkloadMonitor selects on.
Upgrading replaces every worker VM in every KubeVirt-backed node pool once. 
A pool can bring up as many replacement VMs at the same time as its `maxReplicas`, 
so the management cluster needs room for the extra VMs during the rollout. 
An old node is drained only once its replacement has joined, except in pools with passed-through GPUs, 
where one old node at a time can be drained while its replacement starts. 
Pods on the workers are evicted and rescheduled, and anything stored only on a worker's local disk is lost.
Proxmox-backed pools do not restart.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

## Summary

* **Bug Fixes**
* Workload monitoring can now match worker-node storage volumes using
deployment and worker-role labels, without requiring a cluster-name
label.
* Corrected the expected machine-template name for configurations that
specify CPU cores with leading zeros.
* **Tests**
* Updated coverage to verify storage-volume labels and leading-zero CPU
rendering.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 17:32:04 +03:00
IvanHunters 902909dbe7 feat(postgres): add an audit toggle for access and statement logging
Managed Postgres could already load pgaudit through the
sharedPreloadLibraries allowlist and set pgaudit.log and log_connections
through postgresql.parameters, but that leaves an orchestrator depending
on internal parameter names to answer who connected and what they ran.

This adds an audit block that bundles access and statement auditing
behind one switch. With audit.enabled the chart adds pgaudit to
shared_preload_libraries and seeds pgaudit.log (from audit.log,
default "write, ddl, role"), log_connections and log_disconnections. The
parameters are seeded as defaults, so an explicit pgaudit.log or
log_connections in postgresql.parameters still wins. The audit trail
goes to the instance log, which the platform log stack already collects,
so it is queryable per database without extra wiring.

Postgres only; the other managed databases are left for follow-ups.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-11-23 17:25:17 +03:00
Aleksei Sviridkin a19846c77e fix(harbor): meter the registry bucket under the registry WorkloadMonitor (#5392)
## What this PR does

The WorkloadMonitor controller finds BucketClaims by the monitor's label
selector. The registry BucketClaim carried no labels, so it never got a
Workload and Harbor's object storage was invisible to billing. Before
the registry moved to S3 its PVC carried the vendored chart's release
and component labels and was reported under the registry monitor;
labelling the BucketClaim the same way restores that.

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### 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(harbor): Harbor registry storage is billed again. The WorkloadMonitor controller finds BucketClaims by label, and the registry BucketClaim had no labels. It now carries the registry monitor's `release` and
  `component` labels, so its storage shows up as Workload under the registry WorkloadMonitor, the same way the registry PVC did before it moved to S3. And also registry WorkloadMonitor now reports not operational while the BucketClaim is not provisioned
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Improvements**
* Harbor registry storage claims now include release and component
labels, making them identifiable as part of the Harbor system and
registry.
* Registry workload monitoring now selects storage claims using these
labels.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 17:14:33 +03:00
Aleksei Sviridkin 7614829293 Merge branch 'main' into feat/bucket-lock-noretention
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-23 16:53:39 +03:00
Andrey Kolkov 8800d0177b fix(platform): bump system PostgreSQL to 17.12
The system databases (Keycloak, Harbor, Grafana, Alerta, SeaweedFS) are
pinned to PostgreSQL 17.7, which is affected by CVE-2026-116331: a type
confusion in the min/max aggregate optimisation lets a role that can
create objects run code as the operating system user of the server.
The 17.x line fixes it in 17.12.

Move the pin to 17.12-standard-trixie. The image variant and the Debian
release stay the same, so glibc and ICU do not change under the data
directory. Clusters on another major keep their image, as before.

Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-23 20:52:21 +07:00
Aleksei Sviridkin 1ab20ea96e fix(cluster-api): name the kubeconfig the upgrade hook runs with (#5398)
<!-- 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

The "Unit & controller tests" job fails on `main` and on every PR
rebased on it: `hack/check-hook-request-timeout.bats` reports "no
in-cluster kubectl call carries a non-zero --request-timeout" against
`packages/system/capi-providers-core/files/upgrade-providers.sh`. #4902
added that script and #5360 extended the check to `files/` a few hours
apart, so neither ran against the other.

It is a false positive. The hook Job exports
`KUBECONFIG=/scripts/kubeconfig` and the script talks to the API only
through that explicit kubeconfig, which is exactly the case the check
exempts, but the exemption keys on the file naming `KUBECONFIG` and the
script only named `KUBE_CONTEXT`.

The single commit makes the script require `KUBECONFIG` with its other
inputs, so the dependency is explicit and the script refuses to fall
back to the in-cluster config. The check and the 10s per-call timeout
are left as they are. It adds a test that the script exits before any
API call when `KUBECONFIG` is unset, and asserts in the chart test that
the Job sets `KUBECONFIG` to the mounted kubeconfig. Reverting the
script change makes both the check and the new test 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(cluster-api): the provider upgrade hook script now requires the kubeconfig its Job mounts, which also unblocks the unit test job on main.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Upgrade operations now require `KUBECONFIG` to be set and stop with an
error if it is missing, before making API calls.
* Added checks that the upgrade job uses the expected kubeconfig path
and that the configured current context is `capi-upgrade`.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 16:49:40 +03:00
Aleksei Sviridkin 8f0082a1c8 fix(clickhouse): delete the archive when its Backup is deleted (#5224)
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
- Scopes are not an exhaustive list — pick the most specific scope for
the change and extend the list when a genuinely new area appears.
Examples:
- System components: dashboard, platform, operator, cilium, kube-ovn,
linstor, fluxcd, cluster-api
- Managed apps: postgres, mariadb, redis, kafka, clickhouse,
virtual-machine, kubernetes
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or
add a `BREAKING CHANGE:` footer
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Add the label `kind/backport` if it's a bugfix that needs to be
backported to a previous version.
-->

## What this PR does

Builds on #5229 (merged), which gives every backup run an archive of its
own.

Deleting a `Backup` taken with the Altinity (ClickHouse) strategy
released its finalizer at once and left the archive in the bucket. On
the system bucket nothing else prunes it, so every ClickHouse backup
stayed until someone called the sidecar by hand, and the route the chart
and the examples documented for that, `DELETE /backup/<name>/remote`,
does not exist in clickhouse-backup 2.7 and answers 404.

The driver names each archive `<application>-<start time as
YYYYMMDDHHMMSS>-<first 12 hex digits of the BackupJob UID>` (#5229) and
records it on the `Backup` under
`altinity.strategy.backups.cozystack.io/archive`. This PR also records,
under `altinity.strategy.backups.cozystack.io/use-system-bucket`, the
application's `backup.useSystemBucket` as it read when the backup Job
was created: the setting is stamped on the backup Job and copied onto
the `Backup`, because the application may switch before the controller
sees the Job complete. A Job created before the stamp existed falls back
to the application as it reads at completion. For a system-bucket
application the bucket the projected credentials (`cozy-backups-creds`)
name is recorded the same way, under
`altinity.strategy.backups.cozystack.io/bucket`. The `Backup` is created
with its cleanup finalizer already set, so a `Backup` deleted before the
`Backup` reconciler first sees it still has its archive deleted.

On `backup.useSystemBucket: true`, deleting the `Backup` runs a one-shot
cleanup Job that calls `POST /backup/delete/remote/<name>` on the
application's sidecar and holds the finalizer until it completes. The
sidecar refuses a delete with 423 while any other operation runs and
cannot be reached while its Pod restarts, so the Job waits both out
within its deadline; an archive that is already gone counts as deleted,
and any other answer fails the Job, which is reported as an
`ArtifactCleanupFailed` Warning Event carrying the reason the Job failed
and retried after a wait that starts at 30 seconds and doubles with each
failure up to 30 minutes (kept on the `Backup` under
`altinity.strategy.backups.cozystack.io/cleanup-failures` and
`.../cleanup-retry-after`, since the failed Job is deleted to make room
for the next). The Job starts only once the projected credentials have
reached the sidecar, as the backup and restore Jobs do. It is built by
the controller, not rendered as a whole from the strategy template,
because the shipped and the example templates run `restore_remote` for
every mode other than `backup`; only the image, how to pull it and where
the Pod may be scheduled (node selector, tolerations, affinity, priority
class) come from the template, rendered as for the strategy's own Pods.

When the delete cannot or must not run, the `Backup` is released with an
`ArtifactNotDeleted` Warning Event naming the archive left behind: the
namespace is terminating, the strategy, the application or its API
Secret is gone, the application no longer uses the system bucket (also
when it leaves while the delete runs), the system bucket is no longer
the one the `Backup` records or cannot be read (also when it changes
while the delete runs; a sidecar on another bucket would answer "not
found" and the delete would count as done), another Job holds the
cleanup Job name, or the archive has the older
`clickhouse-<application>-<YYYYMMDDTHHMMSSZ>` form, without its
BackupJob's UID. Such a name comes from a controller that predates
per-run names; two runs of one application started within the same
second share it, and a run still in flight when the controller is
upgraded records it later, so it is never deleted.
`backups.cozystack.io/skip-artifact-cleanup: "true"` releases a `Backup`
without deleting anything. An application on its own bucket keeps the
archive's lifecycle, as with MongoDB. The wrong delete route is
corrected in the chart comments and the restore scenario.

A BackupJob or RestoreJob no longer takes the outcome of a batch Job of
its name that it does not control. A Job left by an earlier owner of the
same name is waited out, with the `Ready` condition
(`PredecessorJobPending`) naming it, until the garbage collector removes
it; any other Job holding the name fails the BackupJob or RestoreJob
with a message naming the Job. The condition is dropped once the run's
own Job starts.

The example strategy under `examples/backups/clickhouse` now uploads
under the archive name the controller chose and restores the archive the
`Backup` records, as the shipped strategy does, keeping its clock-made
name and the newest archive only as the fallback for a run given no
name; `hack/clickhouse-example-strategy.bats` runs it against a stubbed
sidecar. The backup scenario no longer says the archive is expired by
the upstream tool's retention, which the chart does not configure.

Known limitations: a `Backup` taken before #5208, or by a custom
strategy that does not use `.ArchiveName`, does not name its archive and
keeps it; a `Backup` that names its archive but not the bucket setting,
as every `Backup` taken before this change does (a 1.7.x release that
carries #5208 among them), keeps its archive too and is released without
an Event; a `Backup` that records no bucket, taken before buckets were
recorded, is deleted without the bucket check; a `Backup` deleted during
an application uninstall can lose its cleanup Job to the chart's own
`<release>-cleanup` hook and is then released with a Warning Event,
leaving the archive; the recorded setting and bucket are read when the
backup Job is created, not observed from the upload, so a switch made
just before a backup, while the sidecar still runs on the previous
bucket, is recorded for an archive written to the previous one.

Related gap outside this PR, in main today: an archive uploaded by a run
whose `Backup` name is already taken is recorded by nothing, so no
`Backup` deletes it.

Verified with unit tests that drive the cleanup path through a fake
client and the cleanup script against a stub `curl`, with mutation
checks on every guard, and on a test cluster running v1.7.0 with the
backup controllers built from this branch (before #5229 shortened the
run name to its current form, which leaves the deletion side unchanged),
against the real clickhouse-backup sidecar and SeaweedFS: a backup
records a per-run archive name and the bucket setting on a `Backup`
created with its finalizer; deleting the `Backup` deletes the archive's
objects in the bucket; a restore from a `Backup` brings the data back; a
BackupJob recreated under a used name waits for the earlier Job and then
writes an archive of its own; a Job of that name created by anything
else fails the BackupJob; a `Backup` recording an archive named without
a UID is released with `ArtifactNotDeleted` and its objects stay. The
changes made after that run (the recorded bucket, the retry wait, the
credentials wait before the cleanup Job, the rendered cleanup Pod
settings, the cleared predecessor condition, the example strategy) are
covered by the unit tests and bats, not by a live run.

### Screenshots

<!-- REQUIRED for UI changes: attach screenshots or screen recordings
demonstrating
the visual impact of your changes. PRs with UI changes without
screenshots will not be merged. -->

### Downstream repositories

<!--
Cozystack is upstream for repositories that are NOT kept in sync with it
automatically, and nothing in CI compares the two sides, so a change
here can break them silently.

Which change forces what, and which file to touch, is the trigger map in
docs/agents/contributing.md under "Downstream Repositories". Walk it
before you tick anything.

IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM
TO FILL IN:

1. Walk the trigger map against the actual diff of this PR, file by
file. Do not decide from the PR title or from your memory of what you
changed.
2. For every repository you tick, open the follow-up PR there and link
it on the same line. A ticked box with no link claims work that does not
exist, which is worse than an empty box. Search that repository for an
open PR or issue covering it first, and link that instead of filing a
duplicate.
3. When the follow-up is out of scope, or needs a decision that is not
yours to make, open an issue in that repository instead, link that, and
say so in the PR body. Do not push a speculative PR into another
repository just to fill a line here.
4. Do not tick "No downstream repository is affected" to make the
checklist go away. If you are unsure, leave every box empty and say so
in the PR body, so a human decides.
-->

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: cozystack/website#809 (for cozystack/website#808; its `next/`
pages should merge after this PR)
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

<!--  Write a release note:
- Explain what has changed internally and for users.
- Start with the same `type(scope):` prefix as in the PR title
- Follow the guidelines at
https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md.
-->

```release-note
fix(clickhouse): deleting a Backup taken on the system bucket from this release on now deletes its clickhouse-backup archive and keeps the Backup until the delete finished, reporting an archive it cannot or must not delete (including one named without its BackupJob's UID, or in a system bucket the platform has left) as a Warning Event and retrying a failed delete with a growing wait; the cleanup Pod is scheduled as the strategy's own Pods; a BackupJob or RestoreJob no longer reports the outcome of a batch Job it did not create; the documented sidecar delete route is corrected to POST /backup/delete/remote/<name>.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* ClickHouse backups using the system bucket now remove their recorded
archive when the backup is deleted. Deletion waits for cleanup to
finish.
* Backup and restore operations use the controller-provided archive name
when available. Restores can fall back to the latest matching archive.
* **Bug Fixes**
* Temporary sidecar failures are retried with increasing delays. If
cleanup cannot safely remove an archive, it completes with a warning
rather than risking deletion of the wrong archive.
* **Documentation**
* Clarified that archives in tenant-owned buckets remain until manually
deleted or removed by bucket lifecycle rules.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 16:27:05 +03:00
Mattia Eleuteri ad47521c95 fix(cozystack-basics): make the tenant super-admin VirtualMachine grant read-only
cozy:tenant:super-admin:base carried '*' on kubevirt.io virtualmachines.
A VirtualMachine written directly is sized outside any application: it
is not a HelmRelease the tenant ordered, so nothing that accounts for
applications sees it, and the same verbs let a super-admin raise the
guest size of a VM a VMInstance release rendered. Nothing in tree needs
the write: power goes through the virtualmachines start/stop/restart
subresources, console and VNC through the VMI subresources, size, disks
and networking through VMInstance values. The grant arrived together
with a '*' on helmreleases that was later removed; this one was missed.

watch stays, because the dashboard watches the VirtualMachine for its
live power state and no other tenant role grants it.

The tenant roles are aggregated from ClusterRoles in several packages,
so a write path can reach a tenant without touching the role that
names it; the install e2e now guards against that.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 16:14:49 +03:00
Mattia Eleuteri 9ecff91b74 fix(kafka)!: require SCRAM-SHA-512 on the external listener
With external access on, the chart opens a listener on port 9094 of a
public LoadBalancer address, and it rendered that listener without any
authentication: whoever reached the address could produce and consume
on every topic. TLS on that listener only encrypts the session.

The KafkaUser name carries the release name because it is also the
SCRAM username and the name of its Secret, and two instances in one
namespace may declare the same user. A dot joins the two because a
user Secret readable by the tenant must never take the name of a
Secret Strimzi derives from a cluster name, and neither a release name
nor any of those Secrets can hold a dot.

BREAKING CHANGE: an instance with external access enabled refuses
clients that do not authenticate. The Kafka README gives the upgrade
sequences.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 14:11:55 +01:00
Aleksei Sviridkin 836f280426 fix(monitoring): spread monitoring replicas over nodes (#4989)
## What this PR does

The monitoring chart renders its VMCluster, VLCluster, VTCluster and
VMAlertmanager without `affinity` or `topologySpreadConstraints`, and
vm-operator v0.68.4, which main and release-1.6 ship, copies both fields
onto the pods as written and adds none of its own
([build/statefulset.go#L11-L36](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/build/statefulset.go#L11-L36),
[build/deployment.go#L11-L36](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/build/deployment.go#L11-L36)).
Nothing keeps two replicas of one tier off the same node.

Seen on three three-node clusters, on v1.6.4 and v1.6.5, which both
render these resources without a placement rule and ship the same
operator. In the root tenant of one of them both vmstorage replicas of
`longterm` and both vmselect replicas of `shortterm` shared a node, with
their volumes on the node-local `local` class. On another both vlstorage
replicas shared a node, on `replicated`. On all three, two of the three
Alertmanager replicas shared a node. With `replicationFactor: 2` both
copies of every `longterm` series sit on that node, and vmalert
evaluates its rules through the vmselect of the first metrics storage,
`shortterm` by default, so losing that node also stops alert evaluation.
A StatefulSet pod on a lost node is not replaced until its Pod or Node
object is deleted, so this holds for the Alertmanager replicas too,
which have no volume.

This PR gives every tier a per-node spread keyed to the
`app.kubernetes.io/name` and `app.kubernetes.io/instance` labels the
operator puts on that component's pods
([ClusterSelectorLabels](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/api/operator/v1beta1/vmextra_types.go#L108-L124),
[VMAlertmanager](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/api/operator/v1beta1/vmalertmanager_types.go#L323-L330)).

- The tiers that run as StatefulSets, vmstorage, vmselect, vlstorage,
vtstorage and the Alertmanager, get `maxSkew: 1` on
`kubernetes.io/hostname` with `whenUnsatisfiable: DoNotSchedule` and
`nodeTaintsPolicy: Ignore`, as #4986 proposes for etcd members and #4947
for the SeaweedFS masters, for the reasons given there. A preference
only adds to a node's score and #4986 shows other scores outweighing it,
while a replica placed wrong on a node-local volume stays there. More
replicas than nodes still start, and a replica evicted by a drain goes
to a node without a peer or waits for its own node instead of joining a
peer. As in #4986, a node the pods can never run on, such as a tainted
control plane, still counts as an empty node, so next to such a node the
three Alertmanagers need three schedulable nodes.
- The tiers that run as Deployments, vminsert, vlinsert, vlselect,
vtinsert and vtselect, get the same spread with `ScheduleAnyway`. A
Deployment replaces their pods on another node by itself, and a
requirement would only add Pending pods during drains on small clusters.
- When `_cluster.scheduling.globalAppTopologySpreadConstraints` is set,
every tier gets that policy instead, with the tier's selector added to
each constraint that has none and a selector the policy sets itself left
as written, the rule the keycloak chart applies to its database
constraints. A value that does not parse or holds no non-empty
`topologySpreadConstraints` list fails the render, as an empty
`logsStorages` already does, instead of silently leaving the policy out.
The `traces-central` VMAuth keeps the spread it already has.

### On upgrade

The new pod templates make the operator update every tier once.
StatefulSets default to `OnDelete` in the operator
([build/defaults.go#L84-L87](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/build/defaults.go#L84-L87)),
and it replaces their pods itself, one at a time because the chart sets
no `rollingUpdateStrategyBehavior`, in ordinal order through the
Eviction API, waiting for each new pod to become Ready
([reconcile/statefulset.go#L156-L176](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/reconcile/statefulset.go#L156-L176),
[#L215-L359](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/reconcile/statefulset.go#L215-L359)).
The wait is `VM_PODWAITREADYTIMEOUT`, 80s by default
([config.go#L578-L587](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/config/config.go#L578-L587)),
which the victoria-metrics-operator package leaves alone. Deployments
roll through the Deployment controller
([reconcile/deploy.go#L26-L80](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/reconcile/deploy.go#L26-L80)).
Within a VMCluster the order is vmstorage, vmselect, vminsert
([vmcluster.go#L81-L143](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/vmcluster/vmcluster.go#L81-L143)),
within a VLCluster vlstorage, vlselect, vlinsert
([vlcluster.go#L65-L74](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/vlcluster/vlcluster.go#L65-L74)).

A replica without a volume, like the Alertmanager, or with a volume that
can be attached on another node, like vlstorage on `replicated`, is
placed again under the new rule during that rollout, so given enough
nodes those tiers end up spread with nothing else to do.

A replica on a node-local volume cannot leave its node, and `local` is
the default class for the metrics storage in the documented layout. If a
peer of the same tier runs on that node while another node has none, the
new pod cannot be scheduled, since the volume allows only that node and
the spread refuses it, so it stays Pending. The operator gives up the
wait after 80s and keeps the resource `expanding`, because a wait
timeout counts as retryable
([reconcile.go#L141-L143](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/reconcile/reconcile.go#L141-L143),
[controllers.go#L343-L353](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/controllers.go#L343-L353)),
and tries again on the next reconcile. The later tiers of that VMCluster
or VLCluster are not updated meanwhile, and the peer keeps serving. For
a VLCluster the monitoring HelmRelease waits on that status through its
`healthCheckExprs`, so the release upgrade times out as well.

Such a replica does not move by itself, and this PR does not move it.
Moving it means recreating its volume on another node. For vmselect that
drops a cache. For vmstorage it drops that replica's copy, and with
`replicationFactor: 2` the series written before the move keep one copy
until they age out of retention. vlinsert shards logs over vlstorage
rather than replicating them, so for vlstorage it drops the logs on that
volume. A platform that wants to defer the move can set
`globalAppTopologySpreadConstraints` to a `ScheduleAnyway` policy, which
the other charts that read it pick up too.

#4947 gives the same tiers a preferred pod anti-affinity in its second
commit and argues against a required rule because of exactly this case.
Since then the Alertmanager layout showed up on a third cluster, and
#4986 found tenant etcd members on one node despite a `ScheduleAnyway`
spread on the same storage classes, so this PR takes the other side for
the tiers that keep state and states the cost. The two touch
neighbouring lines but merge cleanly, and the monitoring suite passes on
the merge, 27 suites and 327 tests. If you prefer this approach, the
monitoring commit of #4947 is no longer needed.

### Tests

`tests/topology_spread_test.yaml` pins the whole constraint list of
every tier for the default, for a second VMCluster name, for an empty
platform policy, for a zone policy, for a policy with two constraints,
for a policy constraint that brings its own selector, and for a
constraint without a selector after and before one with its own, with
`matchLabels` and with `matchExpressions`.
`tests/topology_spread_invalid_policy_test.yaml` pins the failure for a
policy that does not parse, a bare list, an empty list and a map.
Against the templates on main all 18 cases fail, and against
0dbbb3b157 only the two new ones. The suites also catch each of 19
mutations, which are a soft default for every tier, no
`nodeTaintsPolicy`, `Honor`, `maxSkew: 2`, a soft vmselect, vlstorage,
vtstorage or Alertmanager, a hard vminsert, ignoring the platform
policy, adding the selector to the last platform constraint only, keying
vmstorage to the release name, dropping the failure, dropping either of
its two conditions, overwriting a selector the policy brings, and
merging the tier's selector into the shared selector map, into the
parsed policy constraint or into every constraint. The first of those
three is the merge order of the first commit. With a policy that mixes
both kinds of constraints it wrote the policy's own selector into the
selector of every constraint without one, and only the two new cases
catch it.

```console
$ docker run --rm -v "$PWD":/apps -w /apps/packages/system/monitoring helmunittest/helm-unittest:4.2.3-1.1.2 .
Charts:      1 passed, 1 total
Test Suites: 26 passed, 26 total
Tests:       322 passed, 322 total
```

On main the same command gives 24 suites and 304 tests, with
helm-unittest 1.1.2 as CI pins it, and `packages/extra/monitoring` stays
at 4 suites and 31 tests. With default values `helm template` differs
from main only in the new blocks and in the alerta key and Grafana
password the chart generates at random, and an empty
`globalAppTopologySpreadConstraints` renders the same as none. I also
decoded the rendered VMCluster, VLCluster, VTCluster and VMAlertmanager
specs strictly into the operator's v0.68.4 API types, which rejects
unknown fields, and checked each selector against the labels the
operator's `PodLabels` gives its component. Each matches its own
component and no other one in the release. With a policy that mixes both
kinds of constraints the same holds for every selector the chart adds,
and the policy's own selector stays as written. I have not run the e2e
suite or rolled this out on a cluster.

`vmcluster.yaml` and `vlogs.yaml` are the same on release-1.6, and
`alerta.yaml` differs from main in one unrelated line. release-1.6 has
no VictoriaTraces, so the backport leaves those lines and their tests
out. That backport is a separate PR.

### Screenshots

Not a UI change.

### Downstream repositories

Only templates and tests of `packages/system/monitoring` change. No
values, schema, README, `ApplicationDefinition`, platform values or
tooling change, and the website shows the monitoring PVCs and pods of an
install but documents no placement workaround, 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(monitoring): spread vmstorage, vmselect, vlstorage, vtstorage and Alertmanager replicas with DoNotSchedule; other tiers use ScheduleAnyway. Pods pinned to a node-local volume can remain Pending if a peer already occupies that node. Before upgrading, set scheduling.globalAppTopologySpreadConstraints to a topologySpreadConstraints list with maxSkew: 1, topologyKey: kubernetes.io/hostname and whenUnsatisfiable: ScheduleAnyway to retain permissive scheduling. This platform-wide override also applies to other charts that consume it. It can also unblock an upgrade already stalled on the spread constraint without deleting volumes. To retain hard spreading instead, plan the affected replica's storage migration or recreation on another node. Recreating its PVC discards that replica's data: vmselect loses cache, vmstorage loses one copy of historical series, and vlstorage loses the logs on that volume. Verify replication or restore coverage before any destructive recovery; do not delete a primary or the last data copy.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Improved monitoring workload distribution across hosts and zones to
increase resilience.
- Added topology-aware scheduling for metrics, logs, traces, and
alerting components.
- Supports configurable platform scheduling policies, including required
and preferred placement rules.
- Provides sensible hostname-based defaults when no custom policy is
configured.

- **Bug Fixes**
- Ensures scheduling constraints consistently target the correct
monitoring components, including when custom constraints are supplied.
- Added validation for malformed or unsupported topology scheduling
policies.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 16:09:45 +03:00
Aleksei Sviridkin 4131169c3c fix(redis, valkey, harbor): spread sentinels and data pods over nodes (#4990)
## What this PR does

The RedisFailovers rendered by the `redis` and `valkey` apps and by the
Harbor system chart set no placement, so the operator applies its
default, a preferred pod anti-affinity on `kubernetes.io/hostname`
([generator.go#L795-L816](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/generator.go#L795-L816),
the same in spotahome v1.3.0-rc1 that release-1.6 ships). A preference
only decides where a pod starts. A sentinel evicted by a drain is
recreated while both other nodes already run one, and a rollout of the
sentinel Deployment adds each new sentinel before it removes an old one,
so either can leave two sentinels on one node, and nothing moves them
back.

Seen on a three-node cluster running v1.6.4 and on clusters running
v1.6.5. A tenant Redis with three replicas had its three Redis pods on
three nodes and two of its three sentinels on one node, and Harbor's
Redis had two of its three sentinels on one node too. Losing that node
leaves one sentinel, below the quorum of two, so no failover can happen
while it is down. The operator does not step in either, because it skips
its checks while a pod of the instance is Pending or terminating
([checker.go#L101-L111](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/checker.go#L101-L111)),
and the pods of a lost node stay terminating, so if the master was on
that node the instance has no master until the node is back.

This PR gives the sentinels and the data pods a spread with `maxSkew: 1`
on `kubernetes.io/hostname`, `whenUnsatisfiable: DoNotSchedule` and
`nodeTaintsPolicy: Ignore`, the default #4986 proposes for tenant etcd.
The selector is the `app.kubernetes.io/name` and
`app.kubernetes.io/component` pair the operator puts on every pod,
without `redisfailovers-role`, which the operator switches between
`master` and `slave` at runtime. No `affinity` is set, so the operator's
anti-affinity stays. When
`_cluster.scheduling.globalAppTopologySpreadConstraints` is set it
replaces the default, and the selector is added to each of its
constraints that has none, as the keycloak chart does for its database
constraints. The etcd and postgres charts add it under the last
constraint only, and a constraint without a selector counts no pods
([helpers.go#L36-L39](https://github.com/kubernetes/kubernetes/blob/v1.33.12/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/helpers.go#L36-L39)),
so with a zone and a node constraint the zone one would spread nothing.
A policy that does not parse or has no non-empty
`topologySpreadConstraints` list fails the render.

The sentinels get a hard constraint because of the quorum. A sentinel
that waits Pending while its node is away leaves two sentinels on two
nodes, which still form the quorum, while two sentinels on one node turn
the loss of that node into a lost quorum. With `Ignore` a cordoned node
still counts, so an evicted sentinel waits for its node instead of
starting next to another one. The data pods get the same constraint
because on a node-local StorageClass a pod that starts next to another
one stays there with its volume. An instance with more pods than nodes
still starts, because the skew is counted between the nodes that exist
([filtering.go#L338-L356](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/scheduler/framework/plugins/podtopologyspread/filtering.go#L338-L356)).

The sentinel constraint also has `matchLabelKeys: [pod-template-hash]`.
The operator sets no strategy on the sentinel Deployment
([generator.go#L546-L551](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/generator.go#L546-L551)),
so a rollout of three sentinels adds one new pod at a time while the old
ones run. Counted together with the old pods, a new sentinel can start
on a node that already has another new one, and that pair stays once the
old pods are gone. With the key, new pods are counted only against each
other
([common.go#L95-L105](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/scheduler/framework/plugins/podtopologyspread/common.go#L95-L105)),
and the ReplicaSet removes old pods that share a node with another pod
first
([replica_set.go#L863-L878](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/controller/replicaset/replica_set.go#L863-L878),
[controller_utils.go#L859-L865](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/controller/controller_utils.go#L859-L865)),
so a rollout on three or more nodes ends with one sentinel per node.
`matchLabelKeys` is beta and on by default since Kubernetes 1.27
([kube_features.go#L1502-L1505](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/features/kube_features.go#L1502-L1505)).
The RedisFailover CRD on main has both fields, and the redis-operator
package replaces the CRD on upgrade.

On upgrade the operator writes the StatefulSet and the sentinel
Deployment in the same pass
([ensurer.go#L49-L57](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/ensurer.go#L49-L57)).
The Deployment controller rolls the sentinels one at a time and removes
an old one only after its replacement is ready, so three sentinels stay
available. The StatefulSet uses `OnDelete`
([generator.go#L376-L379](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/generator.go#L376-L379))
and the operator replaces its pods itself
([checker.go#L14-L83](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/checker.go#L14-L83)).
It waits while any Redis or sentinel pod is Pending or terminating
([check.go#L547-L559](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/check.go#L547-L559))
or a replica is not in sync, so the Redis pods are normally replaced
after the sentinel rollout, one outdated replica per pass and the master
last. The master's preStop hook asks the sentinels to fail over before
the pod stops
([generator.go#L263-L267](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/generator.go#L263-L267)),
so an instance with replicas goes through one failover during the
upgrade, and a single-pod instance restarts its pod. The charts do not
set `disableMasterRollout`. The Cozystack patches to the operator do not
change any of this.

This has two costs. With `Ignore` a node the pods can never run on, such
as a tainted control plane, counts as an empty node, so on such a
cluster each usable node takes one pod at most and the rest stay
Pending, and for Redis a Pending pod also stops the operator's checks
for the instance, including the choice of the first master of a new one.
And data pods that already share a node on a node-local volume cannot be
separated by a reschedule. The replica the operator recreates there
during the rollout cannot be placed, the rollout stops before the
master, and the instance runs one replica short, with the operator's
checks stopped, until that replica's volume is recreated on another
node. On storage that attaches from any node the recreated replica moves
to a free node instead. A platform that wants the old behaviour can set
`scheduling.globalAppTopologySpreadConstraints` to `ScheduleAnyway`,
which the other charts that read it pick up too.

#4880 adds a zone spread to the same two blocks of Harbor's
RedisFailover and leaves the per-node part to the operator's
anti-affinity, so whichever of the two lands second has to merge them.
#2665 adds `affinity` values to the redis app, which would replace the
operator's anti-affinity and do not touch the spread. The valkey app had
no `test` target, so this PR adds the same three lines as #4346.

New suites `packages/apps/redis/tests/topology_spread_test.yaml`,
`packages/apps/valkey/tests/topology_spread_test.yaml` and
`packages/system/harbor/tests/redis_spread_test.yaml` pin both default
constraints, that no `affinity` is rendered, that a cluster-wide policy
renders in place of the default with the selector added to every
constraint that has none, that a selector the policy sets itself is
kept, and that a malformed policy fails the render. Against the
templates on main every new case fails, 9 for redis, 5 for valkey and 5
for Harbor, and against the first commit the 12 cases the second commit
adds fail. Each of 21 mutations fails at least one case. In the default
constraints they are `ScheduleAnyway` or no `matchLabelKeys` for the
sentinels, `Honor` or `redisfailovers-role` in the selector for the data
pods, `maxSkew: 2` in valkey and the Harbor sentinel selector set to
`redis`. In the cluster-wide branch they are the policy ignored,
`nodeTaintsPolicy` added to it, the selector added to no constraint, a
selector the policy sets overwritten, the sentinel selector set to
`redis`, the Harbor name without its `-redis` suffix, the policy check
dropped or reduced to the empty list, and the parse error left out of
the message.

```console
$ docker run --rm -v "$PWD":/apps -w /apps/packages/apps/redis helmunittest/helm-unittest:4.2.3-1.1.2 .
Test Suites: 6 passed, 6 total
Tests:       77 passed, 77 total
$ docker run --rm -v "$PWD":/apps -w /apps/packages/apps/valkey helmunittest/helm-unittest:4.2.3-1.1.2 .
Test Suites: 1 passed, 1 total
Tests:       5 passed, 5 total
$ docker run --rm -v "$PWD":/apps -w /apps/packages/system/harbor helmunittest/helm-unittest:4.2.3-1.1.2 .
Test Suites: 3 passed, 3 total
Tests:       14 passed, 14 total
$ hack/check-render-matrix.sh packages/apps/redis packages/apps/valkey packages/apps/harbor
check-render-matrix: 3 rendered, 0 skipped
```

On main the redis chart has 68 tests in 5 suites and Harbor 9 in 2. With
the render fixtures `helm template` of the three charts differs from
main only in the added constraints, apart from the values they generate
on every render. I have not rolled this out on a cluster, and the
scheduling was not exercised against a running kube-scheduler.

The files are the same on release-1.7. release-1.6 ships spotahome
v1.3.0-rc1, whose CRD has neither `nodeTaintsPolicy` nor
`matchLabelKeys` and is not replaced on upgrade, so its backport is a
separate PR without those two fields.

### Screenshots

Not a UI change.

### Downstream repositories

Templates and tests of `packages/apps/redis`, `packages/apps/valkey` and
`packages/system/harbor`, plus a `test` target in the valkey Makefile.
No values, schema, default, README or `ApplicationDefinition` change.
The website already describes `globalAppTopologySpreadConstraints` as
applied to all managed applications and documents no placement
workaround for Redis, 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(redis, valkey, harbor): spread Redis, Valkey and Harbor Redis data pods and sentinels with DoNotSchedule. The operator rolls existing instances, including one failover when replacing a replicated master. With nodeTaintsPolicy: Ignore, untolerated tainted nodes count as empty domains: if fewer nodes are usable than sentinels, some pods stay Pending. The operator skips its checks while any pod is Pending, so a new instance may never get its first master and an upgrade may stall. Node-local PVCs can also strand recreated replicas beside a peer. Before upgrading, set scheduling.globalAppTopologySpreadConstraints to a topologySpreadConstraints list with maxSkew: 1, topologyKey: kubernetes.io/hostname and whenUnsatisfiable: ScheduleAnyway to opt out. The override also applies to other charts that consume it. For an already stranded instance, apply that override, let the chart and operator reconcile, and verify all pods are Ready and a master is selected. This avoids deleting data. Keeping hard spreading instead requires enough usable nodes and a separate storage-migration plan for any stranded node-local replica.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

- **New Features**
- Added support for configuring topology spread constraints across
Redis, Valkey, Sentinel, and Harbor Redis workloads.
- By default, pods are spread across hostnames with workload-specific
selectors.
- Custom constraints apply to Redis and Sentinel pods. Existing
selectors are preserved; component-specific selectors are added when
none is provided.

- **Bug Fixes**
- Invalid or empty topology spread configurations now fail validation
during rendering.

- **Chores**
  - Added a test command for the Valkey chart.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 16:09:36 +03:00
Timofei Larkin 968d6d14dd refactor(etcd): render the etcd chart's objects from cozy-lib templates
The kubernetes chart is about to render an etcd of its own per cluster,
and it needs the same EtcdCluster, PKI, DataStore, defrag, VPA and
scrape shapes the etcd chart renders. It cannot take the etcd chart as a
subchart: the chart refuses any release not named "etcd", and the names
it renders are pinned by the immutable spec.tls of adopted clusters.

The shapes therefore move into cozy-lib, parameterised by the cluster
name, and the etcd chart calls them with "etcd". Its rendered output is
byte-identical before and after.

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-23 13:50:18 +01:00
Mattia Eleuteri fffbb97ac9 fix(kubernetes-nodes): surge one worker at a time during a pool rollout
A worker pool rolled out with maxSurge set to its maxReplicas, so CAPI
could create up to maxReplicas replacement VMs before draining any old
one. A pool running 8 workers under a ceiling of 10 could reach 18 VMs
at the peak of an instance type, image or version change.

Those extra VMs run in the tenant's namespace. Today the namespace
ResourceQuota counts them, so a tenant near its quota sees replacement
launchers refused and the rollout stall. Under quotas as reservation
limits, where a pool reserves maxReplicas workers and the namespace
quota goes away, the surge is capacity the platform lends for the
length of a rollout: rollouts are mostly platform-driven, and counting
them against the tenant would block a platform upgrade for any tenant
whose pool sits at its ceiling. That loan has to be bounded, and with
a surge tied to maxReplicas it was as large as the pool itself.

The surge is now one Machine whatever the pool's size. It stays out of
the values: tenants write them, and would then size the platform's
margin. maxUnavailable is unchanged, so a node is still only drained
once its replacement is up; a large pool now rolls one worker at a
time.

Tested with helm unittest on kubernetes-nodes, with the golden renders
updated for the new surge.

Refs: cozystack/community#48
Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 13:27:57 +01:00