Commit Graph
3224 Commits
Author SHA1 Message Date
Aleksei Sviridkin c8ffc87717 fix(postgres): run the collation repair outside the Helm hook (#5479)
## What this PR does

Refs #5459 (item 3: "Waiting for rollout eats Job budget").

**Depends on #5505.** Merge #5505 first or together with this PR. Here a
failed repair no longer fails the HelmRelease. #5505 makes the
WorkloadMonitor report the failed repair Job as `WorkloadsReady=False`
with reason `JobFailed`. Without it the failure shows only on the Job
itself.

Moving tenant PostgreSQL to another image (for example bullseye `17.7`
to `17.12-standard-trixie`) fails the first Helm upgrade of every
release whose clients keep sessions open. The collation repair at the
end of the post-upgrade init-job waits for CNPG to move the primary to
the new image. CNPG rolls the primary last, and every instance spends up
to `smartShutdownTimeout` (180 s) in smart shutdown, so the wait uses up
the init-job's 540 s deadline and the HelmRelease goes `UpgradeFailed`
until Flux retries. When the repair instead meets the primary restart,
psql fails with `FATAL: the database system is shutting down` and the
upgrade fails the same way.

The one commit moves the repair out of the hook. A short
post-install/post-upgrade hook, run after the init-job, creates a
`<release>-collation-repair` Job through the API (outside the release,
so helm-controller does not wait for it) and returns. That Job keeps the
OID mark / fingerprint resume and the in-place attempt records. It waits
for the new image whenever the image changes, not only when an index
already depends on a versioned collation: a plan built on the previous
primary would miss an index created meanwhile, which the release
recorded at the end would then claim as repaired. In the hook that wait
was too expensive to make unconditional. The Job gets an hour, is owned
by the Cluster, and its fixed name keeps two repairs from running at
once. It carries the WorkloadMonitor's selector labels plus the opt-in
`workloads.cozystack.io/report-failure: "true"` from #5505, and has no
`ttlSecondsAfterFinished`, so a failed repair stays until the next
upgrade replaces it (see the proposal in #5459). Both Jobs now rerun
their idempotent script on psql exit status 2 (connection refused or
dropped) with backoff instead of failing.

Decisions for reviewers:

- **Repair failures no longer fail the HelmRelease.** A repair that
cannot finish (for example duplicates under a UNIQUE index) shows up as
a Failed `<release>-collation-repair` Job and its log, kept until the
next upgrade starts a new run. The next upgrade retries it. Before, it
showed up as `UpgradeFailed`.
- **The repair also runs after install.** The install-time init-job used
to record which Debian release each database starts on. Without that
record, a cluster whose first upgrade moves the image would have its C.*
indexes rebuilt only if the repair reached the primary before it
restarted. On a fresh cluster the run only writes that record. The Job
sets `PGCONNECT_TIMEOUT=10`.
- **A failed rebuild no longer holds back the PostGIS update.** The
update runs after the collation pass whatever it found, and the Job
still fails at the end if a rebuild failed.
- **The e2e upgrades twice.** The second upgrade finds the first repair
Job complete on the same image, and the test waits for its replacement
to complete.
- **Lock waits are bounded by the Job's remaining hour, not about 8
minutes.** This is harmless for `REINDEX CONCURRENTLY`. For the in-place
rebuild of an exclusion-constraint index, writers to that table can
queue behind its lock wait for longer. Capping it separately means
touching the per-index code that the parallel PRs on #5459 also edit, so
I left it out.
- **The hook's Role** has `get`/`delete` on the repair Job and `get` on
the release's Cluster, both by `resourceNames`. It also has `create` on
jobs, which RBAC cannot narrow by name. The SA, Role and RoleBinding are
deleted once the hooks succeed.
- **Verified under Flux.** helm-controller v1.5.0 runs the post-upgrade
hooks about a second after it patches the Cluster, without waiting for
the rollout. The rollout therefore no longer counts against the release
timeout. Details in the PR thread.

Rebased onto main after #5477 and #5485. The PostGIS extension update
from #5477 waits for the same rollout, so it moves into `repair.sh`
after the collation pass; left in the init-job, it would bring the
hook-budget problem back for postgis clusters. Every message about a
repair or update that did not finish says that the next upgrade of the
release starts it again. The starter and the repair Job take their names
from one base, which stays distinct and within 63 characters for any
release name.

### Testing

- `helm unittest packages/apps/postgres`: 32 suites, 257 tests pass,
including a new `collation_repair_test.yaml`. It checks gating (upgrade
only, skipped while bootstrap is on), hook order after the init-job, the
Role rules, RBAC removal on success, name length, and the init-job
command.
- Docker, with the rendered `run.sh` + `repair.sh` against
`postgres:17-bullseye` and stale ICU / en_US collations:
- Killing the `REINDEX INDEX CONCURRENTLY` backend mid-rebuild made the
pass exit 2. `run.sh` reran it, the already rebuilt index was skipped by
the OID mark, and the other index was rebuilt. amcheck was clean and the
versions were refreshed.
- With the server stopped before the first connection, the script
retried with 5 s and 10 s pauses and finished once the server came back.
  - An SQL error exits 1 and is not retried.
- dev7 (cozystack v1.7.0): two 3-instance v17 releases installed from
v1.7.1 (bullseye `17.7`), with ICU and en_US UNIQUE indexes on 200k rows
and `pg_sleep(3600)` sessions held on `-rw` and `-ro`. Both were
upgraded with `helm upgrade --timeout 10m`:
- origin/main: the init-job waited for `PostgreSQL 17.12 pgdg13`, hit
`DeadlineExceeded`, and the command failed with `UPGRADE FAILED:
post-upgrade hooks failed: resource Job/tenant-root/rr-main-init-job not
ready. status: Failed` (exit 1 after 611 s).
- This branch: exit 0 after 70 s (init-job 9 s, starter 10 s, starter
RBAC removed afterwards). The repair Job waited out the rollout and
rebuilt `t_u` and `t_k`. Collation versions were refreshed to `2.41` /
`153.128`, `bt_index_check(..., true)` passed on all three instances,
and the resume mark was reset.
- A second upgrade replaced the finished repair Job, and the rerun found
nothing to do.
- The rebuild sat in `waiting for old snapshots` behind the test
client's open transaction. That is expected for `REINDEX CONCURRENTLY`;
I ended that session to finish the run.

### Downstream repositories

Walked against the diff (the new template, test and init-script/init-job
changes in `packages/apps/postgres`). The diff changes no values,
schema, `ApplicationDefinition`, Secret or Service names, package
layout, or tooling. The only new objects are a hook-scoped
ServiceAccount/Role/RoleBinding/Job and a Job created at runtime, which
no listed repository refers to.

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

- Flux (dev cluster, helm-controller v1.5.0): a tenant app on the v1.7.0
chart (bullseye `17.7`, 3 instances, sessions held on `-rw`/`-ro`) was
upgraded by switching the platform's postgres chart.
- With this PR, the HelmRelease reached `UpgradeSucceeded` in 21 s, and
the repair Job finished after the rollout with `bt_index_check` clean on
all instances.
  - With main, the upgrade took 7 min 06 s of the 10-minute timeout.
- Docker: the rendered `repair.sh` for the postgis flavor moved PostGIS
3.6.1 → 3.7.0 after the collation pass. A tenant trigger on
`spatial_ref_sys` did not run.

### Release note

```release-note
[postgres] An image change of a tenant PostgreSQL no longer fails the Helm upgrade while CNPG rolls the instances. The collation repair now runs in a separate `<release>-collation-repair` Job, started after each upgrade, which waits for the new image and retries after connection drops. Check that Job's status and log to confirm the repair finished.
```
2026-11-30 18:24:14 +03:00
Aleksei Sviridkin a768c81b49 feat(linstor): add Blockstor as a selectable storage backend (#2942)
<!-- 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

Adds Blockstor as a second control plane the `linstor` package can
deploy, chosen at install time with `storage.backend` on the platform.
LINSTOR stays the default, and a cluster that does not select blockstor
renders exactly what it renders on `main`. Blockstor serves the LINSTOR
REST API, so linstor-csi, piraeus-operator and the StorageClasses are
the same for both.

This PR is for new clusters only. Moving a cluster that already holds
LINSTOR volumes to blockstor (the `storage.blockstorMigration` steps,
the hook Jobs that relax piraeus's webhooks while the operator is
stopped, and the README order) is split out into #5466, stacked on this
one.

Blockstor is experimental. The package pins blockstor 0.4.0, all three
images by digest, and the chart refuses to render if the controller,
apiserver and satellite tags name different releases. 0.4.0 advertises
REST API 1.29, which the linstor-csi v1.13 on `main` requires. A LUKS
volume formatted by blockstor 0.2.x is neither opened nor re-formatted
by 0.3.0 and later, since 0.3.0 wraps a per-volume password under a
master key. This only matters for clusters that ran an earlier revision
of this branch; nothing on `main` ever shipped blockstor.

Default path:

- `helm template packages/system/linstor` is byte-identical to `main`
(defaults, `talos.enabled=false`, `drbd.enabled=false`, explicit
`backend=linstor`).
- The platform renders the `cozystack.linstor` Package without
components, as on `main`, so an upgrade rolls no new revision of the
release.

Selecting the backend: `storage.backend` falls back to `linstor` only
when the key is absent. Any other present value fails the render, `""`,
`false` and `0` included. `null` is the one case the chart can't see,
Helm drops a null key before rendering. The `linstor` chart checks the
value on its own too. Changing the backend of a running cluster fails
the render, the same way the networking variant guard works: the
platform looks up the live `cozystack.linstor` Package, and
`storage.acknowledgeBackendChange: <target>` confirms the switch on a
cluster that has no volumes yet.

Under blockstor the package renders blockstor's controller, apiserver
and satellite, plus its CRDs with `helm.sh/resource-policy: keep`, since
those objects are the whole blockstor database. piraeus-operator runs in
external mode against the apiserver's mTLS port and uses a client cert
from the same CA for its own version probe (#4016). linstor-scheduler
and linstor-gui are told only the backend by the platform and read the
endpoint and client Secret from that same `LinstorCluster`
(`spec.externalController.url`, `spec.apiTLS.clientSecretName`), the
object that points linstor-csi there, so the names of blockstor's
Service and Secret live only in the linstor package and nothing renders
objects under piraeus's names. Under linstor they get no values and keep
their defaults; the scheduler chart takes this through one more vendored
patch. Under blockstor a `LinstorCluster` that names no external
controller yet fails their render instead of falling back to
linstor-controller: on a backend switch they can upgrade before the
linstor release has rewritten that object, and the fallback left them on
a Service the operator then deletes, with nothing to render them again.
The platform's HelmReleases retry a failed render every retry interval
without counting it as a failure, so they follow once the linstor
release is through.

Every blockstor component finds the Secret that opens its master key
through `ControllerConfig/default`. A post-install/post-upgrade hook Job
server-side applies `spec.passphraseSecretRef` there, pointing at
piraeus's `linstor-passphrase` (key `MASTER_PASSPHRASE`, the name is the
`blockstorPassphraseSecret` value), and leaves the rest of the object to
blockstor. It is a Job and not a release object because the CRD comes
with the same release. The controller opens nothing and creates no
keyring until the reference is there, so starting before the Job is
harmless. Because the passphrase Secret is always named, `linstor
encryption create-passphrase` is refused under this chart: the operator
creates `linstor-passphrase` by hand before the first encrypted volume.

piraeus still runs a `linstor-satellite` pod on every node it picks for
`linstor-csi-node`, and `LinstorCluster` has no setting that stops one
without the other. So cozystack's satellite configuration, its internal
CA and the satellite scrape stay under both backends: the pod is pinned
to our image, with TLS, limits and host networking, and the address the
operator registers a node with is the node's own. The plunger and the
opt-in Talos graceful-shutdown hook stay LINSTOR-only (the hook is
refused under blockstor), because they act on DRBD resources that under
blockstor belong to blockstor-satellite. blockstor-satellite runs the
plunger's DRBD workarounds itself, and the chart lets it act on a
stalled resync (LINBIT/drbd#149) instead of only reporting it:
`blockstorSatellite.stalledResyncAct`, on by default.

There is one `LinstorCluster` document for both backends, only the keys
that differ are gated, so the CSI part (strict topology and main's
group-snapshot gate included) can't drift.

RBAC and exposure:

- `cozy-linstor` is shared with piraeus, so no blockstor component can
read an arbitrary Secret there. Each has a namespaced Role naming only
`blockstor-master-key`, `blockstor-unlock` and the passphrase Secret:
the satellite gets `get`, the controller and the apiserver get `get` and
`update`, plus `create`, which RBAC cannot limit by name. The named
rules also allow `list` and `watch`, which newer blockstor releases use
with a `metadata.name` field selector;
- because that `create` is unnamed, a ValidatingAdmissionPolicy admits a
Secret create by a blockstor ServiceAccount in the release namespace
only for the keyring and the generated `blockstor-unlock` Secret, with
the types blockstor gives them;
- no component has cluster-wide Secret access;
- the apiserver's plain HTTP listener is bound to `127.0.0.1`,
port-forward still works;
- the controller has no leader election, so its Deployment uses
`Recreate`, and neither it nor the satellite gets leases;
- the satellite deletes nothing but the PhysicalDevices it discovers,
and the roles name every blockstor kind they grant;
- the satellite's host ports (3372, 9101, 8080) are closed to the world,
same as drbd-reactor's;
- the controller and the apiserver get 21s to stop, so a SIGTERM does
not cut a detached rollback short.

The snapshot stream between satellites runs on port 3372 over mutual
TLS, with a CA of its own from `ca-bootstrapper`, kept apart from the
API CA.

The `blockstor-satellite` DaemonSet rolls one node at a time and holds
each node for `blockstorSatellite.minReadySeconds` (180 by default)
after Ready, because the satellite is Ready seconds after start while
its first pass over the node's DRBD resources ended 1.5 to 2.7 minutes
later on a test cluster with about 110 resources per node.
`maxUnavailable` is fixed at 1 and `maxSurge` at 0, and `OnDelete` is
there for an upgrade checked node by node; the README describes that
procedure. The trade-off to review: the HelmRelease waits for the whole
rollout, about 3.5 minutes per node at the default, so on more than two
or three nodes the first upgrade attempt times out and the retry
finishes it, and `HelmReleaseNotReady` fires meanwhile.

None of the three components sets a CPU limit, as the LINSTOR controller
and satellite don't: under a 500m limit every reconcile pass got
throttled and each volume create took tens of seconds. Memory stays
limited.

The e2e scripts prepare and check whatever `COZY_STORAGE_BACKEND` says,
and refuse an unset or unknown value. Under blockstor the prep waits
until every satellite reports its pool before applying StorageClasses.

`make update-blockstor-crds` refreshes `definitions/` from the blockstor
tag the images are pinned to. For 0.4.0 it reproduces the release's CRDs
byte for byte. Every `DrbdOptions/*` key the chart sets on the
controller and the e2e StorageClasses set passes the whitelist 0.4.0
enforces.

### Testing

- `make test` in `packages/system/linstor`: helm-unittest 133/133 in 20
suites, Python 20/20.
- `helm unittest` in `packages/core/platform`: 394/394;
`packages/system/linstor-scheduler`: 31/31;
`packages/system/linstor-gui`: 28/28.
- `bats`: `hack/linstor-storage-mode_test.bats` 33/33,
`hack/post-install-prep.bats` 25/25, `hack/platform-packages_test.bats`
16/16.
- Every guard was checked by reverting it and watching its test fail:
empty backend, shared strict topology, loopback bind, `Recreate`, the
satellite role, the pool report wait, the pool guard retrying a read
that exits 2, the graceful-shutdown refusal, the stream port and its
TLS, no cluster-wide Secret access, the named Secret grants, the
admission policy, the stop grace, the one-release image check, the
rollout strategy and pause.
- `hack/check-commit-trailers.sh origin/main..HEAD`: OK.

### Not tested

- A live run on 0.4.0 passed on a three-node stand installed with
`storage.backend: blockstor` and upgraded to this PR's pin, see
https://github.com/cozystack/cozystack/pull/2942#issuecomment-7225299079:
Filesystem and Block PVCs, LUKS, snapshot and restore, group snapshots
across nodes, online resize, `vmdisk-clone`, and the `vminstance`
chainsaw suite including the VM backup roundtrips. That run predates the
scheduler and GUI render guard above, which is unit-tested only. No CI
lane can run blockstor: every e2e lane runs Talos in containers without
DRBD.
- The passphrase hook Job and the admission policy are rendered and
unit-tested here; this PR has no run of them on a fresh install.
- The satellite rollout strategy has not rolled on a live cluster; the
timing figures come from a manual node-by-node `OnDelete` upgrade.

### Screenshots

N/A, no UI change.

### Downstream repositories

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

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

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: https://github.com/cozystack/website/pull/667 documents the
backend, `storage.acknowledgeBackendChange` and this chart. It still
describes blockstor 0.2.0 and has to follow this PR to 0.4.0 and to the
master key opened from `linstor-passphrase`. Its LINSTOR to Blockstor
migration guide belongs with #5466. It stays unticked and merges 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:

I walked the trigger map against the diff. Only the website is affected:
the new `storage.backend` key in `packages/core/platform/values.yaml`
and the backend docs, both in website#667. No app package, installer
values, variant, bundle, `hack/package.mk` or `hack/update-crd.sh` is
touched.

### Release note

```release-note
feat(linstor): Blockstor can be selected as the storage control plane for new clusters with `storage.backend: blockstor` on the platform. LINSTOR stays the default and existing clusters are unchanged. Blockstor is experimental, and moving a cluster that already has LINSTOR volumes to it is not part of this change.
```
2026-11-30 15:47:15 +03:00
Andrey Kolkov 66bba3bf1e fix(postgres): run the collation repair outside the Helm hook
The collation repair ran at the end of the post-upgrade init-job and,
when the image moved, waited for the primary to run it. Helm starts that
hook as soon as the Cluster is patched; CNPG then rolls the replicas
first and the primary last, and every instance whose clients hold
sessions sits in smart shutdown for smartShutdownTimeout (180s on
existing clusters). With three instances the wait took about eight of
the Job's nine minutes, the Job printed "the init-job is out of time,
the next run of it carries on" and the HelmRelease went UpgradeFailed
until Flux retried. When the Job's psql met the primary restart instead,
it failed with "FATAL: the database system is shutting down" and failed
the upgrade the same way. A rebuild of a large index does not fit the
hook budget either.

Moving the repair into an ordinary manifest does not help:
helm-controller waits for every Job of a release to complete within the
same upgrade timeout. So a short post-upgrade hook, run after the
init-job, creates the repair Job through the API, outside the release,
and returns. The repair Job has an hour, keeps the wait for the new
image and the resume marks it had, and is owned by the Cluster. It has a
fixed name, so two repairs never run against one Cluster: the hook
leaves one still running on the same image alone and deletes any other,
waiting for its pod to go, before creating the new one, which also
retries a repair that failed. The hook's Role reaches only that Job and
the release's Cluster by name, apart from create, which RBAC cannot
narrow, and is deleted once the hooks succeed.

psql exits with status 2 both when an instance refuses connections while
shutting down and when it drops a session, so both Jobs now rerun their
script after a growing pause on that status instead of failing; the
scripts are idempotent and their elapsed-time bounds keep counting
across attempts. A connection lost during an index rebuild is reported
the same way. smartShutdownTimeout stays as it is: the repair no longer
waits inside the hook, so the rollout's length does not matter.

The PostGIS extension update waits for the same rollout, so it moves
into the repair Job with the collation pass, and the messages of both
name the next upgrade of the release as what starts them again. A lost
connection in the PostGIS pass is reported with the same status as in
the collation pass, so the Job reconnects instead of giving up.

The repair runs after install as well. The init-job used to record there
which Debian release each database started on, and without that record
the first image move is detected only if the repair reaches the primary
before it restarts. The Job sets PGCONNECT_TIMEOUT, so a primary that
does not answer is retried instead of using up the Job's deadline.

A failed index rebuild no longer stops the PostGIS update that follows
it: a unique index that duplicates keep from being rebuilt would
otherwise hold the extensions back until an operator removes them. The
Job still fails at its end.

With an hour to spend, the repair now waits for the new image whenever
the image changes, not only when an index already depends on a versioned
collation. Otherwise it planned on the previous primary, missed an index
created meanwhile, and the release it recorded at the end claimed that
index repaired.

The repair Job carries the WorkloadMonitor's selector labels, opts in to
having its failure reported with workloads.cozystack.io/report-failure,
and has no ttlSecondsAfterFinished, so a failed repair stays visible until the next
upgrade replaces it instead of vanishing while the indexes stay wrong.

Refs: #5459
Assisted-By: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-30 17:58:17 +07:00
Aleksei Sviridkin 222c31fcf8 fix(seaweedfs): pin the in-tree image to a build ghcr serves (#5503)
<!-- 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 in-tree seaweedfs pin on main points at `4.48@sha256:5360a02b...`, a
pull request build that only ever lived in the CI registry. That
registry has pruned it and ghcr never had it, so any install that does
not overlay current-main refs fails to pull the image.

This pins the build of current main that the nightly mirror published to
ghcr instead (`sha256:d3b5fa8d...`, labelled
`org.opencontainers.image.version: 4.48`). Like every main and nightly
build, it is a single-arch amd64 manifest.

The digest is still not behind a permanent tag. Publishing it as `4.48`
needs a manual copy by a maintainer with GHCR write access:

```bash
skopeo copy --all docker://ghcr.io/cozystack/cozystack/seaweedfs@sha256:d3b5fa8d943c637e1aed141508edeb4eca9b531e6b4b1862912abfdcb73b9457 docker://ghcr.io/cozystack/cozystack/seaweedfs:4.48
```
<!-- Link the issues this PR addresses. For a complete fix targeting the
default branch, use Closes #N (Closes owner/repository#N for another
repository). Otherwise use a non-closing reference; release-branch PRs
need manual issue linking and closure when appropriate. -->

### Screenshots

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

### Downstream repositories

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

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

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

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

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

### Release note

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

```release-note
fix(seaweedfs): pin the bundled seaweedfs image to a digest that ghcr actually serves, so installs without a main-refs overlay can pull it again.
```


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

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

## Summary by CodeRabbit

* **Chores**
* Refreshed the SeaweedFS image digest while retaining version 4.48.
This update does not change the listed version; no end-user feature
changes are included in this update.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-30 00:59:23 +03:00
Andrei Kvapil 71ab260239 fix(linstor): keep scheduler and GUI off a stale endpoint on a switch
Under backend blockstor linstor-scheduler and linstor-gui read the API
endpoint from the LinstorCluster the linstor release renders. The
backend reaches both charts in one platform render, and dependsOn holds
them back only while the linstor release is not Ready, so on a switch
they can upgrade before the linstor release has written
externalController. They then fell back to the values, linstor-controller,
a Service piraeus-operator removes in external mode, and nothing rendered
them again: the scheduler stayed pointed at a deleted controller.

Fail the render instead while the LinstorCluster names no external
controller. The platform's HelmReleases use the RetryOnFailure strategy,
and a failed render stores no release, so helm-controller retries after
the retry interval without counting a failure until the linstor release
has written the endpoint. Under backend linstor nothing changes.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:13 +01:00
Andrei Kvapil eed86349a8 feat(linstor): let the satellite act on a stalled resync
Without its act flag the satellite only reports a stalled resync
(LINBIT/drbd#149) as an Event, and the replica stays Inconsistent
until someone runs the drbdadm commands by hand. Production clusters
should recover on their own, so blockstorSatellite.stalledResyncAct
turns the action on and defaults to true.

The flag arrived in blockstor 0.4.0, the release the chart pins, and
the backend guard keeps the three images on one release, so the chart
passes it without checking the satellite's version.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:13 +01:00
Andrei Kvapil b33e3863f1 feat(linstor): pin blockstor v0.4.0
v0.4.0 serves linstor-csi v1.13 at REST API 1.29, deletes storage
only when asked to, and carries the DRBD workarounds of the LINSTOR
plunger. The CRDs are refreshed from the same tag, so the schema and
the binaries that read it stay one release.

The DrbdOptions keys the chart and the e2e StorageClasses set all
pass the whitelist v0.4.0 enforces, so no parameter has to change.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:12 +01:00
Andrei Kvapil 7ebbbd18a0 fix(linstor): drop the CPU limit of the blockstor components
With a 500m CPU limit the blockstor controller and every satellite sat
at the limit through a burst of volume creates, and idle satellites were
throttled in most CPU periods, so each reconcile pass and each create
stretched to tens of seconds. The LINSTOR components blockstor replaces
run without a CPU limit; the satellite now takes the LINSTOR satellite's
requests and memory limit, and the controller and apiserver keep their
memory limits.

The resources become values so a cluster can size them without patching
the chart.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:12 +01:00
Andrei Kvapil ced338f4f1 fix(linstor): pause the satellite rollout until the first adjust
The blockstor-satellite DaemonSet took the Kubernetes default update
strategy. The satellite reports Ready once its caches have synced,
seconds after start, while re-rendering and adjusting every DRBD
resource on the node takes minutes: on a test cluster a satellite
finished about 110 resources 1.5 to 2.7 minutes after it turned Ready.
An image bump therefore rolled every node seconds apart.

Hold each node for minReadySeconds, 180 by default, after Ready, one
node at a time, and let an operator choose OnDelete to check every
node by hand. maxUnavailable takes only 1 or 0 and a surge is refused,
because two satellites on one node would both drive its DRBD resources
and a wider rollout runs several first passes at once. Readiness never
drops after the cache sync, so the pause stops only a satellite that
exits or restarts; OnDelete with the per-node checks is the gate for a
change in how resources render.

The README describes the node-by-node upgrade, what waits for the
rollout (the linstor HelmRelease past the upgrade timeout and
HelmReleaseNotReady, and the dependent scheduler and gui releases),
and that rolling back means reverting the change that brought the
version.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:12 +01:00
Andrei Kvapil 49725a376d fix(linstor): refuse blockstor images from different releases
The controller, apiserver and satellite speak one wire protocol and
share the CRDs fetched for the controller's tag. Pinning one of them
to another release rendered and passed every test, and broke only on
a cluster, so the chart now fails the render instead.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:12 +01:00
Andrei Kvapil 194201d643 test(linstor): select TLS documents by name, not by position
Both templates render several cert-manager objects, so a positional
index silently retargets an assertion whenever a document is added or
reordered above it. main now rejects new documentIndex selectors on
multi-document templates for exactly that reason.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:12 +01:00
Andrei Kvapil 26435fc0fd feat(linstor): unlock blockstor from piraeus's passphrase Secret
From v0.3.0 every blockstor component finds the Secret that unlocks
the master key through ControllerConfig/default, in the piraeus shape:
linstor-passphrase, key MASTER_PASSPHRASE. Naming it is what lets a
cluster migrated from LINSTOR keep its passphrase, and what blockstor's
runbook assumes under Cozystack.

The field is set by a post-install/post-upgrade Job rather than by a
ControllerConfig in the release. Helm resolves every kind of a release
before applying any, and the CRD is a template of this release, so the
object would fail the first install of the backend. blockstor also
creates and writes the same object at runtime, so the Job server-side
applies only passphraseSecretRef under its own field manager and leaves
the rest to blockstor. The controller does nothing with the keyring
until the reference is there, so starting first is harmless.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:12 +01:00
Andrei Kvapil 6ba465d40a fix(linstor): admit only blockstor's own Secret creates
RBAC cannot limit create by name, and the blockstor controller and
apiserver need create for the keyring and the generated unlock Secret.
With the name-limited get they also hold, a compromised pod could
create a service-account-token Secret for one of piraeus's
ServiceAccounts in cozy-linstor under a covered name that does not
exist yet, linstor-passphrase on a cluster that never set one, and read
the token back. blockstor's design leaves closing this to the chart.

The policy matches only Secret creates in the release namespace by the
blockstor ServiceAccounts, so it cannot reach piraeus or cert-manager,
and admits the keyring and the unlock Secret with the types blockstor
gives them. The passphrase Secret is not admitted: blockstor never
writes it.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:12 +01:00
Andrei Kvapil 5c1f4c532e docs(linstor): point a cluster with LINSTOR volumes at blockstor's runbook
The values files said nothing converts LINSTOR's database into
blockstor's. blockstor v0.2.0 ships linstor-migrate and a runbook for
adopting such a cluster in place; the platform still does not run it,
so the backend value stays for new clusters and names the runbook.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:12 +01:00
Andrei Kvapil 112aa1ca16 fix(linstor): give the blockstor controller and apiserver 21s to stop
Their REST servers hold a shutdown window derived from the detached
rollback budget, and blockstor v0.2.0 sets the pods' grace to 21s so a
SIGTERM does not kill a compensation mid-cascade.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:11 +01:00
Andrei Kvapil b4865ae574 fix(linstor): let the blockstor satellite record events.k8s.io events
The satellite's recorder writes events through events.k8s.io, for a
LUKS format refused over data, and the role granted only core events.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:11 +01:00
Andrei Kvapil b9526ebfd2 fix(linstor): grant blockstor its Secrets by name only
blockstor reads the passphrase Secret past controller-runtime's cache,
keeps the master key in its own keyring Secret and unlocks it from
piraeus's linstor-passphrase. Its own RBAC grants the satellite, and
the controller and apiserver, access only to those Secrets and the
generated unlock Secret. cozy-linstor is shared with piraeus, so
unnamed or cluster-wide grants would let any blockstor pod read
piraeus's TLS keys; the satellite runs privileged on every node, which
makes that one compromised node away.

The apiserver reads and writes Secrets through a namespaced Role only.
The controller creates the keyring itself, so it gets its own
namespaced Role, and the namespace it looks the Secrets up in, which
otherwise defaults to blockstor-system. create cannot be limited by
name and is granted on its own. The passphrase Secret's name is a
value so a cluster that names another Secret keeps the Roles in step.

The named rules also allow list and watch: newer blockstor releases
read these Secrets from one watch per Secret selected by
metadata.name, and without the verbs fall back to a GET per read. A
list or watch restricted by resourceNames is authorized only when its
fieldSelector names one of them, so the rule still exposes nothing
else in the namespace.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:11 +01:00
Andrei Kvapil bd64d7672d feat(linstor): run blockstor's snapshot stream on 3372 over mutual TLS
blockstor v0.2.0 moved the stream between satellites from port 9100 to
3372 and runs it over mutual TLS with a CA of its own. The chart issues
the stream CA and the satellites' certificate, mounts it into the
satellite, and closes 3372 to the world instead of 9100.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:11 +01:00
Andrei Kvapil 87e6f99c72 feat(linstor): run blockstor v0.3.0
Bump the three blockstor images to 0.3.0 and take its CRDs from the
release.

v0.3.0 activates an LVM thin pool a reboot left inactive; before it,
a rebooted node reported no capacity on such a pool and volume
creation failed across the cluster. It gives every LUKS volume its own
password, wrapped under a master key that several passphrases can
open, so changing a passphrase no longer touches a volume and losing
one is no longer losing the data. It also keeps each replica's own
DRBD port when converting a LINSTOR cluster.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:11 +01:00
Andrei Kvapil d617d52bfd refactor(linstor): follow blockstor's API group to blockstor.org
blockstor moves its API group from blockstor.cozystack.io to
blockstor.org before anything is deployed on it. The chart's CRD
copies, the RBAC rules of the apiserver, controller and satellite, the
chart tests and the e2e helpers that read the storage pools now use
the new group.

This needs the blockstor release that carries the rename, which the
backend is pinned to before this PR merges.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:11 +01:00
Andrei Kvapil be0a55c072 feat(linstor): make Blockstor a selectable storage backend
Blockstor is a control plane for DRBD-replicated volumes that serves
LINSTOR's REST API and keeps its state in Kubernetes objects instead
of a SQL database. Because it speaks LINSTOR's API, linstor-csi,
piraeus-operator and the StorageClasses stay as they are, and the
linstor package can deploy either control plane behind them.

The platform chooses through storage.backend, linstor by default. The
default leaves the linstor Package as it was, with no components, so
existing clusters render exactly what they rendered before and roll
no new revision. A value present but not one of the two strings fails
the render, empty ones included: read as linstor, an empty override
on a blockstor cluster would switch its control plane back. The
linstor chart refuses an unknown backend on its own too, since a
value can reach it without passing through the platform.

Under blockstor the package renders blockstor's controller, apiserver
and satellite, and its CRDs with helm.sh/resource-policy: keep, since
those objects are blockstor's whole database and a switch back to
linstor must not delete them. piraeus-operator runs in external mode
against blockstor-apiserver's mutual-TLS port, and is pointed at a
client certificate from the same CA for its own version probe, which
otherwise fails and stops every LinstorCluster and LinstorSatellite
reconcile. linstor-scheduler and linstor-gui read that endpoint and
client Secret from the same LinstorCluster, rather than from objects
rendered under piraeus's names, so the platform tells them only the
backend and no package but this one names blockstor's Service.

piraeus still runs a linstor-satellite pod on every node it selects
for linstor-csi-node, and nothing in LinstorCluster stops that without
also stopping the CSI node plugin. So cozystack's satellite
configuration, its internal CA and the satellite scrape stay under
both backends: what runs is pinned, uses TLS and host networking, and
the address the operator registers each node at is the node's own
rather than one on the pod network.
The plunger stays with LINSTOR, as it drives DRBD resources that under
blockstor are blockstor-satellite's alone, and the opt-in Talos
graceful-shutdown hook is refused under blockstor for the same reason:
it downs every idle Secondary resource in the shared kernel.

The LinstorCluster is one document with the differing keys gated, so
the CSI half, strict topology included, cannot drift between the two.
The apiserver's plain-HTTP listener, which authenticates nobody, is
bound to loopback. The controller runs without leader election, so its
Deployment uses the Recreate strategy. Each workload is granted what
it uses: the apiserver writes Secrets only in its namespace, the
satellite reads its one Secret there and deletes nothing but the
PhysicalDevices it discovers, and neither binary gets leases, since
neither runs leader election. The roles name every blockstor kind
they grant. The satellite's unauthenticated
host-network ports are closed to the world the way drbd-reactor's
are.

Blockstor is for new clusters only. The pinned release cannot adopt a
cluster that already holds LINSTOR volumes safely, and nothing here
converts LINSTOR's database, so both values files say so, and the
platform refuses to change the backend of a live cozystack.linstor
Package unless storage.acknowledgeBackendChange names the new one, the
way the networking variant guard does.

`make update-blockstor-crds` refreshes the CRDs from the blockstor tag
the images are pinned to.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:45:11 +01:00
Andrei Kvapil 119859548b fix(seaweedfs): pin the in-tree image to a build ghcr serves
The 4.48 pin named a digest from a pull request build in the CI
registry. Nothing copies such a digest to ghcr: the nightly mirror
publishes the images it rebuilds from main, and only a release pushes
the 4.48 tag. The CI registry has since pruned it too, so any install
that does not overlay current-main refs pulls a manifest that does not
exist. Pin the build of current main that the nightly published
instead.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 13:44:00 +01:00
Andrey Kolkov 05477de6f9 fix(postgres): rebuild indexes on C.UTF-8 when the Debian release changes
PostgreSQL records no collation version for a libc locale named
C.<codeset>, so the collation repair never counted a column declared
COLLATE "C.UTF-8", or a database created with LC_COLLATE 'C.UTF-8', as
stale. Yet the C.UTF-8 Debian patched into the glibc of bullseye and the
one glibc ships since 2.35 order characters differently. After the move
to the standard-trixie images an index on such a column misses most of
its keys and amcheck reports "item order invariant violated", on
PostgreSQL 13 as on 17, and the pass said nothing on PostgreSQL 15 and
later.

Such a collation, and a database default of such a locale, now take the
Debian release of the server's build (the pgdg suffix of server_version)
as their version, so their indexes go through the same resumable rebuild
as any other stale collation. PostgreSQL keeps nothing to compare that
release with, so the pass records the release each database was repaired
for in the cozystack.collation_release setting, once the database is
repaired without a failure. A database without the setting gets the
release of the server the pass first finds it on. The pass looks before
it waits for the rollout, so the old release is recorded even when that
run then fails, and a retry after the primary has restarted still
rebuilds. A database first seen when the server already runs the new
glibc is recognised by a libc collation, or a libc database default,
whose recorded version differs from the server's. Anything else, a new
cluster included, is recorded as repaired for the release it runs and
nothing is rebuilt. That includes a database an earlier pass already
repaired on the new glibc: it refreshed the libc versions and left no
sign of the move, so its indexes on C.* collations need a REINDEX by
hand.

Before PostgreSQL 15 the pass warned that a C.<codeset> database default
could not be checked; it is repaired now, so the warning no longer fires
for it. A range partition key on such a collation is reported once, by
the run that rebuilds its indexes, since PostgreSQL logs no version
mismatch for it later.

Refs: #5459
Fixes: b40be51a6b ("fix(postgres): move the default flavor to patched standard-trixie images")
Fixes: a10e449a56 ("fix(postgres): rebuild indexes whose collation changed version")
Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-28 09:32:53 +07:00
Aleksei Sviridkin 9cf93b8535 fix(postgres): keep bullseye clusters on their image until a clean locale check (#5472)
## What this PR does

Refs #5459. Part of bringing #5405 (standard-trixie images) back to
release-1.7, which #5461 reverted. This PR covers the `C.UTF-8` item of
#5459 by keeping such clusters off the new image. The other items are
fixed separately: the repair racing the rollout and the Job budget, the
repair skipping `C.UTF-8`, the double REINDEX, and the postgis extension
update.

### Why

Clusters created before #5405 run a bare tag, the system variant on
Debian bullseye. Moving them to `standard-trixie` changes glibc and ICU
under the data directory. The collation repair pass from #5405 cannot
see every case. A libc `C.*` locale such as `C.UTF-8` carries no
collation version in any PostgreSQL major, yet Debian bullseye's
`C.UTF-8` and the one in glibc 2.35+ sort differently. Until the indexes
are rebuilt, replicas return wrong results through `-ro` and unique
indexes accept duplicates. PostgreSQL ([Locale data
changes](https://wiki.postgresql.org/wiki/Locale_data_changes)) and
CloudNativePG
([postgres-containers](https://github.com/cloudnative-pg/postgres-containers):
switching the Debian base "is a manual operation because of PostgreSQL
locale-data implications") both treat this as a deliberate, owner-driven
step.

### What it does

A cluster on one of the bare bullseye tags the chart shipped (13.22,
14.20, 15.15, 16.11, 17.7, 18.1) stays on its image until a check finds
it clean. The check fails closed: a cluster not checked yet, one the
check could not finish on, and one it found affected all stay.

- **The check.** A `pre-upgrade` hook (`locale-check-<release>-<hash>`)
runs before every upgrade of such a cluster, from the cluster's current
image.
- It looks in every database for columns, indexes, composite or range
types, and `jsonb` indexes that depend on a collation other than C,
POSIX or builtin, and for a database default (collate or ctype) outside
those.
- It records `clean`, `affected` or `unknown` in the
`postgres.cozystack.io/locale-data` annotation of the Cluster, and the
first objects found in `postgres.cozystack.io/locale-data-objects`.
  - Its Role can only `get`/`patch` that one Cluster.
- **What the chart renders.** The chart reads the recorded answer
through `lookup`. Helm renders before hooks run, so the hook fails an
attempt only when the new answer contradicts that render, before the
Cluster is patched. The HelmRelease retry then renders according to the
new answer:
- A cluster not checked before, or found `affected` or `unknown`, is
rendered on its current image. The upgrade passes, and every other value
of the app still applies.
- A cluster found `clean` fails that attempt once, and the retry moves
it to `standard-trixie` with the existing repair.
- **Opt-in.** `allowCollationChange: true` moves a held cluster on the
next upgrade, in a window the owner picks.
- **Version changes.** A held cluster refuses a change of `version` with
an explicit render error, since new majors are built only on the new
images.
- **Restore.** The CNPG backup driver copies the source Cluster's
`spec.imageName` into the backup snapshot verbatim, passes it to the
restore as `bootstrap.sourceImageName`, and clears it with
`bootstrap.enabled`. The core controller knows nothing about the chart's
hold rules.
- The chart decides: a backup taken on one of the bullseye tags restores
onto that image, so the data keeps the library that built it.
- The next upgrade then checks the restored data like any other bullseye
cluster.
- Any other value is ignored, so a tenant cannot choose an image through
it.
- The driver also reads the major from that image tag when the backup
recorded none, and refuses a mismatch with `spec.version` before the
purge.

### What a held cluster is left with

- It keeps running its bare bullseye tag. Upstream builds new PostgreSQL
minors only on bookworm and trixie, so a held cluster gets **no further
minors and none of their security fixes; CVE-2026-116331 stays open on
it** for as long as it is held.
- The tenant sees only that the image did not change. The answer and the
objects found are on the cnpg.io Cluster, which only an administrator
can read.
- There is no deadline. The hold lasts until the owner takes one of the
ways out below.

### How a held cluster leaves that state

1. **Remove the dependency.** Move the listed columns and indexes to
`C`, or to the builtin `pg_c_utf8` on PostgreSQL 17 and later, or drop
them. The next upgrade checks again, finds the cluster `clean` and moves
it.
2. **Move explicitly.** In a maintenance window, set
`allowCollationChange: true`. The next upgrade moves the cluster and the
init Job's repair rebuilds indexes on versioned collations (ICU, libc
locales other than `C.*`). Until the separate `C.UTF-8` repair fix
lands, rebuild indexes on `C.UTF-8` or another `C.*` locale by hand with
`REINDEX INDEX CONCURRENTLY`. Range partitions, CHECK constraints and
materialized views on such text are not fixed by a rebuild and need a
logical move (pg_dump/restore or logical replication). During the move,
replicas restart on the new image first, so reads through `-ro` can be
wrong and unique indexes can accept duplicates until the primary's
rebuild is done.

### Testing

- `helm unittest packages/apps/postgres`: 276 passed, including
`tests/locale_guard_test.yaml`. It covers:
- holding on `affected`, `unknown` and a missing result, and moving on
`clean`;
  - the opt-in and the version refusal;
- restores from bullseye and trixie backups, hand-set recoveries, and
leftover values;
- ignoring foreign images, postgis, hook gating, naming and the Role
scope.
- `go test ./internal/backupcontroller/...` passes, including
`cnpg_source_image_test.go` and the restore reconcile cases for passing
the image on and refusing the held major before the purge.
- The check script was run in Docker against `postgres:13-bullseye` and
`postgres:18-bookworm`:
- It flags `C.UTF-8`/`C.utf8` columns and defaults, ICU indexes, `en_US`
defaults with text, a `C`-collate / `en_US`-ctype database with a
`lower()` index, composite and range types over text, and `jsonb`
indexes under a non-C default.
- It reports `clean` for `C`, `POSIX`, `pg_c_utf8` and `ucs_basic`, and
when another database is `default_transaction_read_only`.
- It reports `unknown` on an authentication failure or when a database
accepts no connections.
- The record step was run with a stub `kubectl` for each render (held or
moving) and answer:
- held + `clean` fails the attempt; held + `affected`/`unknown` passes;
- moving + `clean` passes; moving + `affected`/`unknown` fails the
attempt;
  - every answer is recorded.
- Dev cluster: apps installed from the v1.7.1 chart (`postgresql:17.7`,
bullseye) and upgraded to this branch (results in the PR thread).

### Screenshots

### Downstream repositories

The trigger map hits `cozystack/terraform-provider-cozystack`, because
this adds `allowCollationChange` and `bootstrap.sourceImageName` to the
postgres `values.schema.json`. The follow-up is
cozystack/terraform-provider-cozystack#91.

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: cozystack/terraform-provider-cozystack#91
- [ ]
[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
[postgres] A cluster still on a Debian bullseye image now stays on that image until a pre-upgrade check finds nothing in it that depends on a collation other than C, POSIX or builtin (an ICU or libc locale, or C.UTF-8), or until `allowCollationChange` is set. A held cluster gets no further PostgreSQL minors or their security fixes. The `postgres.cozystack.io/locale-data` annotation of the cnpg.io Cluster shows the result of the check.
```


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

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

## Summary by CodeRabbit

- **New Features**
- PostgreSQL upgrades from older Debian Bullseye images now check for
collation-dependent data and hold the current image when results are
affected or unknown.
- Added an opt-in setting to allow the image change despite the
collation check. Review collation and index-rebuild considerations
before enabling it.
- PostgreSQL restores retain source-image information to support image
selection and compatibility checks.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-27 18:42:08 +03:00
Aleksei Sviridkin ed22d251c8 feat(api): add EndpointAttachment to attach addresses to app endpoints (#4324)
## What this PR does

Implements `EndpointAttachment` (`local.sdn.cozystack.io/v1alpha1`,
namespaced) from the design proposal in
[cozystack/community#45](https://github.com/cozystack/community/pull/45):
a tenant-created resource that attaches one external address to one
tenant-facing Service of one managed application. It is the Network
load-balancing path (a dedicated address per attachment), complementary
to SNI exposure through the tenant Gateway, and it implements the
`loadBalancer` union member only. Nothing in it routes by hostname,
touches TLS, or reads chart values.

Two commits. The first updates address-controller and metallb-iad to
v0.3.0: the class's provisioner now reports, in
`IPAddressClass.status.loadBalancerClass` with an `Accepted` condition
for the class's generation, the `loadBalancerClass` a Service consuming
its claims must carry, and the MetalLB driver writes that status. The
second adds `EndpointAttachment`, which sets that class on every Service
and FloatingIP it renders and renders nothing new until the class is
accepted (`ClassNotAccepted`); a Service or FloatingIP already published
is kept if the class later loses acceptance. The FloatingIP retarget
check needs cozyplane v0.1.5 or later, which stamps
`metadata.generation` and `status.observedGeneration`.
[#5389](https://github.com/cozystack/cozystack/pull/5389) moves the
cozyplane pin to v0.1.5, and this PR merges after it; on an older
cozyplane both fields read 0 and the check passes as before.

**API** (`api/localsdn/v1alpha1/endpointattachment_types.go`, CRD
generated into the cozystack-controller chart). The kind lives in
`local.sdn.cozystack.io`, the CRD-served half of the sdn family the
address substrate and cozyplane already share, so stock `ResourceQuota`
counts still work. `spec` is required at the resource root, since
removing it would otherwise skip every rule nested inside it.
`spec.applicationRef` (group/kind/name, group defaulting to
`apps.cozystack.io`), `spec.endpoint.serviceName`, and
`spec.loadBalancer` with `className` | `claimName` (exclusive),
`family`, `ports`, `method` (`WholeIP` | `PortList`), `allowICMP`. CEL
freezes the address-identity fields (`applicationRef`, `className`,
`claimName`, `family`) and the member selection, requires exactly one
union member (written as a list so a `gateway` member can be added
without restructuring), and holds the static shape rules (`PortList`
needs `ports`, `allowICMP` is `PortList`-only). Everything cross-object
or dynamic is a condition. `status.phase` is a projection of the
`Resolved` and `Provisioned` conditions.

**Controller** (`internal/controller/endpointattachment`), one reconcile
in four steps:

1. Resolve. The application's HelmRelease is found by the three lineage
labels; the attachment gets a non-controller owner reference to it by
UID and the lineage labels stamped on itself. The endpoint Service must
carry the lineage triple matching `applicationRef` and
`internal.cozystack.io/tenantresource: "true"`; lineage alone is refused
(`EndpointLineageMismatch` / `EndpointNotTenantFacing`), as is a Service
rendered by another attachment, and a LoadBalancer Service a tenant
Kubernetes cluster's cloud-controller-manager creates for a Service
inside that cluster: it carries the cluster's lineage and the marker,
and is told apart by the `cluster.x-k8s.io/tenant-service-name` label
that controller writes. A same-name recreated application (different
HelmRelease UID) is reported as `ApplicationIncarnationChanged`, the
Service is withdrawn, and the owner reference is never rewritten.
2. Claim. `claimName` references an existing `IPAddressClaim` and writes
nothing to it; otherwise a claim is minted with `generateName` under the
attachment's controller reference. The substrate kinds are read as
unstructured, so the controller carries no module or CRD dependency on
it and reports `ClaimPending` where it is not installed.
`loadBalancerClass` is read from the claim's resolved `IPAddressClass`
status before the Service is created, only once the class's `Accepted`
condition is True for its current generation, and left empty when the
class reports the cluster default. The Service's `ipFamilyPolicy` and
`ipFamilies` follow the claim's family (`SingleStack` for IPv4 or IPv6,
`RequireDualStack` for Dual) and are reconciled on existing Services; a
primary family that differs, which the apiserver never changes, and a
create the cluster refuses are both reported as `RenderFailed`. An
address whose `IPAddress.status.associatedTo` names another live Service
gives `ClaimInUse` and withdraws this attachment's own Service, so two
attachments that both rendered before either association was recorded
leave one Service asking for the claim. A `family` conflicting with a
referenced claim gives `FamilyConflict`.
3. Render. One `type: LoadBalancer` Service via `generateName` (a prefix
derived from the attachment name and bounded to what the apiserver
accepts for a Service, which also bounds the minted claim's), identified
by controller owner reference only (a Service with the ownership label
and no reference is ignored, never adopted). It mirrors the endpoint's
selector and ports (or the `ports` subset; synthesized ports when the
endpoint has only the sentinel port), carries the
`local.sdn.cozystack.io/ip-address-claim` annotation,
`externalTrafficPolicy: Local`, and `allocateLoadBalancerNodePorts:
false` unless the platform says otherwise. It copies no labels or
annotations from the endpoint. An endpoint with no selector
(hand-managed endpoints) is refused with `NothingToPublish`, and the VM
placeholder is recognised by its shape (headless, only port 65535)
rather than by the port alone. When the cache shows no owned Service,
the controller rechecks through the API reader before creating one, and
collapses duplicates to the oldest. Re-mirroring is event-driven through
watches on Services, EndpointSlices, HelmReleases and, where served at
startup, the claim kind.
4. Report. `status.addresses` mirrors the claim's bound addresses (a
list), `status.serviceName` and `status.claimName` name the objects, and
`Provisioned=True` asserts address and Service wiring only; its message
says so, since reachability additionally depends on the CNI's policy
objects.

**VM datapath modes.** `method` renders the cozy-proxy Service contract
exactly (the `service.kubernetes.io/service-proxy-name: cozy-proxy`
label, `networking.cozystack.io/wholeIP`,
`networking.cozystack.io/allowICMP`, the sentinel port for whole-IP
without ports) and adds nothing beside it. Rendering is gated on a
platform declaration, not CNI detection: the controller flag
`--cozy-proxy-contract-implemented` is threaded from the system bundle,
which sets it exactly when it emits the cozy-proxy Package; without it a
method-bearing attachment renders no Service and reports
`DatapathContractUnavailable`, because a load balancer would still
attract the address while every proxy skipped the Service. Exclusivity
is keyed on the backend pod and counts every delegated Service in either
mode (attachments, chart Services rendered with `external: true`,
hand-made ones): a delegation no attachment renders (a chart Service
with `external: true`, or a hand-made one) always wins, since nothing
would ever withdraw it; between attachments the oldest wins, ties by
name. The loser reports `BackendAlreadyDelegated` and renders nothing
rather than fighting for the slot. cozy-proxy v0.4.0 programs IPv4 only
(one IPv4 nftables table, every address through `To4()`), so a method
attachment off a VPC with an `IPv6` or `Dual` claim renders no Service
and reports `FamilyUnsupportedByDatapath`; the cozyplane path still
serves IPv6 through the FloatingIP. `WholeIP` on an endpoint with more
than one ready backend keeps its Service and claim but selects nothing
(`MultipleBackends`), so a rolling update or live migration passes
through held-but-dark and recovers without churning the address.

**VMs in a VPC.** On a cozyplane VPC the VM's only interface is in the
VPC, so the launcher pod address a cozy-proxy Service maps to never
reaches it. When a backend pod carries the VM chart's
`sdn.cozystack.io/vpc` annotation and the cluster serves cozyplane's
`FloatingIP`, a `WholeIP` attachment owns a FloatingIP in its namespace
(`vpcRef` from the annotation, `target` from the
`sdn.cozystack.io/vpc-ip` address cozyplane's CNI stamps,
`addressClaimName` the attachment's claim) instead of a Service, and
`Provisioned` mirrors the FloatingIP's readiness. FloatingIP is read as
unstructured and only where served, so there is no dependency on the
cozyplane PR. Refusals there: `PortList` (`MethodUnsupportedInVPC`), a
`Dual` claim, since a FloatingIP wears one address
(`DualStackUnsupportedInVPC`), a VPC in another namespace
(`VPCNotInNamespace`), several distinct VPC addresses or a mix of VPC
and non-VPC pods (`MultipleBackends`, claim held), no VPC address
stamped yet (`WaitingForVPCAddress`), and a VPC backend where FloatingIP
is not served (`DatapathContractUnavailable`, no Service). A live
migration's two launcher pods share the VPC address and stay one
binding; a stopped VM keeps its FloatingIP. Since only a backend pod
says whether a VM is in a VPC, a `method` attachment that has published
nothing yet waits for one (`WaitingForBackend`), so an attachment
created before its VM starts never pins the claim to a cozy-proxy
Service first. On the kube-ovn VPC the VM keeps its pod-network
interface and joins VPC subnets through extra interfaces, so the
cozy-proxy path is unchanged there.

**Detach semantics.** An endpoint Service that disappears withdraws the
rendered Service, keeps the claim (minted or referenced), and reports
`Detached`; the same claim is reused when the endpoint returns. Deleting
an attachment collects its Service and its minted claim; a referenced
claim is untouched.

**Wiring.** The controller is registered in `cmd/cozystack-controller`
behind two flags (`--cozy-proxy-contract-implemented`,
`--endpoint-attachment-allocate-node-ports`), the chart exposes them as
`cozystackController.endpointAttachments.*`, the platform system bundle
derives both (cozy-proxy emitted, Hetzner RobotLB enabled), the
controller ClusterRole gains Service writes, the `endpointattachments`
kind, `ipaddressclaims` create/delete and `sdn.cozystack.io`
`floatingips` writes, and the tenant ClusterRoles get
`endpointattachments` beside `securitygroups` (full in
`cozy:tenant:base`, read in `cozy:tenant:view:base`, write in
`cozy:tenant:admin:base`).

**Tests.** `crdcel_test.go` compiles the shipped CRD and pins the create
and update admission matrix. `reconciler_test.go` (fake client) covers
the resolve/deny matrix over both label families, mirroring and port
subsetting, the minted-claim path, the two proof sequences (a
labelled-but-unowned Service is ignored and a same-name recreated
application is not re-acquired; a reserved claim holds across detachment
and moves to a different application), detach/reattach, the
sentinel-port rule, the capability gate, both modes, held-but-dark on
multiple backends, pod-keyed exclusivity, the substrate-absent path and
the family conflict. Admission tests also validate from the resource
root (removing or restoring `spec`). The reconciler tests cover a Dual
claim that is provisioned only once the Service carries both addresses,
and attachment names up to 253 characters, with dots or a leading digit,
on both address-selection paths. `floatingip_test.go` covers the
cozyplane path: the FloatingIP's spec and readiness mirroring, the claim
worn by its own Service not counting as in use, switching from and back
to a cozy-proxy Service, a kube-ovn-shaped backend keeping the Service,
each refusal, live migration, a stopped VM, re-pointing in place, detach
and name bounds. Chart unit tests pin the platform declaration on every
bundle variant, slim opt-in included, and the FloatingIP RBAC rule.
`hack/e2e-chainsaw/endpointattachment` carries the postgres hold/move
sequence, GC, the lineage refusal of an attachment pointing at another
application's Service, and the VM mode Test (re-scoped to a single
delegated Service per VM, since current cozy-proxy's rule installer
keeps one 1:1 slot per pod). It is registered: `hack/select-install.sh`
maps it to `cozystack.address-controller` and `cozystack.metallb-iad`,
with Postgres, VMInstance, VMDisk and cozy-proxy as its runtime
requirements, and `hack/select-e2e.sh` maps both substrate packages back
to it, since no other suite installs them. The e2e install enables both
packages, and `hack/e2e-post-install-prep.sh` creates the default
`IPAddressClass` on a dedicated, non-auto-assigning MetalLB pool
whenever metallb-iad is installed.
`hack/e2e-chainsaw/endpointattachment-vpc` covers the cozyplane
FloatingIP path (whole-IP published through a FloatingIP, `PortList` and
`Dual` refused) and stays parked as `chainsaw-test.yaml.disabled`,
because no e2e lane installs the cozyplane networking variant.

**Upgrade.** Additive: a new CRD, a new reconciler, new RBAC rules, no
migration. The system bundle now always passes the cozystack-controller
component an `endpointAttachments` values block, so the first upgrade
rolls the controller once with the new flags; the flags change nothing
until `EndpointAttachment` objects exist, and no existing object is
modified.

**Docs.** The user guide is on the website, in
[cozystack/website#825](https://github.com/cozystack/website/pull/825):
the resource, which Services can be attached, the lifecycle, the
conditions' exact meaning, the VM modes and the cozyplane path, and the
TLS posture (attaching a database does not turn its TLS on). It is a
cross-package guide, so under the documentation placement rules it lives
there rather than in `docs/`.

**Not in this PR, deliberately.** The `gateway` union member (a reserved
name; the CRD ships without it and nothing references it). A certSAN
write-back for the managed Kubernetes API. Discovery-engine address
write-back. The address-preserving migration from `external: true`. An
authoritative exclusivity gate inside cozy-proxy (the attachment-side
refusal is advisory); that wants an issue in cozystack/cozy-proxy.

### Screenshots

Not a UI change.

### Downstream repositories

`ApplicationDefinition.spec.services` now also decides which Services
tenants can attach an address to, which the trigger map routes to the
website's ApplicationDefinition page:
[cozystack/website#825](https://github.com/cozystack/website/pull/825)
documents that, and carries the user guide. Nothing else matched: the
cozy-proxy runtime contract is consumed with the same three literal
strings and nothing is renamed; the new CRD travels as opaque JSON in
the terraform provider; no platform `values.yaml` key, variant, asset or
node prerequisite changed. An issue in cozy-proxy for an authoritative
one-delegation-per-pod gate is worth a human decision rather than a
speculative filing.

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

### Release note

```release-note
feat(api): add EndpointAttachment (local.sdn.cozystack.io/v1alpha1), a tenant resource that attaches an external address, minted from an IPAddressClass or bound from a reserved IPAddressClaim, to one tenant-facing Service of a managed application by rendering an additive LoadBalancer Service that mirrors it; VM whole-IP and port-list modes render the cozy-proxy contract where the platform deploys it.
```


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

## Summary by CodeRabbit

* **New Features**
* Added endpoint attachments to publish eligible application and VM
endpoints through dedicated load balancer addresses, with whole-IP or
selected-port exposure and IPv4, IPv6, or dual-stack support.
* Attachments can use a reserved address or request one through a
configured address class. Status shows endpoint resolution,
provisioning, assigned addresses, and attachment state.
* Tenant access now includes managing and inspecting endpoint
attachments. Whole-IP VM exposure is limited to one delegated backend,
and VPC support depends on the available network datapath.

* **Documentation**
* Added guidance on eligible endpoints, address lifecycle, status, and
exposure considerations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-27 15:56:24 +03:00
Andrei Kvapil 470a561c3a Merge commit from fork
security(harbor): give the inner registry its own credential and port policy
2026-11-27 13:50:54 +01:00
Aleksei Sviridkin f342bd4765 feat(api): add installation defaults for new applications (#5107)
## What this PR does

This PR adds installation defaults for applications: administrator sets
`applicationDefaults` in the platform values, and every application
created after that starts from them. Design is in [the proposal in
cozystack/community](https://github.com/cozystack/community/pull/116),
related to [the worker defaults
issue](https://github.com/cozystack/cozystack/issues/3950).

The value is keyed by ApplicationDefinition plural (for example
`postgreses`) and the platform chart renders it into the
`cozystack-application-defaults` ConfigMap in `cozy-system`. The
aggregated API merges the entry for the kind under the submitted spec on
create, apply-create and dry-run create, and saves the result in
HelmRelease values. The order is user values, installation defaults,
then developer defaults from the chart schema. Update never applies
defaults, so changing the value leaves existing applications alone.

The merge goes into objects that declare `properties` and replaces
everything else whole: arrays, dictionaries with `additionalProperties`,
free-form objects, objects that also take arbitrary keys and objects
marked `x-kubernetes-map-type: atomic`. So a node pool that sets its own
`registryMirrors` gets no platform mirror entries. Explicit empty values
from the user (`{}`, `[]`, `false`, `0`, `""`) win over the installation
value.

An entry is checked against the application's OpenAPI schema before it
is merged. An object that the merge completes is checked as a partial
one, so `required` and `minProperties` are not enforced on it and its
`oneOf` is not evaluated (CEL rules are not evaluated at all). Whatever
is stored whole is checked whole: array rows, dictionary values,
free-form and atomic objects. Without that, an entry like a RabbitMQ
vhost without `roles` was accepted and stored, and the chart refused to
render it.

A missing ConfigMap means no defaults and gives no warning. An
unreadable ConfigMap, invalid JSON, a bad entry or an unreadable schema
does not block the create: defaults are skipped and the response carries
a Warning (dry-run too). The generic checks cover the whole map, so one
entry that is not an object, or a reserved top-level field in any entry,
turns defaults off for every application until it is fixed, while a bad
entry of one application only affects that application. The ConfigMap is
read through a cache limited to that one object, startup waits up to 30
s for it to sync and a create waits up to 5 s for the read, then both go
on without defaults.

Some objects take exactly one of their children and the chart refuses
two: the worker image of a node pool (`osImage.builtin` or
`osImage.factory`), a vm-disk `source`, the `oidc.customConfig` of a
kubernetes cluster and of a monitoring stack (`config` or `secretRef`).
A default for one child merged into an application that chose another
built that spec. These carry the atomic marker now, so the merge
replaces them whole, and `values.yaml` tells catalog authors to do the
same in their own schemas. The chart guide (`docs/agents/overview.md`)
says when the marker fits and when it does not. The `osImage` change is
the same hunk as in #5192.

The dashboard order page sends one dry-run create when it opens and
starts the form and YAML from the returned spec, so the browser reads no
ConfigMap and merges nothing. If the preview fails, or gets no answer in
8 s, the form opens with a notice and Retry, and Deploy still works.
After a failed preview a dropdown stays empty instead of selecting the
cluster default option, so the API applies the platform default to the
omitted field. A cleared text field leaves its key out, a dropdown None
and a sensitive field are written as `""`. While the server owns
defaults the form does not fill schema defaults on its own.

Not in this PR: defaults on update, re-rendering existing applications
when the value changes, defaults for HelmReleases that controllers
create directly, validation when the ConfigMap is saved, previews on
every edit in the dashboard.

### Merge order

#5190 and #5191 are merged and this branch is rebased on main. #5192 is
open and has the same `osImage` marker hunk, so whichever of the two
lands second needs one more `make generate` after a rebase.

### Known limits

- The dashboard does not show the API Warning.
- `null` for a field that has a developer default is saved as `null`
through kubectl or Terraform, but the dashboard form shows the developer
default.
- A number in an integer-or-string field is rejected by the form (same
on main), so quantities in an entry have to be quoted, `cpu: "2"`.
`values.yaml` says so.
- After a failed preview the form still requires a field that has no
schema default, even if an entry would supply it. Typing the value or
switching to YAML gets around it.
- The marker only fits a choice between alternatives that each stand
complete. I went through the application charts and rendered every
refusal I found that involves two or more fields, and most are not that.
A pair that has to be set together (`resources.cpu` with
`resources.memory`, `tls.enabled` with `tls.disableNonTLSListeners` in
rabbitmq) is completed field by field today, and an atomic object would
drop the default half. An object that also holds independent fields an
admin would default (`backup` in clickhouse, mariadb, mongodb and
postgres, `volume` in seaweedfs) would lose them. Relations between two
objects or two top-level fields (`cloudflareProxy` with `proxyProtocol`
in the ingress, most of postgres, the kubernetes addons) cannot carry a
marker. In all of these a default for one field plus the user's value
for another can make the chart refuse the render after the create went
through. Catching that needs the relations declared as rules in the
schema and the merged spec checked against them, and the API does not
evaluate such rules on a user spec yet (#2657), so it is a separate
change. A few relations depend on a lookup into the cluster and I could
not render them offline.
- Clearing an optional text or number field in the order form leaves its
key out, so the default comes back. A dropdown set to None, a sensitive
field and a dictionary value send an empty string and win. The form
keeps its old meaning of clearing a field, same as on main. To override
a default with an empty value, set it in the YAML tab (`""`, `0`).
Switching from the YAML tab back to the form fills an empty dropdown
with its default option again, a None included, so such a value has to
be deployed from the YAML tab
(https://github.com/cozystack/cozystack/issues/5473).
- An entry that cannot be parsed (invalid JSON, a reserved `_` key)
turns defaults off for every kind, not only its own, and the Warning on
each create names the problem. I did not split it per entry: the failure
is loud, the fix is in one place, and splitting touches the parse and
cache path for a case only a typo causes.
- An atomic object also drops a default for a field nested inside an
alternative when the user sets another field of that alternative. A
default for `osImage.factory.imageFactoryURL` does not survive a pool
that sets `osImage.factory.version`, and the boot disk then comes from
the public factory. `talos.imageFactoryURL` is the knob the chart falls
back to, it is not atomic, and defaults for it keep working.
- A schema that declares a typed property only inside an `allOf` or
`anyOf` branch, under a root that takes arbitrary keys, is checked as
partial. No schema in the tree looks like that.
- An object inside an `allOf`, `anyOf` or `oneOf` branch is closed to
unknown keys even when the property it constrains is declared as a
dictionary, so a valid entry for such a schema is refused and the create
goes on with a Warning
(https://github.com/cozystack/cozystack/issues/5474). No schema in the
tree looks like that either.
- The preview uses the placeholder name `preview`, so it fails when the
tenant already has an application of that kind with this name, and the
form opens with the notice.
- The cache wiring in `pkg/apiserver/apiserver.go` has no unit test, the
cache itself has.

### Verification

- `make unit-tests` on this head with `LC_ALL=C`, exit code 0 (a kafka
bats test on main depends on the locale).
- `tsc` and `eslint` in the console are clean.
- For the checks below I broke the code on purpose and saw the matching
test fail, except the `arrayMinItems` flag of the server form, I could
not make it matter.
- A run on a test cluster with v1.7.0 is in the comment below. It was on
an earlier revision, the stored-whole checks, the extra markers and the
cleared-field change came after and are covered by unit tests only.
- Not run: `make test-controllers`.
- The merge cases asked in review are fixtures of
`TestInstallationDefaultsMergeContract` now: a field set inside the
alternative a user chose of an atomic object, the same object without
the marker, an atomic object nested in one that merges, and an explicit
`null` over an installation object. The whole table is in the proposal
addendum, https://github.com/cozystack/community/pull/146.

Checked cases:

- user values `{}`, `[]`, `false`, `0`, `""` are kept, and a node pool
with its own `registryMirrors` gets none from the platform
- an object with both `properties` and a dictionary, or with preserved
unknown fields, is replaced whole
- empty and `null` `spec` on create
- update after create, apply-update and a field removed on update keep
stored values
- a broken entry for another application, or an application with no
entry and no readable schema, does not touch this create
- missing ConfigMap gives no defaults and no warning, invalid JSON,
unreadable ConfigMap and a cache that did not sync give a Warning and
the create goes on
- partial entry: `required`, `minProperties` and object `oneOf` are
skipped on an object the merge completes, while unknown fields, wrong
types, scalar `oneOf` and array items are still checked
- array rows, dictionary values, free-form and atomic objects are
checked whole, also when the constraint sits in an `allOf` or `anyOf`
branch next to the property, and in these shapes an accepted entry
merges into a spec that the application's own schema accepts
- every ApplicationDefinition in the tree accepts an entry built from
its own developer defaults
- an object that lists properties without `type: object` is checked as
an object, so an unknown field in it is refused
- a pool with `osImage.factory`, a disk with another `source`, a cluster
with `oidc.customConfig.secretRef` and a monitoring stack with
`oidc.customConfig.config` do not get the other child from the platform,
on their real schemas
- a node pool that sets `resources.cpu` still gets `resources.memory`
from an entry, so the marker does not take away the field-by-field
completion of pairs
- dashboard: a user with no tenant does not wait on the spinner,
switching tenant keeps what was typed, a preview answer that arrives
after the tenant changed is dropped, a non-object answer counts as a
failed preview, Retry sends the current draft
- dashboard: after a failed preview dropdowns in a field, an array row
and a dictionary value stay empty, and edits made in YAML come back into
the form
- `required` inside array rows and dictionary values stays in force when
the server owns defaults, and an emptied sensitive field stays `""`

### Screenshots

Not captured yet.

### Downstream repositories

This PR changes `packages/core/platform/values.yaml`. The docs for the
new key are in https://github.com/cozystack/website/pull/828, and the
proposal addendum with the merge cases and two decision records is in
https://github.com/cozystack/community/pull/146. The Terraform provider
may be reached too: it has its own defaults for some sizing fields
(storage class, disk size), so installation defaults would not apply to
those, while the Talos block fields are left out when unset and do get
them. I read the schema, not the expand code.

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: https://github.com/cozystack/website/pull/828
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: to check, provider defaults vs installation defaults
- [ ]
[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:
- [x] [cozystack/community](https://github.com/cozystack/community) -
follow-up: https://github.com/cozystack/community/pull/146

### Release note

```release-note
feat(api): add the `applicationDefaults` platform value, installation defaults are applied to new applications under user values, existing applications keep their saved settings, and the dashboard order form starts from the same defaults.
```
2026-11-27 15:18:14 +03:00
Andrey Kolkov 21d66c4cce fix(postgres): keep bullseye clusters on their image until a clean locale check
Clusters created before the move to standard-trixie run the bare tag, the
system variant on Debian bullseye. Moving them changes glibc and ICU under
the data directory, and the collation repair pass cannot see every case
(C.UTF-8 carries no collation version), so text indexes can return wrong
results and unique indexes can accept duplicates.

Such a cluster now stays on its image until a pre-upgrade hook, run from
that image, finds nothing stored that depends on a collation other than C,
POSIX or builtin. The hook records clean, affected or unknown on the
Cluster; anything but clean holds the cluster, so a check that cannot
finish keeps it where it is rather than letting it move unchecked. Helm
renders before hooks run, so the hook fails an attempt only when its
answer contradicts what that attempt rendered, and the retry follows the
answer. allowCollationChange moves a held cluster on the owner's terms, and
a held cluster refuses a change of version, since new majors are built only
on the new images.

A physical restore replaces the Cluster that carries the answer. The CNPG
backup driver records the source Cluster's image in the backup snapshot and
passes it on as bootstrap.sourceImageName without interpreting it; the
chart restores onto it only when it is one of the bullseye tags it shipped,
and the next upgrade checks the restored data.

Assisted-By: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-27 18:21:43 +07:00
myasnikovdaniil fc2da5810f Merge commit from fork
fix(monitoring): give Alerta a real signing key and its own admin password
2026-11-27 14:47:20 +05:00
Myasnikov Daniil 74ac18e042 feat(apps): mark objects whose children exclude each other atomic
The worker image of a node pool takes one of builtin and factory, a
vm-disk source one of disk, http, image and upload, and the oidc
customConfig of a kubernetes cluster and of a monitoring stack one of
config and secretRef, and each chart refuses a spec that sets two. An
installation default for one child merged into an application that
chose another built exactly that spec, and nothing warned at create
time. The x-kubernetes-map-type: atomic marker makes the defaults
merge replace the object whole. Nothing else reads it, so existing
applications render as before.

The marker stays off objects whose fields must be set together or sit
beside independent fields, where replacing the object whole would drop
a default the user did not mean to override. The chart guide says when
to use it and when not to.

The tests run the merge against the four real schemas, and one more
pins that a pair like resources cpu and memory still merges field by
field.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-27 07:39:01 +00:00
Timofei Larkin 9f00135618 feat(api): add EndpointAttachment to attach addresses to app endpoints
A managed application's tenant-facing Services are its endpoints, and
the only way to publish one externally has been the chart boolean
`external`, which publishes one chart-chosen endpoint on one address
from no particular pool through five different render paths.
EndpointAttachment attaches one address, minted from an IPAddressClass
or bound from a reserved IPAddressClaim, to one tenant-facing Service by
rendering an additive LoadBalancer Service that mirrors the endpoint's
selector and ports. The mechanism therefore needs no per-engine render
knowledge and never touches the application's own objects, and a
reserved address survives every attachment and moves between
applications. The Service carries the loadBalancerClass the claim's
class reports in status, so it reaches the load balancer that owns the
class's pool; since a Service's loadBalancerClass is immutable, nothing
new is rendered before the class's provisioner accepts the class for its
current generation. The rendered Service asks for the claim's IP
families, since one left to the cluster's primary family cannot be
assigned an address of the other.

The endpoint check requires both the lineage labels and the
tenantresource marker: lineage alone also covers operator-internal
Services. A LoadBalancer Service a tenant Kubernetes cluster's
cloud-controller-manager creates carries the cluster's labels and the
marker too, so the cluster.x-k8s.io/tenant-service-name label it writes
excludes it. Identity is by owner reference throughout, so a Service
carrying the ownership label without the reference is never adopted,
and a same-name recreated application does not inherit the previous
incarnation's attachments.

The VM datapath modes render the cozy-proxy Service contract unchanged
and are gated on a platform declaration rather than CNI detection: a
proxy skips a Service delegated to a name it does not claim while the
load balancer still attracts the address. Exclusivity is keyed on the
backend pod in both modes because cozy-proxy's egress map holds one
address per pod, and holds IPv4 only, so a method attachment off a VPC
refuses an IPv6 or Dual claim. A delegation no attachment renders, such
as a chart Service with external: true, always takes the pod, since
nothing would ever withdraw it; between attachments the oldest wins. A
whole-IP attachment with several ready backends keeps its address dark
instead of picking one.

A cozyplane VPC changes that for whole-IP: the VM's only interface is
in the VPC, so the launcher pod address a cozy-proxy Service maps to
never reaches it. Where a backend pod carries the VM chart's
sdn.cozystack.io/vpc annotation and the cluster serves cozyplane's
FloatingIP, the attachment owns a FloatingIP on the VM's VPC address
wearing its claim instead, and mirrors its readiness once its status
is for its current generation: a re-pointed FloatingIP keeps the old
target's status until cozyplane observes the change. FloatingIP is
read as unstructured and used only when served, so the controller
keeps no dependency on cozyplane. A live migration's two launcher pods
share the VM's VPC address and count as one target, and a stopped VM
keeps its binding rather than flipping to a cozy-proxy Service. Only
a backend pod says whether a VM is in a VPC, so a method attachment
that has published nothing yet waits for one; otherwise an attachment
created before its VM starts would pin the claim to a cozy-proxy
Service first.
PortList is refused there: a FloatingIP binds every port and cozy-proxy
cannot reach the VPC address. So is a Dual claim, since a FloatingIP
wears one address. The kube-ovn VPC keeps the pod-network
interface and adds VPC subnets as secondary interfaces, so the
cozy-proxy path still delivers to the VM there.

The e2e suite is the only one that needs the address substrate, so it
owns both of its optional packages in test selection: the e2e install
enables them, a selection that leaves the suite out disables them, and
post-install prep gives the sandbox a default IPAddressClass on a pool
MetalLB does not auto-assign from. The cozyplane VPC suite stays
parked, because no e2e lane installs that networking variant.

The kind lives in local.sdn.cozystack.io, the CRD-served half of the
sdn family the address substrate and cozyplane share, so stock
ResourceQuota counts keep working.

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-27 08:33:56 +01:00
Timofei Larkin b9bc88d053 feat(address-controller): update to v0.3.0
address-controller v0.3.0 gives IPAddressClass a status: the class's
provisioner reports the loadBalancerClass a Service consuming one of
its claims must carry in status.loadBalancerClass, and sets an
Accepted condition for the class's generation. The value means
something only while Accepted is True, and auto-claim waits for it.
metallb-iad v0.3.0 writes that status (its --lb-class, empty for the
cluster default), sets Accepted to False with reason PoolRefused when
the class's pool is unusable, and requires the v0.3.0 CRD, so the two
move together.

Cozystack runs metallb-iad with an empty --lb-class, and its classes
name a pool, so this upgrades in place. The driver's ClusterRole and
binding are named after the release namespace, which Helm handles on
upgrade.

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-27 08:33:47 +01:00
Andrei Kvapil bcba5d349a security(monitoring): reset the Alerta admin password on every start
The entrypoint creates admin users only when they are missing, so an
admin user created before Alerta had a password of its own keeps the
Grafana password, which stays valid after an operator rotates Grafana's.
The respin runs a step right after user creation that sets every admin
user's password to ADMIN_PASSWORD, and stops the container if it fails.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-27 05:39:18 +01:00
Andrei Kvapil 68b0e80d17 security(monitoring): show tenants Alerta's login apart from its keys
Tenants logged in to the Alerta UI with the Grafana credentials, the
only Secret of the release they are shown. With Alerta on a password of
its own, that password moves to a Secret that holds nothing but the
login, listed for tenants next to Grafana's, so the signing key and the
API key in the alerta Secret stay hidden. The alerta Secret is now
rendered under data alone.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-27 05:39:18 +01:00
Andrei Kvapil 8942c7dfcc security(monitoring): keep Alerta credentials out of its container log
The upstream Alerta entrypoint prints the whole environment, including
the admin password and API key, and echoes the admin API keys it
creates, while nginx logs the request line where Alertmanager passes
the key as a query parameter. Pod logs are readable at lower tenant
tiers than the credentials themselves.

The respin drops the environment dump, silences key creation and masks
the api-key parameter in the access log. Each edit is checked during
the build, so an upstream change to either file fails the image build
rather than bringing the output back.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-27 04:49:30 +01:00
Andrei Kvapil 40525fc756 security(harbor): give the inner registry its own credential and port policy
The Harbor application never set a credential for the registry that
Harbor core and jobservice talk to, so the vendored chart's published
default applied, and the registry Service accepted it from any pod the
tenant network policies let through. That bypasses Harbor's own
authorisation, quotas and audit log.

Each release now gets a random registry password with a matching
htpasswd line, kept in a Secret that stays out of the tenant-visible
allowlist and is reused across upgrades so the bcrypt salt does not
restart the registry on every reconcile. An existing installation
rotates on upgrade: core, jobservice and registry roll together because
their Secret checksums change; registry storage is untouched.

The inner chart also ships a CiliumNetworkPolicy that denies the
registry and registryctl ports to everything but core, jobservice and
trivy of the same release. A deny is needed because the tenant base
policy already allows the traffic and Cilium allow rules are additive.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-27 04:21:57 +01:00
Aleksei Sviridkin bcba1a0bfb fix(seaweedfs): keep the masters on separate nodes through a drain (#4947)
## What this PR does

SeaweedFS masters can end up on the same node after a drain, leaving two
of the three raft members on one failure domain. A hard hostname spread
makes the replacement wait for the drained node, or use a spare node.

The SeaweedFS app now exposes `master.topologySpreadPolicy`: `hard` is
the default; `soft` removes the hard spread and keeps the preferred
anti-affinity. Use `soft` before upgrading a cluster where a tainted
node counts toward the spread but cannot run a master. On a two-node
cluster, draining the node with two masters leaves both Pending with the
hard policy.

## Validation

All 252 Helm tests across the app and system charts pass. Generated app
schema, API types, resource definition and README are current. The
fail-closed test guard passes. The new opt-out has not had an e2e run.

## Downstream repositories

No separate downstream change is required. The app value, schema, API
and documentation are generated in this repository.

## Release note

```release-note
fix(seaweedfs): SeaweedFS masters now wait for a drained node instead of starting next to another master. The new master.topologySpreadPolicy app setting defaults to hard. Set it to soft before upgrading when tainted or otherwise unusable nodes would leave a master Pending; soft keeps the preferred anti-affinity. With hard placement, draining the node that holds two masters in a two-node cluster leaves both Pending until it returns.
```


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

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

## Summary by CodeRabbit

* **New Features**
* SeaweedFS master placement now defaults to a hard spreading policy,
enforcing one master per node when enough schedulable nodes are
available.
* Set the policy to `soft` to allow masters to share nodes while
preferring to keep them separate.
* **Documentation**
* Added guidance on the scheduling trade-offs, including how hard
spreading accounts for nodes where masters cannot run.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-27 04:59:01 +03:00
Aleksei Sviridkin 6aa33e379e feat(monitoring): alert when a namespace stays in Terminating (#5040)
## What this PR does

On a cluster running v1.6.5 a tenant namespace that was deleted
directly, not through the Tenant app, stayed in `Terminating` for about
28 hours, held by the Kamaji finalizers described in #5002. Nothing
alerted on the namespace itself. The only signal was
`HelmReleaseNotReady` of the tenant release, which kept flapping.
kube-state-metrics already exports `kube_namespace_status_phase` and
`dashboards/main/capacity-planning.json` reads it, but no alert rule in
the repo does.

This adds `KubeNamespaceStuckTerminating`, a warning in a new
`namespace-deletion` group under
`packages/system/monitoring-agents/alerts/`. It fires when `max by
(cluster, namespace)
(kube_namespace_status_phase{job="kube-state-metrics",
phase="Terminating"}) == 1` has held for 30 minutes. kube-state-metrics
exports a `Terminating` series for every namespace, 0 while the
namespace is active and 1 while it is being deleted
([namespace.go#L109-L135](https://github.com/kubernetes/kube-state-metrics/blob/v2.15.0/internal/store/namespace.go#L109-L135)).
The scrape adds the node and pod of the kube-state-metrics pod as target
labels, so the rule groups by cluster and namespace and its timer keeps
running through a kube-state-metrics rollout to another node. A gap in
the series, for example while kube-state-metrics is down, starts the 30
minutes over. The description names the namespace and the cluster and
points at the namespace status conditions, which list the remaining
resource types and finalizers
([status_condition_utils.go#L101-L140](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/controller/namespace/deletion/status_condition_utils.go#L101-L140)).

Why 30 minutes. Healthy tenant deletions we watched on current versions
took under a minute from the delete request until the namespace was
gone, 61 of 61, and about 5 minutes for a tenant with a Kubernetes
cluster, a VM and Postgres inside. The namespace itself spent under a
minute in `Terminating` in every one of them. 30 minutes leaves wide
room and still reports a stuck namespace within the hour.

`hack/namespace-deletion-alerts.bats` replays `.spec` of the VMRule
through `vmalert-tool` v1.136.0 pinned by digest, the same harness as
#4963, #4985 and #4993.
`hack/testdata/namespace-deletion-alerts/unittest.yaml` has 5 cases with
11 checks. A namespace in `Terminating` is quiet at 29 minutes and fires
at 35, with labels and annotations pinned. A namespace deleted after 20
minutes in `Terminating` stays quiet at 19, 35 and 60 minutes, and an
active namespace stays quiet. When kube-state-metrics moves to another
node 15 minutes in, the alert still fires at 31 minutes. The same
namespace name in two clusters gives one alert per cluster, each with
its own timer.

```console
$ bats hack/namespace-deletion-alerts.bats
1..1
ok 1 namespace deletion alerts pass their vmalert-tool cases
```

With the expression replaced by `vector(1) == 0` the suite prints `not
ok 1` and vmalert-tool fails the 4 checks that expect an alert. On main,
where the rule file does not exist, the suite fails too. Each of the
following rule changes fails at least one check. They are `for: 15m`,
`for: 45m`, no `== 1`, `sum by` instead of `max by`, which only the
kube-state-metrics move catches, no `cluster` in the grouping,
`phase="Active"`, no aggregation, another severity and another
description.

With Bats 1.14.0 at the commit CI pins and Helm 3.17.3 on `PATH`, 18
suites pass with 325 of 325 tests, the new one together with
`alert-severity-contract`, `bats-strict-setup`, `bats-runner-coverage`,
`bats-runner-contract`, `unit-test-parallelism`, `image-pin-consistency`
and `check-commit-trailers` among others. The severity contract lists
the new alert as `warning`. helm-unittest 1.1.2 passes the
monitoring-agents chart with 19 of 19 tests, and `helm template` renders
the VMRule the same as the file. Like the migration suites, the new
suite needs docker. I have not run the rule in vmalert on a live
cluster.

The release-1.6 backport is a separate PR with one more commit that
drops the `load test_helper` line, because release-1.6 runs
`hack/*.bats` through `hack/cozytest.sh`.

### Screenshots

Not a UI change.

### Downstream repositories

A new alert file under `packages/system/monitoring-agents/alerts/`, a
Bats suite under `hack/` and its test data. No values, schema, README,
image or `ApplicationDefinition` change, and the website does not list
platform alerts by name, so no trigger map entry applies.

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

### Release note

```release-note
feat(monitoring): new warning alert KubeNamespaceStuckTerminating fires when a namespace has been in phase Terminating for more than 30 minutes.
```


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

## Summary by CodeRabbit

- **New Features**
- Added an alert for Kubernetes namespaces that remain in the
`Terminating` phase for more than 30 minutes.
- Alerts identify the affected cluster and namespace and note that
remaining finalizers may be preventing deletion.

- **Tests**
- Added coverage for deletion timing, active namespaces, node changes
during termination, and identically named namespaces across clusters.
Test cases verify expected alert labels and annotations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-27 03:40:22 +03:00
Andrei Kvapil d99a1a063e fix(monitoring): give Alerta a real signing key and its own admin password
Alerta signs its session JWTs with SECRET_KEY, but the upstream image never
wires a real value into it: the entrypoint renders the generated key into
alertad.conf under the name SECRET (which the application never reads) and
unsets SECRET_KEY before exec, so at runtime the built-in default from
alerta.settings ("changeme") signs and verifies every token. Anyone can mint
a valid admin token without credentials.

Alerta's admin account also reused Grafana's credentials
(grafana-admin-password), and Alerta exposes the whole process environment via
/api/management/properties to any admin-scoped caller, so admin on Alerta
yielded Grafana's admin password.

Generate a strong SECRET_KEY and a dedicated admin password, persist both in
the alerta Secret so they survive upgrades and restarts, feed the key to the
application through a mounted alertad.conf under the name it actually reads,
and stop referencing grafana-admin-password. Add a unittest covering the key,
the mount and the credential decoupling.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-27 01:26:22 +01:00
Aleksei Sviridkin 7be083a5a7 feat(harbor): expose replicas and zone spread for the request path (#4880)
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- If it's a work in progress, consider creating this PR as a draft.
-->

## What this PR does

Closes #4824.

Every `docker login`, pull and push goes through nginx → core
(`/service/token`) → registry, and each of them ran as a single pod.
Losing the node that hosted one stopped all registry traffic, however
many PostgreSQL and Redis instances backed it. The vendored goharbor
chart already scales these components and the registry keeps its blobs
in S3, so only the wrapper was missing the knobs.

**Request path (`packages/apps/harbor`)**

- New `nginx.replicas`, `portal.replicas`, `core.replicas` and
`registry.replicas`, all defaulting to `1`.
- Above one replica, the wrapper forwards to the upstream chart a
`podDisruptionBudget` with `maxUnavailable: 1` and
`topologySpreadConstraints`. Upstream defaults `minAvailable` to 1 and
renders whichever of the two fields is set, and the API server rejects a
PDB carrying both, so the wrapper forwards `minAvailable: 0` to drop it.
- At one replica nothing but `replicas: 1` is forwarded, which is the
upstream default, so an existing install renders the same Deployments as
before.
- The `WorkloadMonitor`s for core, registry and portal take `replicas`
from the values instead of a hard-coded `1`. `minReplicas` stays at 1,
since one serving replica is enough for the component to work.

- The spread follows the platform's
`scheduling.globalAppTopologySpreadConstraints` (read from
`_cluster.scheduling`), as postgres, etcd, keycloak, grafana and
kubernetes-nodes already do, so the cluster operator sets the policy
once. When the platform sets none, a soft spread stands in: zone then
hostname, both `ScheduleAnyway`, so a cluster without zone labels or
with fewer nodes than replicas still schedules every replica. Any
`labelSelector` in the policy is dropped, because the upstream chart
appends its own `release`/`app`/`component` selector to every entry.

**Data tier (`packages/system/harbor`)**

- The CNPG `Cluster` (when `database.replicas > 1`) gets
`topologySpreadConstraints` from the same platform policy, or a
`ScheduleAnyway` zone spread when the platform sets none; CNPG's default
anti-affinity handles nodes. The Redis pods and sentinels already spread
hard per node on main (#4990); this adds a `ScheduleAnyway` zone spread
on top of that default. A constraint in the platform policy without a
selector gets the component's own; a selector the policy sets is kept,
as in the keycloak chart.

**Deviations from the issue, on purpose**

- Placement follows the platform-wide
`globalAppTopologySpreadConstraints` instead of a set of rules
hard-coded in Harbor, to stay consistent with the other applications.
The fallback spreads across nodes with a `topologySpreadConstraints`
entry rather than a preferred `podAntiAffinity` term: the upstream chart
appends its own selector to spread entries, while an affinity term is
passed through verbatim and would have to hard-code that label set in
the wrapper.
- On the data tier the zone spread goes through
`topologySpreadConstraints`, not `affinity.topologyKey:
topology.kubernetes.io/zone`. Moving CNPG's `topologyKey` to the zone
would drop its per-node anti-affinity, so instances could share a node
on a cluster without zone labels. With spread constraints the two add
up, and for Redis the zone entry sits beside the per-node one.
- `jobservice.replicas` (item 5 of the issue, which needs `jobLoggers:
[database]`) is left for a follow-up, as the issue suggests.

**Upgrade impact**

- Request path: none at the default replica count.
- Data tier: `database.replicas` and `redis.replicas` default to 2, so
on upgrade most installs see a one-off rolling restart of the CNPG
instances (with a switchover), of the Redis pods and of the sentinels,
as their pod spec gains the spread constraint. Where the platform policy
uses `DoNotSchedule`, it is now enforced for Harbor pods too, as it
already is for the other applications.

**Tests**

- `packages/apps/harbor/tests/replica_placement_test.yaml`: defaults
forward nothing beyond `replicas: 1`; above one replica the PDB and
spread are forwarded; the platform policy replaces the fallback and
loses its `labelSelector`, and is ignored at one replica; components
scale independently; `registry.replicas` lands at the Deployment level,
not under `registry.registry`; WorkloadMonitors follow the values.
- `packages/system/harbor/tests/zone_spread_test.yaml`: CNPG, Redis and
sentinel spread with the right selectors and no `affinity` override,
both with the fallback and with a multi-entry platform policy, keeping a
selector the policy sets; `redis_spread_test.yaml` covers the per-node
default with the zone entry on top; and, rendering the vendored chart
with the values the wrapper forwards, the PDB carries `maxUnavailable`
alone and the spread entries are scoped to the component's pods.
- Checked that the tests fail with the fix removed (helper without
`minAvailable: 0`, upstream PDB without the zeroing, CNPG spread
removed, platform policy ignored). `helm unittest` on both charts: 72/72
passing. Also rendered the app chart, with and without a platform
policy, fed its HelmRelease values into the system chart, and checked
the resulting Deployments, PDBs and CNPG `Cluster`.

### Screenshots

No UI change.

### Downstream repositories

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: cozystack/terraform-provider-cozystack#70 (issue: the
provider models Harbor by hand)
- [ ]
[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 adds fields to the `harbor` app's `values.schema.json`, which
the Terraform provider models by hand, so a follow-up issue is open
there. The website reference page is regenerated from the README on
release, and no other trigger in the map matches the diff.

### Release note

```release-note
feat(harbor): nginx, portal, core and registry now take a `replicas` value. Above one replica they get a PodDisruptionBudget and follow the platform's `globalAppTopologySpreadConstraints`, or a best-effort spread across zones and nodes when none is set, so draining or losing a node or zone keeps docker login, pull and push working. The PostgreSQL and Redis instances and the Redis sentinels now follow the same policy, or a best-effort zone spread; on upgrade this causes a one-off rolling restart of the database and Redis pods.
```


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

## Summary by CodeRabbit

* **New Features**
* Harbor NGINX, portal, core, and registry replica counts are
configurable and default to one. Above one replica, these components use
a PodDisruptionBudget and follow platform-wide placement settings when
available, or spread across zones and nodes otherwise.
* Database replicas spread according to placement settings when
configured above one. Redis replicas also spread above one, while all
three Redis sentinels are always spread.
* Core and registry resource settings now use a shared default when not
specified.
* **Documentation**
* Harbor configuration guidance now describes replica settings,
placement behavior, and PodDisruptionBudget behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-27 01:52:06 +03:00
Timofei Larkin c797803dd7 feat(vm-instance): keep a cozyplane VM's IP and MAC (#5389)
## What this PR does

It bumps cozyplane to v0.1.5 and has a cozyplane `vm-instance` VM hold
its Port through a `PortClaim`, so the VM keeps its IP and MAC across
restarts and live migrations.

Without a claim, a VM's Port is garbage-collected when its launcher pod
goes away, and the next launcher pod gets a new IP and a random MAC. A
guest whose network config is pinned to the old MAC then matches no
interface and loses its network. lllamnyp/cozyplane#79 (released in
v0.1.3) fixes this without special-casing KubeVirt. A namespaced
`PortClaim` in `sdn.cozystack.io` holds a cluster-scoped `Port` the way
a PVC holds a PV, and a pod binds it with the annotation
`sdn.cozystack.io/port-claim: <name>`, resolved in the pod's own
namespace. The claim keeps its IP and MAC for as long as it exists: a
stopped VM keeps its address reserved, and deleting the claim frees it.

- **cozyplane v0.1.5.** `cozyplane`, `cozyplane-kpr` and
`cozyplane-apiserver` are re-vendored with `make update` at `b99171ea7`
(tag `v0.1.5`). Beyond v0.1.3's PortClaim, it carries
lllamnyp/cozyplane#80, so a PortClaim that adopts a running VM's Port
keeps it bound to the pod already holding it and reports `Bound=True`
with reason `PreClaimPod`. It also carries lllamnyp/cozyplane#81: the
aggregated apiserver sets `metadata.generation` and the controllers
stamp `observedGeneration`, so a retargeted FloatingIP no longer keeps
its old target's status. The wrappers pin the release images by tag and
digest:
-
`ghcr.io/lllamnyp/cozyplane:v0.1.5@sha256:2cc55293000b64a4c4233910cbc3803b9bea7c16e9e7d44ddcc44fb4042cdd98`
-
`ghcr.io/lllamnyp/cozyplane-kpr:v0.1.5@sha256:28254bdc0283b3797ea8c5f26146932c46b0be98a15cdd660cb42330963cb01c`

The aggregated apiserver serves `PortClaim` from the same binary, and
its chart changes only in the image pin. The CNI chart gains the agent's
and controller's PortClaim RBAC, and its tenant roles gain `portclaims`.
- **`vm-instance`.** A VM that joins a VPC through `networks` renders a
`PortClaim` named after the VM, with `spec.vpcRef` set to the VM's VPC,
and annotates its pod template with `sdn.cozystack.io/port-claim: <VM
name>` next to `sdn.cozystack.io/vpc`. The name matters: cozyplane
adopts a running VM's existing Port into a claim named after that VM, so
running VMs keep their IP and MAC through the upgrade. Without a VPC, or
on kube-ovn, nothing changes.
- **RBAC.** No change is needed. Releases are applied by the same
identity that already applies the VPC application's `sdn.cozystack.io`
objects. Tenants reach `portclaims` through cozyplane's own tenant
roles, which `cozy:tenant:cozyplane-edit` and `-view` (#3149) already
aggregate into the `cozy:tenant*` tiers: every access level can read
claims, and admins can manage them.

### Compatibility

The bump and the chart change have to land together. From v0.1.3 a VM
with no claim gets a new IP and MAC on every launcher pod, live
migration included.

**Upgrading running VMs.** A VM adopted while it was running gets a new
IP and loses its network if it is live-migrated before a restart. Such a
VM's claim shows `Bound=True` with reason `PreClaimPod`, and the VM is
marked `RestartRequired`; restart it before migrating it.

**Tenant Kubernetes worker VMs are not covered.** `kubernetes-nodes` is
unchanged, so from v0.1.3 a tenant cluster's worker VMs keep no IP or
MAC across restarts or live migrations.

A PortClaim's spec is immutable. Changing `networks[0].name` on an
existing VM therefore fails the release upgrade at the claim, instead of
moving the VM to another VPC as it did before.

### Tests

The new helm-unittest suite `vm-instance/tests/portclaim_test.yaml`
covers a VPC VM (one claim named after the VM, its `vpcRef`, no `mac`,
and the pod-template annotation), cozyplane with no VPC (no claim, no
annotation), and kube-ovn (no claim, no annotation). The `vm-instance`,
cozyplane wrapper, kubernetes, kubernetes-nodes and platform suites
pass.

### Downstream repositories

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

Boxes left unticked so a human decides.

### Release note

```release-note
feat(vm-instance): on the cozyplane networking variant, a VM in a VPC keeps its IP and MAC across restarts and live migrations through a PortClaim; cozyplane is bumped to v0.1.5
```

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

## Summary by CodeRabbit

* **New Features**
* VMs configured with supported VPC networks now receive a port claim
that launcher pods can use to bind to the selected network.
* Tenant roles now support viewing and managing port claims, with access
appropriate to each role.
* **Updates**
* Cozyplane components are updated to version 0.1.4, including the API
server and Kubernetes provider. These updates include revised support
for port claims.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-26 22:19:37 +03:00
Timofei Larkin f17cd76d5e feat(cozyplane): bump to the v0.1.5 release
v0.1.5 adds the PortClaim kind: a pod naming a claim in its
sdn.cozystack.io/port-claim annotation keeps the claim's IP and MAC
across launcher pods. A claim that adopts a running VM's Port keeps it
bound to the pod already holding it and reports Bound=True with reason
PreClaimPod. Without a claim a VM now gets a new IP and MAC on every
launcher pod, live migration included, so vm-instance claims one in the
next commit. The aggregated apiserver now sets metadata.generation, and
the controllers stamp observedGeneration, so a retargeted FloatingIP no
longer keeps its old target's status. The vendored charts pin a main
build, so the wrappers keep pinning the release images by tag and
digest.

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-26 16:11:47 +01:00
Myasnikov Daniil ecb2576239 feat(dashboard): start the order form from one server dry-run
The form took its defaults from the schema in the browser, which
cannot see the installation defaults the API now applies on create,
so it could show values the created application would not have. The
page sends one dry-run create when it opens and fills the form and
the YAML editor from the spec the server returns.

There are no further previews while the user edits. A preview that
fails, or gets no answer within 8 seconds, opens the form without
installation values and shows a notice with Retry. Deploy still works
then, because the real create applies the defaults itself.

After a failed preview a dropdown stays empty instead of selecting the
cluster's default option: a value the user did not choose would be sent
and win over the platform default the API applies to omitted fields. A
cleared plain text field leaves its key out, as it did before, so
clearing a field still resets it.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-26 14:20:06 +00:00
Myasnikov Daniil 77d8bf5001 feat(api): apply installation defaults when creating applications
Defaults set by the administrator have to reach every application
kind, including ones from external catalogs, and give the same result
for the dashboard, Terraform and kubectl, so the merge runs in the API
server on create instead of in each client.

User values win over installation defaults, which win over the
developer defaults of the chart. Only objects with declared properties
merge recursively. Arrays, dictionaries and free-form objects are
replaced whole, so a pool that sets its own registry mirrors never
receives the platform entries. The entry is checked against the
application's OpenAPI schema before merging. CEL rules are left out of
that check, since a rule such as an immutability test has no meaning
on a partial object.

The ConfigMap is read through a cache limited to that one object, so
the API does not hold a watch on every ConfigMap in the cluster. A
missing ConfigMap means no defaults. One that cannot be read, or an
invalid configuration or entry, skips the defaults and the create goes
on with a warning, because a configuration mistake must not stop
applications from being created. Updates never apply defaults. The
ConfigMap rule the API already has covers the read, and its comment
now names this second user.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-26 14:20:05 +00:00
myasnikovdaniil c51ea43fee chore(deps): update module golang.org/x/net to v0.62.0 [security] (#4822)
This PR contains the following updates:

| Package | Change |
[Age](https://docs.renovatebot.com/merge-confidence/) |
[Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [golang.org/x/net](https://pkg.go.dev/golang.org/x/net) | [`v0.61.0` →
`v0.62.0`](https://cs.opensource.google/go/x/net/+/refs/tags/v0.61.0...refs/tags/v0.62.0)
|
![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fnet/v0.62.0?slim=true)
|
![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fnet/v0.61.0/v0.62.0?slim=true)
|

---

### Avoid quadratic complexity when coalescing text nodes in html in
golang.org/x/net
[CVE-2026-78661](https://nvd.nist.gov/vuln/detail/CVE-2026-78661) /
[GO-2026-6860](https://pkg.go.dev/vuln/GO-2026-6860)

<details>
<summary>More information</summary>

#### Details
When coalescing adjacent text nodes in addText and fosterParent,
appending to an existing TextNode's Data via string concatenation
(n.Data += text) reallocated and copied the accumulated string on every
token. Inputs containing many short text runs separated by ignored end
tags (such as "a</x>") caused O(n^2) allocations and byte copies.

Accumulate coalesced text in per-node byte slices during parsing and
materialize Data strings once at the end of parse.

#### Severity
Unknown

#### References
- [https://go.dev/cl/849365](https://go.dev/cl/849365)
- [https://go.dev/issue/82224](https://go.dev/issue/82224)
-
[https://groups.google.com/g/golang-announce/c/sqrs2vTx_Xs](https://groups.google.com/g/golang-announce/c/sqrs2vTx_Xs)

This data is provided by
[OSV](https://osv.dev/vulnerability/GO-2026-6860) and the [Go
Vulnerability Database](https://redirect.github.com/golang/vulndb)
([CC-BY 4.0](https://redirect.github.com/golang/vulndb#license)).
</details>

---

### Check all ancestor namespace transitions when rendering raw text in
html in golang.org/x/net
[CVE-2026-97045](https://nvd.nist.gov/vuln/detail/CVE-2026-97045) /
[GO-2026-6866](https://pkg.go.dev/vuln/GO-2026-6866)

<details>
<summary>More information</summary>

#### Details
In childTextNodesAreLiteral, walking up the tree previously stopped at
the nearest foreign ancestor once an HTML integration point was found.
However, that integration point may itself be a descendant of an element
that was foster-parented into a foreign namespace (such as <mglyph> or
<malignmark> fostered under <mtext>), causing a parser to resolve the
subtree in a different foreign namespace upon re-parsing the rendered
output.

Continue walking the full ancestor chain and verify that every
transition from a non-empty namespace occurs at an HTML integration
point before emitting literal text.

#### Severity
Unknown

#### References
- [https://go.dev/cl/855121](https://go.dev/cl/855121)
- [https://go.dev/issue/82622](https://go.dev/issue/82622)
-
[https://groups.google.com/g/golang-announce/c/sqrs2vTx_Xs](https://groups.google.com/g/golang-announce/c/sqrs2vTx_Xs)

This data is provided by
[OSV](https://osv.dev/vulnerability/GO-2026-6866) and the [Go
Vulnerability Database](https://redirect.github.com/golang/vulndb)
([CC-BY 4.0](https://redirect.github.com/golang/vulndb#license)).
</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/cozystack/cozystack).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xMzQuMSIsInVwZGF0ZWRJblZlciI6IjQ0LjI0OS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWF0ZWQiLCJzZWN1cml0eSJdfQ==-->
2026-11-26 19:13:43 +05:00
Timofei Larkin 64cd55a161 feat(kubernetes): run tenant clusters inside a cozyplane VPC (#5337)
## What this PR does

Stacked on #4508 (VMs in a cozyplane VPC). This layer runs a whole
tenant Kubernetes cluster inside a VPC: the control plane, its etcd and
the worker VMs. The `Kubernetes` cluster and each of its
`KubernetesNodes` pools set the same `network: {name: <VPC catalog
name>}`.

A VPC refuses cluster-internal destinations, so the workers, the
tenant's own pods and the konnectivity agents all need an apiserver
address inside the VPC. The platform side keeps working unchanged: it
reaches VPC pods by their fabric IPs and through ClusterIPs that resolve
to them. That covers Kamaji, CAPI, kccm, the cluster autoscaler, the
chart's Jobs, the ingress passthrough, and the `super-admin.svc`
kubeconfig Flux installs the tenant addons with.

**Control plane.** `network.name` on the `Kubernetes` cluster does three
things:
- puts the apiserver pods in the VPC
(`deployment.podAdditionalMetadata`);
- attaches their Service to it (`network.serviceAnnotations`), so that
inside the VPC the resolver answers the Service's name with a VIP from
the VPC's own range;
- stamps the cluster's own etcd through the `annotations` key of
`cozy-lib.etcd.cluster`. etcd-operator copies that annotation onto the
member Pods and both etcd Services, so the apiserver reaches its
DataStore entirely inside the VPC.

**Advertise address.** Kamaji's `advertiseAddress` is what the tenant's
`kubernetes` endpoints and the konnectivity agents dial, and its CRD
requires an IP. The right IP is the apiserver Service's VIP, which only
a pod inside the VPC can learn. In VPC mode each pool's talos-reconcile
Job starts a short-lived probe pod in the VPC. The probe resolves the
Service's FQDN and writes the answer to its termination message. The Job
reads that back with a namespaced pod `get`, patches `advertiseAddress`
(Kamaji adds it to the apiserver certificate itself), and uses the VIP
for the workers' `extraHostEntries` in place of the ClusterIP. This
happens before the pool's TalosConfigTemplate is applied, so Kamaji's
one rollout runs while the cluster has no workers yet. The Job's Role
gains `create` on pods plus `get`/`delete` on the probe pod by name, in
VPC mode only.

**Workers.** Each pool stamps `sdn.cozystack.io/vpc` on its worker VM
template, only when set, because the KubevirtMachineTemplate is
content-hash named.

**Route table.** A pool can also name a cozyplane RouteTable with
`routeTable` (a DNS-1123 name, empty by default), the same contract as
`vm-instance`'s value in #4508. When it is set, the pool renders
`sdn.cozystack.io/route-table: <routeTable>` on its worker VM template
next to `sdn.cozystack.io/vpc`, and setting or changing it rolls the
pool's workers, as `network` does. Empty renders nothing, which leaves
the VPC's default table in effect. The render fails with `routeTable` on
a cluster that does not serve `sdn.cozystack.io`, on `substrate:
proxmox`, or without `network.name`. The control plane keeps the VPC's
default table.

**Guards**, all unit-tested. The cluster refuses `network.name`:
- where `sdn.cozystack.io` is not served;
- on the proxmox substrate;
- on the tenant's shared DataStore;
- on a running cluster outside that VPC, in either direction, because
etcd-operator never re-stamps a running member.

A pool refuses a network that differs from its control plane's, again in
either direction, checked against the live apiserver Service.

Design notes:
- **The probe is interim.** A request for cozyplane to report an
attached Service's VIP on the Service itself (`sdn.cozystack.io/vpc-ip`,
the same annotation the CNI stamps on pods) is going to upstream. Once
it ships, the Job reads the annotation and the probe goes away.
- **The rejected alternative is a LoadBalancer.** Publishing the
apiserver Service and reaching it through the VPC gateway's NAT spends a
published address per cluster and makes NAT a dependency of the control
path.

Not verified on a live stand yet:
- the probe's resolution through the VPC resolver;
- worker bootstrap and konnectivity through the VIP;
- etcd member peering inside the VPC;
- OIDC mode, where the apiserver dials Keycloak's internal URL from
inside the VPC.

### Screenshots

Not a UI change.

### Downstream repositories

Walked the trigger map against the diff. terraform-provider-cozystack
models app fields by hand, so the new `network` (both apps) and
`routeTable` (KubernetesNodes) fields need its schema, model and
expand/flatten; that is cozystack/terraform-provider-cozystack#90. The
website's reference pages for kubernetes and kubernetes-nodes are
regenerated from their READMEs on release, and both apps are in the
website's app lists, so no follow-up is needed there. Nothing else in
the map is touched.

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: cozystack/terraform-provider-cozystack#90
- [ ]
[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): on the cozyplane networking variant, a tenant Kubernetes cluster can run entirely inside a VPC — network.name puts its control plane, its own etcd and its worker VMs in the VirtualPrivateCloud
```

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

## Summary by CodeRabbit

* **New Features**
* Kubernetes clusters now use dedicated etcd by default, with
configurable one- or three-member setups and storage options. Existing
clusters using shared etcd retain their current configuration.
* Clusters and worker pools can join a cozyplane VPC, subject to
platform and compatibility requirements. Changing a worker pool’s
network rolls its worker VMs.
  * Cluster status notes now identify the etcd configuration in use.

* **Bug Fixes**
* Enabled Kubernetes add-ons and supporting services can render
independently of tenant-shared etcd availability.
  * Cluster cleanup now handles dedicated etcd resources.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-26 16:24:28 +03:00
Timofei Larkin 94c79925f8 feat(api): add the credentials API with mint and revoke subresources (#4921)
## What this PR does

Tenants read application passwords from Secrets today, and a leaked
password can't be taken back. This PR adds the platform side of the user
secrets API design (cozystack/community#137, ADR 0002): a password comes
out once from a mint, the next mint replaces it, and a revoke kills it.
The engines are converted in the PRs stacked on top, starting with
Postgres in #4922.

How it works:

- A kind's chart renders one `CredentialTemplate`
(`cozystack.io/v1alpha1`) per account: the username, the stored format
(`scram-sha-256`, `mysql-native`, `sha256` or `plaintext`), labels for
the account Secret, and an optional `valuesPath` for an operator that
reads no Secret.
- cozystack-controller keeps the account Secret `<template>.account`. It
seeds it on a release the API marked for seeding, adopts an unowned
Secret with the same username, leaves a foreign one alone with a
`SecretConflict` condition, and mirrors the record (origin, time, actor,
history) into the template status. For a `valuesPath` template it
maintains an optional `valuesFrom` entry on the release.
- `core.cozystack.io/v1alpha1` serves `credentials` as a read-only view
of the templates, plus `mint` and `revoke` subresources. A mint checks
the caller's `resourceVersion` precondition against the mirrored status,
builds the whole Secret and writes it in one request, or answers 409. It
never reads the Secret back. One API request writes one object; the
best-effort Event is the only extra write.
- The Application API marks a new release for seeding, keeps the account
`valuesFrom` entries when it rewrites a release, and refuses to delete a
suspended release that still has accounts, since Flux would skip its
uninstall.
- The dashboard gets a Credentials tab on the application page. It lists
accounts with origin and history; an administrator can mint or revoke,
and a viewer sees no buttons.

The application charts are untouched here: a kind starts using this only
when its chart renders templates. The `CredentialFormat` webhooks that
ADR 0002 describes are not in this PR, so `format.name` accepts only the
four built-in names for now.

### Screenshots

<img width="1440" height="900" alt="01-admin-tab"
src="https://github.com/user-attachments/assets/8c48086c-8f6c-4908-82c1-40e9078afe57"
/>

<img width="1440" height="900" alt="02-mint-dialog"
src="https://github.com/user-attachments/assets/802b2963-3f57-4c0b-ab84-f74bad28c343"
/>

<img width="1440" height="900" alt="03-mint-result"
src="https://github.com/user-attachments/assets/0e9ae3cc-7a3c-4daf-9a09-d4abf53bf70b"
/>

<img width="1440" height="900" alt="04-viewer-tab"
src="https://github.com/user-attachments/assets/10e940f2-4ceb-469d-a0f9-6c9d20a62919"
/>

### Downstream repositories

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: needed, cozystack/website#753 should document the
`Credential` mint/revoke flow and the dashboard tab
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: needed later, a way to mint from Terraform; nothing breaks
in this PR alone
- [ ]
[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: none, the design is cozystack/community#137

### Release note

```release-note
feat(api): Add the credentials API. Applications that support it expose their accounts as `credentials.core.cozystack.io`; an administrator mints a password once with the `mint` subresource, and `revoke` invalidates it without issuing a new one. The dashboard shows a Credentials tab for such applications. No application uses it in this release on its own; see the per-engine changes.
```
2026-11-26 12:37:20 +03:00
Timofei Larkin eec761a40f feat(kubernetes-nodes): choose a cozyplane route table
A worker pool in a VPC always routed by the VPC's default table. routeTable
names a cozyplane RouteTable for every worker VM of the pool and renders
sdn.cozystack.io/route-table on the worker VM template, the same contract
as vm-instance's routeTable. It fails the render where cozyplane does
not serve sdn.cozystack.io, on proxmox workers, and without network.name.

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-26 10:13:58 +01:00
Timofei Larkin 9e7741449c feat(kubernetes): run tenant clusters inside a cozyplane VPC
On the cozyplane networking variant a VPC refuses cluster-internal
destinations, so a tenant cluster whose workers join a VPC must bring
its control plane along: the workers, the tenant's own pods and the
konnectivity agents all need an apiserver address inside the VPC. The
platform side keeps working unchanged, since it reaches VPC pods by
their fabric IPs and through ClusterIPs that resolve to them.

network.name on the Kubernetes cluster puts the apiserver pods in the
VPC, attaches their Service to it, and stamps the cluster's own etcd,
whose operator copies the annotation onto the members and both etcd
Services, so the apiserver reaches its DataStore inside the VPC too.
The same value on each KubernetesNodes pool stamps its worker VM
template.

Kamaji's advertise address must be an IP that tenant consumers reach,
which here is the VIP the VPC knows the apiserver Service by. Only a
pod inside the VPC can learn it, so the pools' talos-reconcile Job
starts a probe pod in the VPC, reads the address it resolves back from
its termination message, advertises it, and gives it to the workers'
host entries in place of the ClusterIP.

The cluster refuses a VPC where sdn.cozystack.io is not served, on the
proxmox substrate, on the tenant's shared DataStore, and on a running
cluster outside that VPC, since etcd-operator never moves a running
member. A pool refuses a network that differs from its control
plane's.

Both checks hold where a live object does not exist yet: the pools'
reconcile Job compares the apiserver Service's VPC before the probe,
and the etcd render compares the live EtcdCluster's. The probe's Role
grants only get and delete, so a probe left by an interrupted attempt
is deleted without waiting and polled with get. network.name is a
DNS-1123 label in both apps, and every annotation carrying it is quoted.

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-26 10:13:47 +01:00
renovate[bot] 16d0f1fd19 chore(deps): update module golang.org/x/net to v0.62.0 [security] 2026-11-26 09:09:59 +00:00