Commit Graph
1726 Commits
Author SHA1 Message Date
Timofei Larkin f91ffd8fa7 test(reservation): check shipped consumption declarations on the rendered charts (#5411)
## What this PR does

The shipped-declaration test in `pkg/reservation` enforced a file layout
that no requirement asks for, and a correct open PR went red because of
it. The test came with #5349. It read
`packages/system/*-rd/cozyrds/*.yaml` as raw files and failed when two
files carried the same `metadata.name`. An `-rd` chart may keep one
definition per variant under one name and render only one of them. #4508
does this for the VPC cozyplane variant and has been red since #5349
merged. The same test also parsed cozy-lib's preset template with a
regexp, pinned about seventy figures the shipped declarations compute,
and required the IaaS kinds to declare consumption while nothing reads
the declarations yet.

The first commit moves the evaluator and classifier tests to fixtures.
They used to read schemas from the `cozyrds/` files and instance types
from the kubevirt-instancetypes templates. The expected figures stay the
same, and the exact product past int64 gets its own case.

The second commit checks the shipped declarations where the charts live.
`hack/check-rd-consumption.sh` renders each `-rd` chart with
`values.yaml`, and once more for each `values-<variant>.yaml` next to
it, together with the kubevirt-instancetypes chart.
`cmd/check-consumption` reads that stream and knows nothing about
charts. It fails when a declaration does not compile or does not
evaluate on its kind's defaults, and when a rendered instance type does
not classify. Presets come from a cozy-lib template helper and nothing
renders them, so an evaluation that reaches `preset()` stops there and
is reported as compiled. Only that lookup is tolerated, an unknown
instance type still fails. The check is a new `rd-consumption-check`
target under `make unit-tests`, which the Unit & controller tests job
runs.

The third commit deletes `pkg/reservation/shipped_test.go`. Open PRs
that add tests to that file (#5401, #5397) will need to move them.

I checked it against #4508 merged onto this branch, with no changes to
#4508: the Go tests and the new check pass, and the VPC cozyplane
variant is rendered on its own; it declares no consumption, so the check
has nothing to evaluate there. A broken shipped declaration fails the
check.

Comparing a declaration with the requests and limits its chart actually
renders is left for #5416.

### 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
test(reservation): shipped consumption declarations are checked on the rendered -rd charts instead of their source files, so an -rd chart can ship one definition per variant under the same name.
```


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

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

## Summary by CodeRabbit

- **Tests**
- Automated checks now validate resource consumption declarations across
system application charts and their value variants, reporting chart
rendering or validation failures.
- Unit tests now cover additional resource classification and
calculation cases, including products that exceed the supported integer
range.
- **Chores**
- The new validation check is included in the standard unit test
workflows.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-25 14:58:56 +04: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
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
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 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
Aleksei Sviridkin 01496d8130 test(reservation): check shipped declarations on the rendered charts
A consumption declaration on an ApplicationDefinition has to compile
against its kind's schema and evaluate on the kind's defaults, or the
first order of that kind fails. What the cluster gets is what each -rd
chart renders for the variant installed, so that is what to check: the
file layout of cozyrds/ is the chart's own business, and a chart may
keep one definition per variant under a single name.

hack/check-rd-consumption.sh renders every -rd chart with its
values.yaml and once more with each values-<variant>.yaml beside it,
the way a PackageSource variant lists them in valuesFiles, together
with the kubevirt-instancetypes chart. cmd/check-consumption reads that
stream and knows nothing about charts. It fails when a declaration does
not compile or does not evaluate, and when a rendered instance type
does not classify.

cozy-lib's preset table is a template helper with nothing rendered for
it, so an evaluation that reaches preset() stops there and is reported
as compiled; only that lookup is tolerated, an unknown instance type
still fails. The check runs under make unit-tests.

Tested: the command's tests cover a declaration that does not compile,
an instance type missing from the stream, one the classifier rejects
and the preset stop; widening the tolerance to any not-found error
fails them. The script's own test runs it on a stub chart and fails
when only a variant is broken or the chart does not render. A broken
shipped declaration fails the script.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-24 11:49:41 +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 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 5e6772ec3f fix(cluster-api): name the kubeconfig the upgrade hook runs with
The provider upgrade hook reaches the API through the kubeconfig its
Job mounts at /scripts/kubeconfig and exports as KUBECONFIG, never
through the in-cluster config. The script only named KUBE_CONTEXT,
so hack/check-hook-request-timeout.bats, which since it started
reading files/ exempts a script only when it names KUBECONFIG, took
its "kubectl --context ... --request-timeout=10s" for an in-cluster
call and failed "no in-cluster kubectl call carries a non-zero
--request-timeout" on main.

Require KUBECONFIG alongside the other inputs instead of loosening the
check or dropping the timeout: the per-call timeout is safe because
the explicit kubeconfig is what serves it, and the script now refuses
to fall back to the in-cluster config, where the timeout would hit the
bug the check guards against.

Tested with bats on hack/check-hook-request-timeout.bats,
hack/capi-upgrade_test.bats and hack/capi-upgrade-chart_test.bats; with
the script change reverted, the check and the new missing-KUBECONFIG
test both fail.

Fixes: 9680ed64df ("feat(cluster-api)!: update Cluster API to v1.14.4 (#4902)")
Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 13:24:41 +01:00
Aleksei Sviridkin f5ceed0e24 feat(linstor, platform): upgrade snapshot-controller to v8.7.0 and enable VolumeGroupSnapshots (#5239)
## What this PR does

Windows VMs with three or more disks cannot get an
application-consistent Velero backup on Cozystack today. Velero takes
one CSI snapshot per PVC, one after the other, while virt-freezer holds
the guest frozen, and on LINSTOR each snapshot takes 2 to 4 s. With
three disks or more the freeze runs past the 10 s that Windows VSS
allows, VSS aborts with `0x80042314`, and the backup fails. The only
workaround is `kubevirt.io/skip-backup-hooks=true` on the VM, which
gives up application consistency.

The fix is a VolumeGroupSnapshot: one snapshot request for all the PVCs
of a VM, taken inside the freeze. linstor-csi has implemented the CSI
GroupController since v1.11 (the package ships v1.11.2), and it creates
the whole group in a single LINSTOR `Resources.CreateSnapshots` call, so
every volume of the VM is captured at the same instant and the freeze
lasts one snapshot instead of N. Velero 1.18 drives VolumeGroupSnapshots
through `groupsnapshot.storage.k8s.io/v1beta2`. What is missing is on
the Cozystack side: snapshot-controller v8.0.1 serves the group snapshot
API only as v1alpha1 and runs without the `CSIVolumeGroupSnapshot` gate,
and piraeus-operator turns the gate off on the csi-snapshotter sidecar
when it does not find v1beta2.

This PR:

- Upgrades the vendored Piraeus `snapshot-controller` chart from 3.0.5
(v8.0.1) to 5.4.0 (v8.7.0) with the package's `make update`. The
`snapshot.storage.k8s.io` CRDs stay at v1. The
`groupsnapshot.storage.k8s.io` CRDs go from v1alpha1 only to v1beta1,
v1beta2 and v1, with v1beta2 as the storage version. The controller runs
with `--feature-gates=CSIVolumeGroupSnapshot=true`, the chart's default.
The validating webhook is gone upstream, replaced by CEL rules in the
CRDs. The new optional conversion webhook stays disabled, as upstream
ships it, since no cluster holds group snapshot objects to convert.
- Sets `keepCRDs: true`. The chart now renders its CRDs from a template
instead of `crds/`, so without it an uninstall of the release would
delete every VolumeSnapshot with the CRDs.
- Patches the vendored CRD template (`patches/skip-foreign-crds.diff`,
applied by `make update`) so a CRD is rendered only when it is absent or
already carries this release's `meta.helm.sh/release-name` and
`meta.helm.sh/release-namespace`. A CRD a distribution ships, or that
another release owns, stays out of the manifest, so helm-controller
neither takes it over nor rewrites it on upgrade. On a fresh install,
and for the CRDs migration 62 adopts, the output is unchanged.
- Adds migration 62 and bumps `migrations.targetVersion` to 63
(renumbered from 61 after upstream took migration 61 for the Strimzi v1
conversion). The CRDs `crds/` created carry no Helm ownership metadata,
and the patched chart renders only the CRDs that do, so the migration
annotates the three `snapshot.storage.k8s.io` CRDs the release installed
for adoption, which keeps them in its manifest. The three group snapshot
CRDs cannot be adopted: the apiserver rejects an update that drops
v1alpha1 while it is listed in `status.storedVersions`. The old
controller never ran with the gate, so no v1alpha1 object was ever acted
on, and the migration deletes each of these CRDs when it is empty and
creates it again straight away at v1beta2, from copies `make
image-migrations` renders out of the snapshot-controller chart with the
release's ownership metadata (as it already bakes the etcd-operator CRDs
for migration 50). Every HelmRelease waits for this pre-upgrade hook, so
the linstor release renders against the v1beta2 API even when it
upgrades before snapshot-controller. A CRD that still holds objects is
kept and recorded on the `cozystack-version` ConfigMap as
`cozystack.io/migration-62-needs-attention`, and the CRD stays out of
the release, which carries no Helm ownership on it, so
snapshot-controller still upgrades with that group snapshot API at
v1alpha1 and group snapshots off. Nothing re-renders either release once
the CRD is cleaned up, so the migration's warning gives the whole
recovery: delete the objects and the CRD, force a snapshot-controller
HelmRelease upgrade so the chart creates the CRD at v1beta2, restart the
snapshot-controller Deployment, which sets up its group snapshot watches
only when it starts, then force a linstor HelmRelease upgrade. The
migration only touches CRDs that helm-controller labelled as installed
by `cozy-snapshot-controller/snapshot-controller`, and the chart leaves
the others out of the release, so a distribution that ships its own
snapshot CRDs keeps them in both places. Whether the release is
installed is read from its HelmRelease rather than from those labels, so
a retry after a failed create still recreates the group CRDs it deleted
when only they carried the labels; without the HelmRelease the migration
changes nothing. The version is stamped only once every release-owned
v1beta2 group snapshot CRD is Established, whichever path brought it
there, so a retry after a timed-out wait waits again rather than letting
linstor render before the API is served.
- Sets `FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT=true` on the linstor-csi
`csi-snapshotter` sidecar through the LinstorCluster pod template.
piraeus-operator v2.10.2 probes for the v1beta2 API once, when it
starts, and adds a patch that sets the variable to `false` when the
probe fails. On a cluster upgraded from v1alpha1 the operator started
before the new CRDs existed, so the gate would stay off until the
operator next restarted. The pod template is merged after the operator's
own patch. The variable is always set, to `true` only when the apiserver
serves all three `groupsnapshot.storage.k8s.io/v1beta2` kinds and to
`false` otherwise: the operator's probe looks at VolumeGroupSnapshot
alone, and csi-snapshotter with the gate on and a group API missing
waits for its group snapshot caches before it starts the ordinary
snapshot workers. The class below renders under the same check.
- Adds a default `VolumeGroupSnapshotClass` `linstor-group-snapshots`
for `linstor.csi.linbit.com`, next to the existing `linstor-snapshots`
VolumeSnapshotClass, with the `velero.io/csi-volumegroupsnapshot-class:
"true"` label Velero selects a group snapshot class by. Only on a
cluster where migration 62 kept a populated v1alpha1 CRD do they wait
for the forced linstor upgrade at the end of that recovery.

Not in this PR: grouping a VM's PVCs for Velero. Velero builds a group
from the PVCs that share the value of the `velero.io/volume-group`
label, so the `vm-instance` and `vm-disk` charts would have to set it to
the VM name on every disk. That is a separate change, and an operator
can set the label by hand meanwhile.

Testing:

- Kubernetes v1.34.3, Velero 1.18.1, linstor-csi v1.11.2,
piraeus-operator v2.10.2. On that cluster the group snapshot CRDs are
v1alpha1 only, list `["v1alpha1"]` in `storedVersions`, hold no object,
and carry the helm-controller labels of
`cozy-snapshot-controller/snapshot-controller`. The csi-snapshotter
sidecar runs with `FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT=false`, set by
the operator's patch.
- `hack/migration-62-snapshot-crds.bats` (16 cases) runs migration 62 in
the migrations base image against a fake kubectl that keeps the CRDs in
a state file: adoption and deletion, a second run that changes nothing,
a CRD holding objects, CRDs another installer owns, CRDs that already
serve v1beta2, a cluster without the release, a release without the
group CRDs, a failing HelmRelease read, CRD read or delete that aborts
before the stamp, a failed diagnostic record that still stamps, a failed
create that aborts and is completed by the retry, release labels on the
group CRDs alone, with and without a failed first create, a timed-out
Established wait whose retry must wait again before stamping, and a
v1beta2 CRD that still stores v1alpha1, which is recorded rather than
adopted. With the delete removed from the migration, the first case
fails; with the release identity taken from the CRD labels instead of
the HelmRelease, the failed-create case with group-only labels stamps 63
without recreating the CRDs and fails. Without the wait on the adoption
path, the timed-out-wait case stamps 63 on the retry without waiting and
fails.
- New helm-unittest suites:
`packages/system/snapshot-controller/tests/crds_test.yaml` pins
`keepCRDs`, v1beta2 served and stored on the three group snapshot CRDs
and the controller gate;
`packages/system/snapshot-controller/tests/crd_ownership_test.yaml`
mocks the live CRDs and checks that one without Helm ownership and one
owned by another release are left out while an absent one and one this
release owns are rendered (it fails with the patch reverted);
`packages/system/linstor/tests/volume_group_snapshot_test.yaml` pins the
sidecar gate on with and without strict topology, off when only
VolumeGroupSnapshot or no group API is served, and the
VolumeGroupSnapshotClass rendered only when the v1beta2 API is served.
`csi-topology_test.yaml` now counts the `csi-snapshotter` entry in the
pod template.
- `helm unittest` passes for `packages/system/linstor` (30 tests),
`packages/system/snapshot-controller` (7) and `packages/core/platform`
(285). `hack/cozystack-version-stamp.bats` and
`hack/check-migrations-target.sh` pass.
- Not yet run end to end: the upgrade of a live cluster through
migration 62, and a Velero backup with a VolumeGroupSnapshot through
linstor-csi.

### 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 only change to `packages/core/platform/values.yaml` is the value of
`migrations.targetVersion`. The website's `platform-package.md` lists
that key without a value, so it needs no change. No website page
mentions VolumeGroupSnapshots or documents the snapshot-controller
webhook. The rest of the diff is a vendored chart, two system packages,
a migration and its tests, none of which the trigger map reaches.

### Release note

```release-note
feat(platform): snapshot-controller is upgraded to v8.7.0 and serves VolumeGroupSnapshots as groupsnapshot.storage.k8s.io/v1beta2, and linstor-csi takes group snapshots with a default VolumeGroupSnapshotClass labelled for Velero. A platform migration hands the snapshot CRDs over to the release and removes the empty v1alpha1 group snapshot CRDs.
```


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

## Summary by CodeRabbit

* **New Features**
* Added LINSTOR volume group snapshot support when all required APIs are
available, including a default snapshot class.
* Updated the snapshot controller to support newer snapshot APIs and a
conversion webhook.
* Added safer CRD installation and upgrade handling, preserving CRDs
with existing objects and recording items that need attention.

* **Bug Fixes**
* Improved snapshot-controller upgrade reliability, including recovery
from certain CRD creation failures.

* **Documentation**
* Updated chart guidance for CRD management, conversion webhooks, and
snapshot class configuration.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 14:12:46 +03:00
Aleksei Sviridkin 39f3f73fbc fix(postgres): keep users.app's password across pod restarts (#4984)
## What this PR does

A Postgres app that declares a user named `app` loses that user's
password every time its pod restarts. Clients keep the password
advertised in `<release>-credentials` and start failing with `password
authentication failed for user "app"`, with nothing changed on their
side.

`app` is the owner role CNPG bootstraps, with a generated password in
`<release>-app`, and a declared `users.app` adopts that role (the
init-script says so). The init-job sets the role's password from
`<release>-credentials`, but CNPG's instance manager re-applies the
owner's password from the bootstrap secret whenever it meets a secret
version it has not applied yet (`refreshCredentialsFromSecret` →
`reconcileUser` in
`internal/management/controller/instance_controller.go`). Its cache is
in memory, so every pod start re-applies `<release>-app` and silently
undoes the init-job. Only releases whose two secrets happen to differ
break, which is every release where `users.app` was declared at
creation.

This PR renders a `<release>-app-owner` basic-auth Secret from the same
password `<release>-credentials` holds, and sets
`spec.bootstrap.<method>.secret.name` to it, so both writers agree on
one value. CNPG resolves the owner secret through that field before
falling back to `<release>-app`, never rewrites the data of a secret it
does not own, and its webhook accepts a bootstrap change on an existing
Cluster. The secret goes on the method the live Cluster was bootstrapped
with, read through `lookup`, because CNPG rejects two methods and a
restored Cluster keeps `bootstrap.recovery` in its live spec. A release
with no `users.app` renders exactly what it rendered before, and a
restore in progress (`bootstrap.enabled`) is left alone, since the chart
flags its credentials as pending until the init-job runs.

We hit this in production: the cluster-wide pod restart of a platform
upgrade broke two of the four apps that declare `users.app`; the two
others survived only because their two secrets held the same value.

`tests/app_owner_secret_test.yaml` covers the shared password (preserved
and freshly generated), the initdb and recovery methods, a release
without `users.app`, and an in-progress restore. Without the template
change, 5 of its 8 tests fail. The full chart suite passes (217 tests).

### Screenshots

Not a UI change.

### Downstream repositories

Walked against the diff: two templates and one test file under
`packages/apps/postgres`. No package is added or renamed, `values.yaml`,
`values.schema.json` and `README.md` are untouched, and no output Secret
or Service is renamed (a new Secret is added; the Terraform provider
reads only `-credentials`, `-rw` and `-ro`).

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

### Release note

```release-note
fix(postgres): a user named `app` no longer loses its password when the Postgres pod restarts. CNPG re-applied its own generated password to the `app` owner role on every pod start; the chart now hands CNPG the password stored in `<release>-credentials`.
```


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

## Summary by CodeRabbit

- **New Features**
  - Added owner credentials when the `app` user is configured.
- PostgreSQL clusters now use those credentials during initialization or
recovery, while preserving compatible recovery settings for restored and
actively recovering clusters.

- **Bug Fixes**
- Ensured generated or existing `app` passwords are reused for owner
credentials.

- **Tests**
- Added coverage for credential reuse, password generation, omitted-user
behavior, and cluster recovery scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 13:39:43 +03:00
Aleksei Sviridkin afa3dfa224 feat(virtual-machine): group a VM's claims for Velero volume group snapshots (#5240)
<!-- 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

An application-consistent Velero backup of a VM freezes the guest,
snapshots its PVCs one after another, then thaws it. Windows holds a VSS
freeze for 10 seconds at most, and on LINSTOR each CSI snapshot takes
about 4 seconds. So a Windows VM with three volumes (system disk, data
disk and the `persistent-state-for-*` claim KubeVirt keeps for TPM/EFI
state) overruns the window: `virt-freezer --unfreeze` fails with
`VSS_E_HOLD_WRITES_TIMEOUT` and the backup is only crash-consistent.
Velero 1.18 snapshots the PVCs that share a `velero.io/volume-group`
value as one VolumeGroupSnapshot, which linstor-csi takes as a single
atomic snapshot.

This adds a `post-install,post-upgrade` hook to `vm-instance` that
labels every claim of the VM with `velero.io/volume-group:
<VirtualMachine name>`. That covers the `vm-disk-<name>` claim of each
disk in `disks`, and the claims KubeVirt labels `persistent-state-for:
<VirtualMachine name>`. The hook also removes the label from claims
still carrying this VM's group once they no longer belong to it (a
detached disk, or a group that can no longer form). A claim grouped
under another VM is left alone.

A `vm-disk-<name>` claim belongs to the `vm-disk` release and outlives
the VM, and the hook leaves out a claim grouped under another VM's name,
so a disk reattached to a replacement VM would otherwise keep its old
group for good. A `pre-delete` hook therefore removes this VM's group
from every claim still carrying it when the release is uninstalled. Helm
runs uninstall hooks from the stored manifest, so that hook is rendered
unconditionally, and it selects the claims at run time with `-l
velero.io/volume-group=<VM>` rather than from a render-time list that
would be stale by then. Its Role needs `list` on the namespace's claims
for that; the removal is the same JSON `test`+`remove` patch, so a claim
another VM grouped in the meantime keeps its group.

Why a hook and not a label in the charts' own manifests:

- CDI copies DataVolume labels to the PVC only when it creates it
(`newPersistentVolumeClaim` in
`pkg/controller/datavolume/controller-base.go`, v1.66.1), so a label
added to an existing VMDisk's DataVolume never reaches its claim.
- A VMDisk is created, and its PVC with it, before any VMInstance names
it, so `vm-disk` cannot know the VM at that point; the disk-to-VM
mapping only exists in `vm-instance` values. `vm-disk` is therefore
unchanged.
- KubeVirt creates the persistent-state PVC with a fixed label set
(`createPVC` in `pkg/storage/backend-storage/backend-storage.go`,
v1.9.0); nothing on the VM or VMI spec adds labels to it.

Velero 1.18.1 has no fallback for a labelled claim it cannot group
(`getVolumeSnapshotReference` in
`pkg/backup/actions/csi/pvc_action.go`). Any of these fails the claim's
backup: an unbound member, two CSI drivers in the group, or anything
other than exactly one VolumeGroupSnapshotClass labelled
`velero.io/csi-volumegroupsnapshot-class: "true"` for the driver. The
hook therefore forms the group only when all of these hold, and removes
the label otherwise:

- the claims are bound and use a single CSI driver;
- at least two of them exist;
- `groupsnapshot.storage.k8s.io/v1beta2` is served;
- exactly one default class serves that driver.

On a cluster without group snapshot support the hook does not render.
That is every cluster on current `main`, which runs snapshot-controller
v8.0.1 with v1alpha1 CRDs. A companion change upgrades
snapshot-controller to v8.7.0, enables the `CSIVolumeGroupSnapshot` gate
on linstor-csi and adds a default VolumeGroupSnapshotClass. This PR does
nothing until something like it lands.

The hook is gated on render-time lookups like `vm-update-hook.yaml`, so
a converged VM renders no Job, and its Role is limited by
`resourceNames` to the claims it patches. Existing VMs are picked up on
their next Helm upgrade, which a Cozystack upgrade that bumps the chart
triggers.

Known limit: the hook labels only the claims the render saw. A
persistent-state claim created after it stays unlabelled until the next
upgrade. That happens on the first boot of a new VM, and on every live
migration, where KubeVirt creates a new RWO claim. Such a claim is
snapshotted on its own, next to one group snapshot of the disks: two
snapshot operations, which still fit the freeze window, as two-volume
VMs show today. Closing that gap needs something that sees every PVC
creation. The lineage webhook is a candidate: it already mutates PVCs on
create and walks the owner graph to the VMInstance. That is left for a
follow-up.

`tests/instancetype_resources_test.yaml` rendered every template, and
the fake client of helm-unittest refuses a list lookup for a kind it
does not register. That suite is therefore scoped to `vm.yaml` and
`vm-update-hook.yaml`, the two templates it covers.
`tests/volume_group_hook_test.yaml` covers labelling, convergence, label
removal, the Job's security context and each gate: API not served, no
default class, two default classes, two drivers, an unbound claim, a
single claim. Each gate was checked to fail its test when removed.

`tests/volume_group_release_hook_test.yaml` pins the uninstall hook's
manifest, and `hack/vm-volume-group-release-hook.bats` runs its script
against a fake kubectl: every claim the VM grouped is released, a
detached disk included, another VM's claim is untouched, a claim
regrouped or deleted between the list and the patch does not fail the
uninstall, and a failed list or a patch that leaves the label in place
does. `tests/volume_group_hook_test.yaml` also covers a differently
named VM grouping the released disks.


### 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
feat(virtual-machine): label every PVC of a VMInstance with velero.io/volume-group, so Velero snapshots them as one VolumeGroupSnapshot when the cluster serves groupsnapshot v1beta2 with a default VolumeGroupSnapshotClass for their CSI driver.
```


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

## Summary by CodeRabbit

* **New Features**
* VM disk and persistent-state volumes can now be grouped for snapshots
when the storage provider and snapshot configuration support it.
* Volume grouping is updated automatically as claims change; ineligible
volumes are excluded, and claims assigned to another VM are left
unchanged.
* Grouping is applied only when multiple bound volumes share a supported
storage driver and a matching default snapshot class is available.
* Volumes no longer eligible for the VM’s group are ungrouped, and
missing volumes are safely skipped.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 13:26:04 +03:00
Andrei Kvapil 9680ed64df feat(cluster-api)!: update Cluster API to v1.14.4 (#4902)
<!-- 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.
- Breaking changes: append `!` after type/scope or add a `BREAKING
CHANGE:` footer.
- If it is a work in progress, consider creating this PR as a draft.
- Ask for opinion and review in the community chats when needed.
- Fixes merged to main reach supported release lines through the
backport batch automatically. Do not open backport PRs by hand.
-->

## What this PR does

Updates the Cluster API stack with an automatic intermediate upgrade for
existing v1.10 providers.

The core chart upgrades them through v1.13.8 before Helm applies the
final manifests. The hook fails on API errors, conflicting changes or
timeouts. The hook image goes through cozy-lib. The core chart's
PackageSource declares that library, otherwise the packaged chart can't
render the hook. Fresh installations skip the intermediate providers.
Helm keeps the intermediate ConfigMaps, so they stay in the cluster
after the next change of the intermediate version, and that bump has to
remove them.

Each provider now selects exactly one repository. The bridge and final
ConfigMaps carry `provider.cluster.x-k8s.io/version` with the full
version, including the role suffix, and the core and kubeadm selectors
include it. The operator's finalize step hashes every ConfigMap the
selector matches and rejects more than one. During an upgrade it also
checks the selector of every other installed provider. So the bridge
ConfigMaps carry only the version label, and the v1.10 selectors, which
have no version, never match them. The hook switches the version and the
selector in one guarded patch and selects a bridge by that label alone.
It also narrows an existing bridge selector to that label. A provider
whose first installation never finished takes the fresh-install path.

Kamaji, CAPK, capmox and IPAM keep their existing pins and temporary
v1beta1 compatibility. The autoscaler keeps its explicit v1beta1
selection. An infrastructure provider's v1beta1 `failureReason` no
longer immediately fails a Machine or triggers remediation. The provider
conditions still show the cause.

The vendored operator chart gets six local patches, and `make update`
reapplies them. The core components get a startup probe patch. The
sync-period patch from main stays. I kept the one-minute resync setting
until restart recovery is tested.

CAPI Bats, the bootstrap and platform Helm suites and the rendering
checks pass locally. On envtest against cluster-api-operator v0.30.0,
legacy v1.10 core and kubeadm providers go through v1.13.8 to v1.14.4
with these ConfigMaps. With the old bridge labels core stayed on v1.10.
I have not run a live upgrade, restart or eviction test on this
revision. The [earlier Proxmox
report](https://github.com/cozystack/cozystack/pull/4902#pullrequestreview-5510737333)
covers the v1.13 candidate only.

### Screenshots

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

Not a UI change.

### Downstream repositories

<!-- Cozystack is upstream for repositories that are not kept in sync
automatically. Check the trigger map in docs/agents/contributing.md
against the diff. Keep every checkbox. Tick an affected repository only
after linking an existing or newly opened follow-up. Do not claim no
downstream impact when it is unknown. -->

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: cozystack/website#751
- [ ]
[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 existing website follow-up needs the management-cluster minimum
updated to v1.33. No tenant API fields, version enums, installer values
or platform variants change.

### Release note

```release-note
feat(cluster-api)!: update Cluster API core and kubeadm bootstrap to v1.14.4, cluster-api-operator to v0.30.0 and Talos bootstrap to v0.6.13. Legacy core and kubeadm installations are upgraded through v1.13.8 before the final manifests are applied. The core and kubeadm bootstrap charts reject management Kubernetes older than v1.33. The upgrade is one-way: Cluster and Machine CRDs use v1beta2 storage and downgrades are not supported. The preferred Cluster API version becomes v1beta2. Clients relying on v1beta1 fields must select that version explicitly. The operator no longer serves operator.cluster.x-k8s.io/v1alpha1. The autoscaler stays on the v1beta1 Cluster API.
```
2026-11-23 11:00:48 +01:00
Andrey KolkovandYan Bondarenko 4fb8ea40e2 test(clickhouse): delete the system-bucket Backup while its S3 host resolves
Deleting a system-bucket Backup now deletes its archive through the
clickhouse-backup sidecar, and the Backup is held until that delete is
answered. The delete reaches S3 at s3.example.org only through the
CoreDNS rewrite and the Ingress certificate the round-trip installs,
and the script's EXIT trap removes both. The round-trip therefore
deletes its Backup inside the script, before the trap runs, and waits
for the cleanup; the preconditions and the step's finally mark a
Backup they still find with skip-artifact-cleanup, since no S3 host is
mapped by then. The wait covers a cleanup Job that runs out its 600s
deadline, the 30s retry delay and a second Job, so the route is not
removed while a retried delete still needs it.

The test then checks the delete itself by listing the objects under
the archive's prefix in the system bucket, through the S3 Ingress with
the projected credentials and with folder entries left out: some before
the delete, none once the Backup is gone. clickhouse-backup's
list/remote is not used for this: it reports an archive for every
prefix at the top of the bucket, and SeaweedFS was seen to keep the
folders the delete emptied for minutes after all their objects were
gone.

Co-authored-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
2026-11-23 12:15:07 +03:00
Alexey Artamonov 8cf04bdd0f fix(clickhouse): make the example strategy use the archive its Backup records
The example strategy minted its own archive name from the clock and
restored the newest archive of the source application. The controller
then found no archive name in the backup Job and recorded none, so a
restore of an older Backup silently restored the latest archive and
deleting a Backup left its archive in the bucket.

The example now uploads under the name the controller chose and
restores the archive the Backup records, as the shipped strategy does;
the clock-made name and the newest archive remain the fallback for a
run the controller gave no name. The backup scenario no longer says the
archive is expired by the upstream tool's retention, which the chart
does not configure.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-11-23 12:15:06 +03:00
Aleksei Sviridkin 319c2c81f7 test(migrations): build each migration test image once per file (#5362)
## What this PR does

Closes #5299

In `hack/migration-{54,55,57,58,59,61}-*.bats`, every test calls
`prep()`, and `prep()` ran `docker build -q -t "$TESTIMG"` for one fixed
tag derived from the alpine pin. Under `bats -j N`, the tests in a file
run concurrently. On a cold cache, several uncached builds of that tag
therefore ran at the same time. The issue traces how a retag on the
containerd image store deletes the old image before creating the new
one, so a sibling's `docker run` can find the tag missing and fall back
to a pull.

This PR takes the first fix the issue suggests:
- `build_test_image()` holds the existing Dockerfile for each file,
unchanged (`jq`, plus `bash` for migration 61). Its exit status is
`docker build`'s, so a failed build still fails the caller.
- `setup_file()` builds the image once, before any test in the file
starts. If docker isn't available it does nothing, so `prep()` still
prints its existing "docker is required" message.
- `prep()` now runs `docker image inspect "$TESTIMG" ||
build_test_image`, so it only builds as a fallback when the tag is
missing (for example, a run without bats' `setup_file`). Under bats the
image already exists, so tests never build concurrently.

The issue lists 54, 55, 57, 58 and 59.
`migration-61-strimzi-v1-conversion.bats` has the same `prep()` pattern,
so it's included. Its separate `cozystack-migration61-test:ubuntu` build
stays where it is: only one test builds and uses it.

I chose this over `--no-parallelize-within-files` because it keeps these
files parallel and doesn't change the Makefile for every other bats
file.

### How I checked it

- I had no Docker daemon here, so I ran each file with a stub `docker`
on `PATH` that logs its calls and treats the tag as present once built:
- **On this branch:** one `docker build` per file (two for migration 61,
the second being the ubuntu image), with one `image inspect` per
`prep()` call.
  - **On main:** migration 54 ran four builds for its four tests.
- `bats --count` parses all six files.
- None of these files sources a `.sh` file, so they run only under real
bats (`bats-unit-tests`), not the `cozytest.sh` POSIX lane.
- Please rely on CI to run them against a real daemon.

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

These are repository-internal tests only.

### Release note

```release-note
NONE
```


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

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

## Summary by CodeRabbit

* **Tests**
* Improved migration test setup by building the required test image once
per test file and reusing it across tests.
* Preserved the existing Docker prerequisite checks and fallback
behavior.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 12:01:18 +03:00
Mattia Eleuteri 62dee1d132 fix(postgres): keep users.app's password across pod restarts
CNPG bootstraps an "app" owner role with a generated password stored in
<release>-app, and a declared users.app adopts that role. The init-job
then sets the role's password from <release>-credentials, but CNPG's
instance manager re-applies the owner's password from the bootstrap
secret whenever it meets a secret version it has not applied, which
includes every pod start. Any restart therefore reverts users.app to
CNPG's generated password, and clients holding the advertised one get
"password authentication failed" with nothing changed on their side.

Render the owner's bootstrap secret from the same password the
credentials Secret holds, and point the live bootstrap method at it, so
both writers agree on one value.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 11:56:33 +03:00
Mattia Eleuteri 3a5ae23797 feat(virtual-machine): group a VM's claims for Velero volume group snapshots
Velero snapshots the PVCs of an application-consistent VM backup one
after another between the guest freeze and thaw. Windows holds a VSS
freeze for 10 seconds at most, and on LINSTOR a VM with three volumes
(two disks and the persistent TPM/EFI state) outlasts it, so the thaw
fails and the backup is only crash-consistent. Velero 1.18 snapshots
the PVCs sharing a velero.io/volume-group value as one
VolumeGroupSnapshot.

Neither chart can carry that label onto the claims. CDI copies
DataVolume labels to a PVC only when it creates it, and a VMDisk
exists, PVC included, before any VM names it; KubeVirt creates the
persistent-state PVC with a fixed label set. A post-install and
post-upgrade hook of vm-instance labels them instead, and removes the
label from claims of this VM that no longer belong to the group.

Velero has no fallback for a labelled claim it cannot group: an unbound
member, a second CSI driver, or no single default
VolumeGroupSnapshotClass for the driver fails it. The group is formed
only when all of that holds and groupsnapshot v1beta2 is served, so
clusters without group snapshot support render nothing new.

The instancetype suite rendered every template, and the hook's PVC list
lookup needs a scheme it does not mock, so it is scoped to the two
templates it covers.

A vm-disk claim outlives the VM that grouped it, so a pre-delete hook
releases this VM's group on uninstall. Helm runs uninstall hooks from
the stored manifest, so that hook is rendered unconditionally and
selects the claims by this VM's label value when it runs.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 11:55:31 +03:00
Mattia Eleuteri 892d9c9b34 feat(platform): upgrade snapshot-controller to v8.7.0
snapshot-controller v8.0.1 serves VolumeGroupSnapshots only as
v1alpha1 and runs without the CSIVolumeGroupSnapshot gate, so no CSI
driver on the platform can take a crash-consistent snapshot of several
volumes at once. Velero 1.18 and piraeus-operator both look for
groupsnapshot.storage.k8s.io/v1beta2, which v8.7.0 serves and which the
upstream chart enables by default.

The upstream chart renders its CRDs as ordinary templates instead of
shipping them in crds/, and helm-controller takes over existing objects
by default. A patch makes the chart render a CRD only when it is absent
or already carries this release's ownership, so a distribution that
ships its own snapshot CRDs keeps them as they are. keepCRDs is set
because an uninstall would otherwise delete every VolumeSnapshot along
with the CRDs.

Migration 62 hands the CRDs this release installed over to it, read
from its helm-controller labels, and checks the HelmRelease rather than
those labels to decide whether the release exists, so a retry after a
failed create still recreates what the first attempt deleted. The
apiserver refuses to drop v1alpha1 from a CRD that lists it in
storedVersions, so the empty v1alpha1 group snapshot CRDs are deleted
and created again at v1beta2 from copies the image build renders out of
the chart. Every HelmRelease waits for the pre-upgrade hook, so linstor
renders against the v1beta2 API even when it upgrades first; the version
is stamped only once every release-owned v1beta2 group snapshot CRD is
Established, which a retry after a timed-out wait must check again. A
CRD that still holds v1alpha1 objects is kept, recorded on the
cozystack-version ConfigMap, and its warning spells out the manual
recovery, since nothing renders either release again once it is gone.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 08:08:49 +01:00
Aleksei Sviridkin f5479e7093 fix(qdrant): scrape TLS metrics over HTTPS (#5340)
## What this PR does

Qdrant with TLS enabled serves metrics over HTTPS, but its
ServiceMonitor still uses HTTP. Patch the rendered endpoint to use HTTPS
with the issued CA and a certificate SAN. The API key and explicit TLS
opt-out are preserved.

Validation: 3 regression tests and 110 Helm tests pass; both TLS cases
fail without the patch. The full Bats run has 183 failures on this macOS
host, all reproduced on unchanged main. The POSIX lane has 4 baseline
failures as well.

### 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(qdrant): restore metrics scraping for TLS-enabled instances by using HTTPS and verifying the server certificate against the issued CA.
```

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

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

## Summary by CodeRabbit

* **New Features**
* Qdrant monitoring now uses HTTPS when TLS is enabled, with certificate
verification and the configured server name.
* Monitoring connections use the release’s TLS certificate authority,
while non-TLS setups continue to use HTTP.
  * External Qdrant monitoring uses HTTPS by default.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 04:13:36 +03:00
Aleksei Sviridkin 0b53d53c01 Merge branch 'main' into fix/qdrant-monitoring-tls
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-23 02:58:03 +03:00
Andrey Kolkov 35634080f4 fix(backups): sign Kafka S3 requests without curl --aws-sigv4
The Kafka topic-metadata strategy and the topic-data demo strategy move
their artifacts to and from S3 with the curl of the Strimzi image they
run in, signed by curl --aws-sigv4. The Strimzi 1.3.1-1 images carry
curl 7.76.1-43.el9, whose RHEL backport of the S3 payload handling
(0044-curl-7.76.1-aws-sigv4-s3-unsigned-payload.patch) adds
x-amz-content-sha256 to the canonical headers and to SignedHeaders but
never sends the header. SeaweedFS rejects every signed request, so both
backup Jobs fail with

    curl: (22) The requested URL returned error: 403

The 7.76.1-40.el9 curl of the Strimzi 1.2 images has a different
defect, a signed Host without the non-default port it sends, which the
--connect-to workaround covered.

Sign the request in the script with openssl and sha256sum, both in the
Strimzi image, and leave curl only the transport. Sending the missing
header from the script would not do: for an upload the -43 build signs
UNSIGNED-PAYLOAD and the -40 build the empty-body hash, so no single
value satisfies both, and a curl that is fixed to send the header would
then send it twice. With the Host signed as curl sends it, the
--connect-to workaround goes too.

The bats suites hold the signature to the one botocore 1.35.99
S3SigV4Auth computes for the same request at a fixed time. Against
SeaweedFS 4.45 on a non-default port, the metadata script's backup,
restore and cleanup and the demo strategy's upload and download pass
in both quay.io/strimzi/kafka:1.2.0-kafka-4.3.1 and
1.3.1-1-kafka-4.3.1, a key with a space and non-ASCII bytes included,
and a wrong secret still gets 403.

Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-20 20:18:32 +07:00
Andrey Kolkov f4330867ea feat(dashboard): let a login link pick the Keycloak identity provider (#5286)
## What this PR does

A login link into the dashboard can now name the Keycloak identity
provider, so a user who comes from a portal brokered into Keycloak skips
the realm login page:

```
https://dashboard.<host>/oauth2/start?kc_idp_hint=<idp-alias>&rd=/admin/tenants
```

The motivating case is a billing portal registered in the realm as an
OIDC identity provider. Its "Open dashboard" button today lands every
client on "Sign in to <realm>", where they must pick the portal's
provider by hand on every new browser or session. Keycloak skips that
page when the auth request carries `kc_idp_hint`. The gatekeeper,
however, builds the request from a fixed `--login-url`, and
oauth2-proxy's flags forward only `acr_values`, `prompt` and
`approval_prompt` from `/oauth2/start`. Putting the hint into
`--login-url` would force every dashboard login, administrators
included, through that one provider.

oauth2-proxy can forward an allowed parameter through
`providers[].loginURLParameters`, but only in its alpha configuration.
The OIDC gatekeeper therefore now runs from one:

- `templates/gatekeeper-config.yaml` (new, OIDC only) holds the
provider, upstream, listen address and injected headers. The values are
exactly what `oauth2-proxy --convert-config-to-alpha` (v7.12.0) produces
for the previous flags, both the in-cluster Keycloak branch and the
external-discovery branch. On top of those, `kc_idp_hint` is allowed
when it matches `^[A-Za-z0-9._-]+$`. That rule and `clientSecretFile` in
place of the inline `clientSecret` are the only hand-written lines;
everything else, `scope`, `approval_prompt`, `insecureSkipNonce`,
`flushInterval` and `timeout` included, is the converter output
unchanged.
- `templates/gatekeeper.yaml` keeps the flags the alpha configuration
does not own (redirect URL, whitelist domain, email domain, API routes,
cookie options, `--skip-provider-button`, `--ssl-insecure-skip-verify`).
It mounts the config and the `dashboard-client` secret as files
(`clientSecretFile`). A checksum annotation restarts the pod when the
config changes.
- The token-proxy branch (OIDC disabled) is unchanged.

A login without the parameter behaves as before. oauth2-proxy logs a
warning on start that the alpha configuration format may change between
releases.

Tests:
- **Chart suite.** The gatekeeper suite loads the config template as
well, because the deployment checksums it. The "no branding volume" test
now asserts the branding volume is absent, not that the pod has no
volumes. The five tests that read Keycloak URLs from the container args
are removed: those values now sit in the alpha configuration. `helm
unittest .` passes, 23 tests.
- **E2E.** After the gatekeeper rolls out with OIDC enabled, the in-tree
install suite requests `/oauth2/start` through a port-forward and checks
the redirect: `kc_idp_hint=e2e-idp` reaches the `cozy` realm's auth URL,
and a value outside the allow pattern (`e2e%26prompt%3Dnone`) is
dropped. This covers the realm path and the allow rule that the removed
chart tests no longer pin.
- **Gatekeeper login (`hack/dashboard-gatekeeper-login.bats`).** Renders
the chart for a realm other than `cozy`, starts the auth-proxy image
with the rendered args and alpha config, and checks the `/oauth2/start`
redirect: on the in-cluster Keycloak branch the hint reaches that
realm's auth URL, a value outside the allow pattern is dropped, and a
login without it carries none; on the external-discovery branch the
gatekeeper discovers that realm from a local Keycloak stub and passes
the hint. The image is read from the render, so an oauth2-proxy bump
re-checks the alpha configuration. Needs docker, like
`hack/etcd-grpc-alerts.bats`.
- **Real oauth2-proxy v7.12.0 on the rendered config.** Ran with the
rendered args and checked:
  - `/ping` answers OK;
- `/oauth2/start?kc_idp_hint=whmcs` puts `kc_idp_hint=whmcs` into the
Keycloak auth URL;
- `/oauth2/start` without the parameter, or with a value outside the
pattern, does not;
  - a protected path redirects without it;
  - `/apis/*` stays 401;
  - `--ssl-insecure-skip-verify` starts fine alongside `--alpha-config`.
- **Live cluster.** Swapped in the rendered gatekeeper with the
HelmRelease suspended, then reverted:
- a brokered user who was already signed in at the portal went from the
hinted link straight to the dashboard;
  - a plain visit still showed the realm login page;
- a hinted visit without a portal session went straight to the portal's
own login;
- API calls from the console worked, so the `Authorization` header
injection is intact.

### Screenshots

N/A — no console UI changes. The change removes the Keycloak login page
from the hinted flow.

### 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 only the dashboard gatekeeper templates and their
tests. It adds no value, schema, package or platform component. I walked
the trigger map against it, and no entry matches.

### Release note

```release-note
feat(dashboard): a dashboard login link can name the Keycloak identity provider with `/oauth2/start?kc_idp_hint=<alias>`, so users coming from a brokered portal skip the realm login page. The OIDC gatekeeper now runs oauth2-proxy from an alpha configuration kept in a ConfigMap; logins without the parameter are unchanged.
```


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

## Summary by CodeRabbit

* **New Features**
* OIDC-enabled clusters now use updated dashboard sign-in settings,
forwarding identity and token information to the dashboard.
* Authentication requests use Keycloak’s internal URL when configured;
otherwise, logout uses the public Keycloak URL.
  * Sign-in requests include the OpenID, email, and profile scopes.
* Supported identity-provider hints are preserved in sign-in redirects,
while invalid hints are excluded.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-20 17:05:43 +07:00
Marian Koreniuk cfb5119c0b feat(build): attach a provenance attestation beside the SBOM (#5043)
## What this PR does

Follow-up to #4997 (merged as d32092ac9), rebased onto `main` at that
merge: one commit `57db352ed`. The second half of what was agreed there:
beside the SBOM, each release image gets a SLSA provenance statement
from BuildKit, in the same attestation manifest.

Refs #4759, #3278

`SBOM=1` in `hack/common-envs.mk` now passes `--attest
type=provenance,mode=min` with the SBOM attest, in place of
`--provenance=false`; a build without `SBOM=1` keeps
`--provenance=false` as before. BuildKit writes both predicates into the
one attestation manifest per platform, so the index shape
`hack/stitch-multiarch.sh` and `hack/verify-multiarch.sh` read after
#4997 is unchanged, and a signature over the index covers the provenance
as it covers the SBOM. `mode=min` records the build times, the build
platform, the frontend and the BuildKit version and leaves out the build
arguments and the secrets, which `mode=max` would write in, so it can
ride every release image. `docker buildx imagetools inspect
<image>@<digest> --format '{{ json .Provenance }}'` prints it;
`docs/release.md` says so.

### How it was checked

- `hack/common-envs_test.bats`: the `SBOM=1` test now also holds that
`--attest type=provenance,mode=min` is passed, that `--provenance=false`
is not, that neither `mode=max` nor `--provenance=true` appears, and
that the default build still passes `--provenance=false` and no
`--attest`. `make -n` of `packages/system/cozystack-controller` shows
exactly that in both modes. `hack/stitch-multiarch_test.bats` is green:
the attestation manifest count per platform does not change.
- A real build, by @myasnikovdaniil on a local registry: amd64 and arm64
built with the flags from `common-envs.mk`, stitched,
`verify-multiarch.sh` passes, the index has four manifests (two images,
two attestation manifests with SBOM and provenance each), `.Provenance`
reads for both platforms, and a `--build-arg` value is in `mode=max` and
not in `mode=min`.
- Rebased on `main` at d32092ac9: `hack/common-envs_test.bats` and
`hack/stitch-multiarch_test.bats` 34/34.
- Not checked: the provenance predicate on a release runner. The first
alpha after the merge shows it.

### Decisions for the release owners

- `mode=min` rather than `mode=max`: the Dockerfiles take `--build-arg`
values a reader of a public attestation should not see by default. If a
package's arguments are all public, `max` is one word away.
- `docs/security/self-assessment.md` still says build provenance is
disabled (`--provenance=false`). It stays until the first alpha shows
provenance on a release image, as #4997 holds its SBOM row.
- PR, main and nightly builds stay without provenance, as they stay
without an SBOM: nothing reads it there, and the default docker driver
cannot attach it.

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

- [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:

I walked the trigger map against the diff. `hack/common-envs.mk` changes
the flags one variable expands to and no target, variable name or file
that ccp's skills anchor on; nothing else is touched.

### Release note

```release-note
feat(build): every release image built with `SBOM=1` also carries a SLSA provenance statement (BuildKit `mode=min`: build times, platform, frontend and BuildKit version, no build arguments or secrets) in the same attestation manifest as its SBOM, readable with `docker buildx imagetools inspect <image>@<digest> --format '{{ json .Provenance }}'`.
```



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

## Summary by CodeRabbit

* **New Features**
* Container builds with SBOM generation enabled now include both an SPDX
software bill of materials and a minimal SLSA provenance attestation.
  * Provenance attestations remain disabled when SBOM generation is off.

* **Documentation**
* Updated the container image security guide with details on provenance
contents and how to inspect the attestation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-20 10:32:33 +01:00
Andrey Kolkov 421dc2a0a7 test(dashboard): require the exact hint in the e2e redirect check
The case pattern *kc_idp_hint=e2e-idp* also accepted e2e-idp-other
and xkc_idp_hint=e2e-idp. Match the parameter as a whole: preceded by
&, followed by & or the end of the URL.

Assisted-By: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-19 20:44:54 +07:00
Adham Kiwan 589c895d59 test(migrations): build each migration test image once per file
Every test in the migration 54, 55, 57, 58, 59 and 61 bats files called
prep(), and prep() ran `docker build -t` for one fixed tag. Tests in a
file run concurrently under bats -j, so on a cold cache several builds
of that tag ran at once. With the containerd image store a retag to a
different image deletes the old one before creating the new one, and a
sibling's `docker run` that resolved the tag in between found nothing
locally and fell back to a pull of an image that does not exist.

Build the image in setup_file, before any test of the file starts.
prep() keeps a fallback build for a run without setup_file, taken only
when the tag is missing.

Closes: #5299
Assisted-by: LLM
Signed-off-by: Adham Kiwan <adhamkiwan@outlook.com>
2026-11-19 15:16:30 +02:00
Adham Kiwan ffb3b6faf3 test(hack): check hook scripts under files/ for --request-timeout
The guard against a non-zero --request-timeout on in-cluster kubectl
calls only read chart templates. A chart that loads its hook script with
.Files.Get runs it with the same in-cluster credentials, so a flag in
packages/*/*/files/ went through unchecked; a review, not the guard,
caught it in #4915. It also matched only the --request-timeout=<value>
form, while kubectl accepts --request-timeout <value> as well.

Scan shell scripts under files/ too, recognised by a .sh suffix or a
sh/bash shebang, through env or env -S included, and match the
space-separated form and quoted values when a non-zero number follows,
so prose about the flag in comments stays quiet. The new cases run the
scan on a throwaway tree.

Closes: #5304
Assisted-by: LLM
Signed-off-by: Adham Kiwan <adhamkiwan@outlook.com>
2026-11-19 15:12:48 +02:00
Aleksei Sviridkin 0887b43793 Merge branch 'main' into feat/capi-v1.13
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-18 15:21:54 +03:00
Aleksei Sviridkin 191e2f45fa fix(capi-providers-core): stage unfinished kubeadm installations
A kubeadm installation can finish at its old requested version while
core moves to the intermediate release. Ignoring its initial empty
installedVersion leaves the final bootstrap chart outside its supported
upgrade window.

Fixes: 4d251f4122 ("fix(capi-providers-core): let a never-installed provider take the fresh path")
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-18 15:01:21 +03:00
Aleksei Sviridkin d88322197f chore(deps): roll up Renovate updates and raise dependencies to latest stable (#4869)
## What this PR does

One PR instead of separate Renovate PRs. Go modules, Dockerfile base
images and GitHub Actions move to newer versions that build and pass the
tests. Where a newer version is known to break something, it stays
behind, and `.github/renovate.json` holds it with the reason in the rule
description.

The tests come first, in their own commits:

- `make go-unit-tests` runs the Go tests under `pkg/` and `cmd/`, except
the backport-batch suite, which keeps its own target. The apiserver
serializer and fuzz tests, the generated OpenAPI and applyconfiguration
suites, the apis packages and the controller, operator and
observability-proxy commands did not run in CI before.
- The apps API surface that apiserver libraries shape is pinned:
server-side apply, content negotiation, Table output on watch, the
served OpenAPI v2 and v3 documents, and building the server without
etcd. Two answers look wrong and are pinned as they are today: applies
from different field managers never conflict (#4857), and protobuf is
refused with 406 even when the client offers JSON as a fallback (#5297).
- New tests cover the kubeovn webhook patch, the token proxy session
cookie and the mount-utils behaviour the kubevirt CSI node service
relies on.
- `hack/image-smoke.bats` checks the tools the CSI, LINSTOR, multus,
Harbor and redis-backup images take from their base images or build
stages, and that the kubevirt CSI node plugin and its sidecars need no
more than x86-64-v2. Each PR build job runs it against the images it
pushed; forks and the unit lane run no container.

The tests found two bugs:

- The kubeovn webhook dereferenced a nil pointer on an admission review
without a request, so the caller got a dropped connection instead of a
400.
- The token proxy cookie refresh never fired: securecookie decodes the
session times as int64 and the refresh looked for float64, so the
`--cookie-refresh=1h` the chart sets did nothing. A refreshed cookie
keeps the token's expiry. A session too large to encode now shows an
error at sign-in and leaves the current cookie alone on refresh.

What moved:

- GitHub Actions to their Node 24 majors. The flux action stays on the
tag of the Flux CLI it installs. The release job's checkout no longer
persists credentials, so its staging branch push uses the App token.
- Go 1.27.2 for the toolchain and builders. Builds that reproduce an
upstream release keep the Go upstream uses: Harbor, cilium-operator,
SeaweedFS and the chainsaw stage of the e2e sandbox.
- controller-runtime v0.25.2, gateway-api v1.6.3 on the minor of the
installed v1.6.1 CRDs, cel-go v0.30.0, grpc v1.84.0, etcd v3.7.2,
cert-manager v1.21.2, kubevirt csi-driver f10ae94 on Kubernetes v0.37.1.
- Node 24 for the dashboard console.

Held back, each with its reason in the Renovate rule:

- cel-go stays below v0.31: the old repository has no tags past v0.30.0,
and v0.32 moves to cel.dev/cel-go, which k8s.io/apiserver does not
import.
- kube-openapi stays on the commit its dependencies require, and
structured-merge-diff stays on v6, because k8s.io/apimachinery v0.37
does not compile against v7.
- The Flux API modules stay on the Flux v2.8 line the platform installs.
- gomodules.xyz/jsonpatch stays on v2, which controller-runtime's
admission.Patched takes.
- jwx stays on v3: v4 removes jwk.Cache, which the token proxy's JWKS
refresh is built on.
- kubevirt.io/api and the CDI API stay where upstream csi-driver builds.
- The kubevirt CSI driver image stays on AlmaLinux 9, because AlmaLinux
10 builds its amd64 userland for x86-64-v3.
- shadowbox stays on node 18, which outline-server declares in its
engines.
- The e2e sandbox stays on Ubuntu 24.04. 26.04 ships uutils coreutils,
whose `date` costs about 4x per call, and the test harness forks it per
traced line, which adds about ten minutes to the install phase.
- clastix/kubectl stays on v1.32 for the cleanup hooks, within kubectl's
one-minor skew.

The cert-manager Go module (v1.21.2) is one minor ahead of the installed
chart (v1.20.2). The Certificate objects the gateway controller writes
serialize the same either way.

`api/apps/v1alpha1` now requires Go 1.27.2, which applies to every
module that imports the published types.

The Linux run with Go 1.27.2 was done before the rebase onto current
main, and the rebased head has not been through it yet. There the five
modules built, vetted, tested and tidied cleanly, and the repository
unit, controller and envtest lane passed. `go test -race` passed in four
modules. In the root module it failed only on a pre-existing data race
in the workload monitor tests (#5296), which main has too. The image
smoke checks run in this PR's CI.

### Screenshots

No UI change.

### Downstream repositories

`api/apps/v1alpha1` moves to `go 1.27.2`, and
cozystack/terraform-provider-cozystack imports it, so that repository is
affected but needs no action. Its box stays empty for that reason, and
so does the "not affected" one.

- [ ] 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: none needed, because its Renovate raises the go directive
together with the pin bump and its CI takes Go from `go.mod`; the only
effect is that the provider's minimum Go becomes 1.27.2.
- [ ]
[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
chore(deps): move the toolchain and builder images to Go 1.27.2 and raise Go modules, base images and GitHub Actions to newer working releases; the dashboard token proxy now refreshes its session cookie, and the kube-ovn webhook rejects an admission review without a request instead of dropping the connection.
```
2026-11-18 14:42:34 +03:00
Aleksei Sviridkin a3e60ec372 feat(kafka)!: run on Strimzi 1.2.0 and Kafka 4.x (#4900)
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Types: feat, fix, security (a fix that comes through a security
advisory), docs, style, refactor, perf, test, build, ci, chore
- Scopes are not an exhaustive list — pick the most specific scope for
the change and extend the list when a genuinely new area appears.
Examples:
- System components: dashboard, platform, operator, cilium, kube-ovn,
linstor, fluxcd, cluster-api
- Managed apps: postgres, mariadb, redis, kafka, clickhouse,
virtual-machine, kubernetes
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or
add a `BREAKING CHANGE:` footer
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Fixes merged to `main` reach the release lines the backport batch runs
for automatically, so do not open backport PRs by hand:
https://github.com/cozystack/cozystack/blob/main/docs/release/backports.md
-->

## What this PR does

This upgrades the Kafka operator to Strimzi 1.2.0. Kafka 4.3 is the
application default, with 4.2 also available. Upgrades must pass through
Cozystack v1.7 and finish the ZooKeeper-to-KRaft migration first.

The upgrade now stops while any Kafka lacks KRaft evidence. Every Kafka
must report a nonempty `kafkaMetadataVersion` and the `KRaft` metadata
state. The API conversion deletes that state, so without it a Kafka
needs `Ready=True` or the `cozystack.io/kraft-verified` annotation,
which migration 61 writes on every Kafka it accepts before it stops the
operators. Any other explicit state blocks, and the error gives the
reason for each Kafka. On every variant, the platform chart refuses to
switch package sources while Strimzi still serves `v1beta2` and a Kafka
fails that check. On variants without the migration hook, it also
refuses while any Strimzi CRD still stores `v1beta2`, so
`/migrations/61` has to run first. Migration 61 checks the same evidence
again, including on repeat runs, and blocks unfinished broker-pool
drains. A manual change that bypasses the managed package source is
outside this check.

Existing Kafka 3.x applications move to v4.3. Kafka 4 no longer accepts
clients older than Kafka 2.1. Kafka 4 also rejects the topic settings
`message.format.version`, `message.downconversion.enable` and
`message.timestamp.difference.max.ms`, and a `segment.bytes` below 1 MiB
(1048576), which Kafka 3.x accepted down to 14 bytes. A Kafka 4 broker
whose log holds such a topic does not start. The chart now refuses to
render a topic that sets any of these. The platform upgrade refuses to
start while a Kafka application sets one, and migration 61 also checks
KafkaTopic resources, so topics created outside the chart are caught
too. A topic created through the Kafka admin API without a KafkaTopic is
not visible to these checks. Restoring a topic-metadata backup taken on
Kafka 3.x skips the three removed settings and raises a smaller
`segment.bytes` to 1 MiB, with a warning for each. In-place downgrades
are unsupported. The default 10-minute Helm timeout can leave a long
broker roll Failed until its retry succeeds.

The migration does not run automatically on every platform variant. Only
the `isp-*` variants run it automatically. On other variants, run
`/migrations/61` from the matching migrations image before upgrading, as
the Kafka README describes. This includes clusters that run no Kafka but
have the kafka-operator package, from the `paas` bundle or
`bundles.enabledPackages`. Their Strimzi CRDs still store `v1beta2` even
with no objects. The migration converts Strimzi resources and stored
Helm references to `v1`. It stamps platform version 62. Running it
manually also skips earlier migrations on a later move to an `isp-*`
variant. Before it stops the operators, migration 61 refuses objects
that the Strimzi 0.51 conversion tool would reject and names each one,
for example a Kafka with `.spec.kafka.resources` or with OAuth, Keycloak
or OPA settings. A failed conversion can leave the old operators stopped
until the migration succeeds and the operator release upgrades. The
failed conversion Job stays for diagnosis, but its ClusterRole, binding
and ServiceAccount are removed. A Job that is still running when the
wait times out keeps them, because the retry waits for it.

Known limitations. Migration 61 converts with the old operator stopped,
while Strimzi's conversion guide expects a running operator of 0.49 or
later. I stop it because 0.45 keeps writing the Kafka status through
`v1beta2`, but I have not checked this on a live cluster. Objects
Strimzi created keep `ownerReferences` to `v1beta2` until Strimzi 1.2
reconciles them. Deleting a Kafka before that can leave dependents
behind, and the chart's pre-delete hook covers only StrimziPodSets. The
conversion image is pulled from quay.io by digest with no values
override, so an air-gapped cluster has to mirror it under the same name.

The full offline unit run passed on Linux on
`1171d63adfafb45be34214fb9a0f565723e255fd`: 2,576 cases, no failures,
errors or skipped tests. Later changes were checked on `69c704499fa4`
with the Bats tests for migration 61, the migration runner, the Kafka
hooks and the Kafka backup scripts (102), the platform Helm suite (310
tests) and the Kafka Helm suite (91 tests). After the rebase onto `main`
at `5a5d5cd3d85f`, `a48a2f259947` passes the same Bats tests (115) and
the platform and Kafka Helm suites (326 and 103 tests). It also passes
the new check against added `documentIndex` selectors. I have not
validated this revision on a live cluster.

Closes #4365

### Screenshots

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

Not a UI change.

### Downstream repositories

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

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

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

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

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

The Terraform provider does not model the Kafka `version` field. The
website issue covers the upgrade notes the `default` variant needs.

### Release note

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

```release-note
feat(kafka)!: upgrade to Strimzi 1.2.0 and Kafka 4.3 by default, with Kafka 4.2 also available. Platform migration 61 converts Strimzi resources to v1 and moves Kafka 3.x applications to v4.3. Every Kafka must have confirmed KRaft state before the upgrade, including on repeat runs. Upgrade through Cozystack v1.7 first. Kafka 4 drops clients older than Kafka 2.1 and the message.format.version, message.downconversion.enable and message.timestamp.difference.max.ms topic settings, and requires segment.bytes of at least 1 MiB; the chart and the upgrade refuse a topic that breaks either rule, and a topic-metadata backup taken on Kafka 3.x restores without the removed settings and with segment.bytes raised to 1 MiB. In-place downgrades are unsupported.
```
2026-11-18 13:26:31 +03:00
Aleksei Sviridkin 5a92f1fc4e Merge branch 'main' into feat/build-provenance-attestation
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-18 11:55:28 +03:00
Aleksei Sviridkin 045f1a9bbc fix(seaweedfs): remove identities left behind by deleted BucketAccesses
Since SeaweedFS 4.08 the S3 gateways move every identity from
/etc/iam/identity.json into /etc/iam/identities/<name>.json, and the
COSI driver up to v0.3.1 revokes only from identity.json. Every
BucketAccess deleted on such a filer left its identity file behind,
with its keys still accepted (seaweedfs/seaweedfs-cosi-driver#11). A
driver that deletes the file on revoke does nothing for the files
already left.

A post-install/post-upgrade hook removes a ba-<uid>.json file when no
BucketAccess in any namespace names it, by uid or by
status.accountID. The uid covers a BucketAccess still being granted,
the accountID one restored with its status. The identity directory is
listed before the BucketAccesses: a BucketAccess exists before its
grant writes a file, so a file seen in the first listing whose
BucketAccess still exists is always named by the second. File ages are
not used, because grants and gateway migrations rewrite left-over
files as well. A failed or empty listing removes nothing. Each removal
is logged and recorded as an Event on the HelmRelease. The hook runs
before the Object Lock hook, so in delete mode a left-over identity is
removed before that hook grants it anything.

A filer published for Client-topology clusters holds identities whose
BucketAccesses live in those clusters, so cosi.orphanIdentities
defaults to auto: report there, delete otherwise. An operator can
force either.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 22:07:25 +03:00
Aleksei Sviridkin c49f58c4a4 fix(seaweedfs): keep Object Lock working for COSI credentials on SeaweedFS 4.48 (#4893)
## What this PR does

Existing bucket credentials need additional Object Lock actions to work
with SeaweedFS 4.48. Since v0.4.0 (#5284), the upstream COSI driver
grants them to new credentials. It does not grant access again for a
ready BucketAccess, so older identities stay unchanged after the driver
update. The custom COSI driver build and its image repository are no
longer part of this PR.

This PR adds a post-install and post-upgrade hook that grants the
actions implied by each identity's Read and Write permissions. Bucket
restrictions and credentials stay unchanged, and Write does not grant
governance bypass. The `anonymous` identity that public-read buckets
share is skipped on purpose. The driver revokes public read by removing
only `Read:<bucket>`, so added Object Lock reads would stay open to
unsigned requests. The hook runs after the release update and does not
guarantee Object Lock access during a server rollout.

The wrapper chart also declares its local dependency so Helm lint can
check it. The chart remains on 4.45. #4879 is stacked on this PR for the
4.48 upgrade.

The hook's bats suite (22 cases), the chart tests and shellcheck pass
locally on 65708a81b8. The Linux unit lane and E2E are pending. Live
cluster validation has not been run.

Known hook limitations remain tracked in #4894. A pod that never starts
can still fail the Helm action. Deletion between the dry run and apply
can leave a keyless identity. Warning Events expire, and the Job stays
behind for its logs.

### 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(seaweedfs): grant existing bucket credentials the Object Lock actions required by SeaweedFS 4.48 on install and upgrade, preserving their bucket restrictions and credentials.
```
2026-11-17 18:05:41 +03:00
Aleksei Sviridkin a48a2f2599 fix(backups): restore Kafka 3.x topic configs that Kafka 4 rejects
Every Kafka now runs 4.x, and a topic-metadata backup taken on Kafka
3.8 or 3.9 can record message.format.version,
message.downconversion.enable or message.timestamp.difference.max.ms,
which Kafka 4 removed, or a segment.bytes below 1 MiB, the minimum
Kafka 4 raised it to from 14 bytes. A 4.x broker rejects each of them,
so the restore stopped at the first one, leaving that topic
half-configured and every later topic unrestored, and a rerun failed
on the same line.

The restore now skips the removed keys and raises a smaller
segment.bytes to the minimum, each with a warning, and applies the
rest. segment.bytes is read the way Kafka reads it: trimmed, with an
optional sign, leading zeros decimal.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 12:22:56 +03:00
Aleksei Sviridkin f293d64e84 fix(kafka): delete the release's StrimziPodSets on uninstall
On a cluster upgraded from Strimzi 0.x, deleting a Kafka application
leaves its brokers running. kube-controller-manager's garbage collector
first saw the StrimziPodSets under v1beta2 and never updates that
record, so once v1beta2 is no longer served it retries them forever
instead of deleting them, until kube-controller-manager restarts
(kubernetes/kubernetes#102641).

The pre-delete hook now deletes the release's StrimziPodSets after its
node pools, so uninstall no longer depends on garbage collection for
the brokers. An absent CRD is not a failure; any other error fails the
hook like the pool delete does, because Helm never runs it for the
release again.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 12:22:55 +03:00
Aleksei Sviridkin 3b65cebea3 feat(kafka)!: run on the Strimzi v1 API and Kafka 4.x
Strimzi 1.2 serves only the v1 API and runs Kafka 4.2 and 4.3. The
node-pool hook no longer drives the ZooKeeper to KRaft migration or
the drain that freed the shared "kafka" pool name: Strimzi 1.x has no
ZooKeeper support, and the platform migration refuses to upgrade while
a ZooKeeper cluster is left. A cluster migrated earlier keeps its
"kafka" broker pool. Without the drain the hook takes seconds, so the
seven-hour install timeout goes too.

Kafka 4 rejects the topic configs it removed and a segment.bytes below
1 MiB, which Kafka 3.x accepted. A KafkaTopic that sets one stays
NotReady while the release reports Ready, so the chart refuses to
render such a topic. It reads segment.bytes the way Kafka does:
trimmed, with an optional sign, leading zeros decimal.

BREAKING CHANGE: the Kafka application accepts version v4.3 (default)
and v4.2; v3.8 and v3.9 are gone, and the platform migration moves
existing applications to v4.3.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 12:22:54 +03:00
Aleksei Sviridkin af0db99c71 feat(platform): move Strimzi resources to the v1 API before Strimzi 1.x
Strimzi 1.0 removed v1beta2 from its CRDs, and the API server refuses
a CRD that drops a version its status still lists as stored. Every
stored object has to be rewritten as v1 before the new operator
arrives, which needs the CRDs of Strimzi 0.49 to 0.51 that serve both
versions and Strimzi's own conversion tool. The 0.45 operator is
stopped first: Strimzi supports the conversion only under an operator
that knows v1, and 0.45 keeps rewriting the Kafka status through
v1beta2. The conversion Job's ClusterRole can patch CRDs and write
ConfigMaps in every namespace, so it goes with its binding and
ServiceAccount once the Job has finished, successfully or not; a
failed Job stays for diagnosis, and a Job still running when the wait
times out keeps them, because the retry waits for that Job.

Two references to v1beta2 outlive the stored objects. Helm builds the
objects of a release before it upgrades or uninstalls it, so every
stored revision of every Kafka application is rewritten to v1. And the
API server refuses server-side apply to an object whose managedFields
still name a version the CRD no longer serves; when helm-controller
recovers by wiping them, a field a later chart drops is never removed.
Those entries move to v1 as well. A Helm action already running stores
the releases it read when it finishes, v1beta2 included, so the version
is not stamped while any Kafka release revision is still pending.

Strimzi 1.x also runs neither ZooKeeper nor Kafka 3.x. A ZooKeeper
cluster, or a shared broker pool still being drained, left by a
platform that moved past v1.7 before its ZooKeeper to KRaft migration
finished cannot be finished afterwards, so the migration stops
instead; Kafka applications on v3.8 or v3.9 move to v4.3. The
migration also stops, before it changes anything, while a Kafka
application topic or a KafkaTopic sets a config Kafka 4 removed or a
segment.bytes below the 1 MiB minimum of Kafka 4: the new kafka chart
refuses to render such a topic, and a Kafka 4 broker whose log holds
the small segment.bytes does not start. segment.bytes is read the way
Kafka reads it: trimmed, with an optional sign, leading zeros decimal.

Strimzi's conversion tool refuses some v1beta2 objects outright, and
convert-resource stops at the first one, with the operators already
stopped. While v1beta2 is served the migration lists every Strimzi
kind first and refuses, naming each object and the reason, before it
stops anything. The list follows the 0.51.0 tool the conversion Job
runs, and a test fails when that image changes.

The conversion deletes the Kafka's KRaft metadata state, and KRaft is
the state Strimzi never leaves. Before it stops the operators, the
migration records an annotation on every Kafka it accepts, so a retry
after the conversion still accepts a NotReady Kafka that passed on
its KRaft state.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 12:02:45 +03:00
Aleksei Sviridkin 76d68a919f test(e2e): pin the importer restarts an unreachable VMDisk reports
The kubernetes-nodes guard and the image option list call an import
failing once its importer has restarted three times and is not running,
and the vm-disk guard once it has restarted three times, because CDI
keeps an unreachable URL in progress instead of moving it to Failed.
Assert that CDI reports both on the DataVolume of the unreachable
VMDisk, so a CDI change that stops doing so turns this suite red rather
than leaving the guards blind.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 11:20:21 +03:00
Aleksei Sviridkin b6ef231d44 docs(kubernetes-nodes): state why a pool must share its golden's class
The worker image guard, its error message and the storageClass docs
said CDI cannot clone across StorageClasses and always falls back to a
host-assisted copy. CDI falls back only when the two claims have
different CSI drivers or volume modes; with one driver it asks that
driver for a clone into the other class. The guard stays, the reason it
gives is corrected, and the docs name the virtualization default class
an empty storageClass now resolves to.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 11:20:20 +03:00
Yan Bondarenko d009a1e737 fix(qdrant): scrape TLS metrics over HTTPS
TLS-enabled Qdrant rejects the ServiceMonitor's HTTP requests. The
vendored chart exposes no scheme or CA value, so patch its endpoint
through the existing HelmRelease post-renderer mechanism. Trust the
issued CA and use a certificate SAN without disabling verification.

Tested the app-to-system chart render through Kustomize for explicit
TLS, external default TLS and explicit opt-out; the TLS cases fail
without the patch.

Fixes: cdb03a9929 ("feat(qdrant): implement TLS in Helm templates")
Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
2026-11-17 01:22:04 +01:00
Aleksei Sviridkin 0d239fab81 Merge branch 'main' into feat/kubernetes-nodes-talos-sysctls
The generated cozyrds file is regenerated from the merged values.yaml.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 17:17:33 +03:00
Aleksei Sviridkin 2d1d98364d fix(platform): ship cozy-lib with the capi-providers-core artifact
The upgrade hook image is rendered through cozy-lib.image, and the
chart links cozy-lib through charts/cozy-lib. The chart reaches the
cluster as the artifact the operator assembles from the PackageSource,
which copies a library into <chart>/charts/ only when the variant
declares it and the component lists it. capi-provider-core declared
neither, so the artifact carried a dangling symlink and the install
failed with 'no template "cozy-lib.image"'. Rendering from the git
tree resolves the symlink, which is why the chart tests stayed green.

Declare cozy-lib on the variant and on the capi-providers-core
component, as bucket-application does, and pin both in the chart
tests.

Fixes: a709ca1bdb ("fix(capi-providers-core): pull the upgrade hook image through cozy-lib")

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 16:24:25 +03:00
Aleksei Sviridkin e634fd75ed fix(capi-providers-core): repair a bridge selector with extra expressions
The repair check compared only matchLabels, so a bridge selector with
the right label plus matchExpressions was left alone, although the
bridge ConfigMaps carry nothing those expressions could match and the
selector then finds no repository. The check now compares the whole
selector, the same shape the repair patch writes.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 14:03:54 +03:00
Aleksei Sviridkin a52e8dac30 fix(capi-providers-core): name the version the upgrade hook rejects
The hook reported every malformed version as an installed one, also
when the bad value was the requested spec.version or the bridge or
target release from the chart, which sent an operator to look at the
wrong field. The message now says which version it checked.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 14:03:07 +03:00
Aleksei Sviridkin a6a82515f7 test(capi-operator): describe why the resync period is still pinned
The header said the resync period bounds how long a stale Ready lasts
after an operator restart. That was the v0.19 restart bug, which the
operator shipped now already fixes; the period is pinned only until
restart recovery on the new operator is measured.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 13:52:40 +03:00