Commit Graph
8848 Commits
Author SHA1 Message Date
Andrei Kvapil ee5d2adceb docs(linstor): cover the locked controller and retries after a way back
The live run of the ways back found the restarted linstor-controller
with its master key locked: the LinstorCluster sets no
linstorPassphraseSecret, so new LUKS volumes fail until the passphrase
is entered. Every way back restarts the controller, so each one now
says to unlock it.

Starting again after a way back from step 3 or 4 finds the converted
objects still there. A plain delete of a Resource or Snapshot is not
safe: the satellite's finalizer is released only after it has deleted
the replica's storage, so the next hold would destroy the volume.
Say what a retry overwrites, what it leaves, and how to clear the
rest and keep the LUKS passwords under one keyring.

Also warn that the scheduler and GUI show one UpgradeFailed when the
migration completes, which clears on its own.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 23:04:37 +01:00
Andrei Kvapil 8d0e577afe docs(linstor): mark the migration experimental, give a way back per step
blockstor has run on test clusters only, so the procedure says so and
asks for a maintenance window. Each step now says how to go back from
it, and the two after which there is none, repointing CSI and
unfreezing it, say so, since that decides when an operator can still
abort. Until CSI is repointed every way back is the same switch to
backend linstor, so it is written out once.

linstor-scheduler and linstor-gui may fail their render and retry
when CSI is repointed, until the linstor release has written the
external controller, which reads as a failure without the note.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 23:04:37 +01:00
Andrei Kvapil 56a87920e1 docs(linstor): apply the converted manifests server-side
The hook no longer drops fields it does not set, but a hand-run
server-side apply of ControllerConfig/default still would if the
migration left its fields to kubectl-client-side-apply. Applying the
manifests server-side under their own manager leaves nothing for such
an upgrade to take over.

Also say how to check the key ID while the controller is held at zero,
where blockstor's own command prints nothing useful.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 23:04:28 +01:00
Andrei Kvapil 185b582864 fix(linstor): set the passphrase ref without dropping DRBD options
The post-install/upgrade hook set ControllerConfig/default's
passphraseSecretRef with a server-side kubectl apply of that one field.
When the object was last written by a client-side kubectl apply, as the
converted manifests of a LINSTOR migration were, kubectl's CSA-to-SSA
upgrade hands every field kubectl-client-side-apply owns to the applying
manager and re-sends the apply, which then removes what it does not
name: LINSTOR's cluster-wide DRBD options in extraProps, which the
satellites apply live on the next adjust. No field manager avoids it,
since the upgrade moves the fields to whoever applies.

Merge-patch the one field when the object exists and create it when it
does not. A merge patch replaces only what it carries, whoever owns the
rest. The script moves to hack/ so a test can run it against a
client-side-applied object.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 23:04:20 +01:00
Andrei Kvapil fcf7df64a6 docs(linstor): give the order of a LINSTOR to blockstor migration
blockstor's runbook is written for any LINSTOR deployment and does not
know which steps the Cozystack chart and piraeus-operator take on their
own: which value moves piraeus to external mode and when, which
replica counts the running operator leaves at zero and has to be
restored by hand, and how to go back before CSI is repointed.

The operator stays up through every step, as in the runbook. Its
webhooks keep serving, and a platform upgrade in the middle of the
freeze would let it roll out a new operator or linstor-csi, so each
step is its own change.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 23:04:19 +01:00
Andrei Kvapil e09865bd5f feat(platform): pass the blockstor migration step to the linstor package
The cozystack.linstor Package is rendered by the platform, so a value
set on it by hand is overwritten on the next reconcile. The migration
step has to come from the platform values like the backend does, and
is checked there so a typo or a step left over after switching back to
linstor fails the platform render rather than the linstor release.

linstor-scheduler and linstor-gui stay on LINSTOR until
blockstorMigration is cleared, in the step that repoints linstor-csi.
At hold CSI still acts on LINSTOR's state and blockstor serves nothing
yet, or Resources it has not adopted, and the scheduler extender
panics on a Resource without volumes, which is the shape of one before
adoption.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 23:03:55 +01:00
Andrei Kvapil 944fbc8e7d fix(linstor): leave piraeus untouched while blockstor adopts volumes
The migration runbook freezes CSI and stops LINSTOR before blockstor
adopts the volumes, and repoints CSI only after adoption converges.
One backend flip cannot express that order: piraeus-operator goes to
external mode at once, deletes linstor-controller and repoints
linstor-csi before a single volume is adopted.

blockstorMigration splits the switch into steps. Under hold and adopt
every piraeus object renders exactly as under backend linstor, so
piraeus-operator, which keeps running as in blockstor's runbook, finds
LINSTOR's shape and keeps linstor-csi on LINSTOR until adoption has
converged. It does not undo the freeze either: it applies its
Deployments without a replica count, since the LinstorCluster sets
none, so linstor-controller and linstor-csi-controller stay at zero.
Keeping the operator up rather than stopping it also keeps its
validating webhooks served, so the release passes them at every step
without relaxing their failurePolicy.

hold also keeps the blockstor controller at zero replicas until the
converted manifests are in: a scale by hand did not survive the next
upgrade. Clearing the value is the only step that changes piraeus.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 23:03:55 +01: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 cf7bd11eeb test(e2e): prepare and check the backend the install deploys
The e2e scripts assumed LINSTOR throughout: the prep created pools
through linstor-controller and the replicated suite's pool guard read
them from it. COZY_STORAGE_BACKEND is now set once by the install step
and reaches the platform values, the prep and the Chainsaw suites
alike. The prep refuses a missing or unknown value instead of guessing,
which would race the install and fail open to linstor.

Under blockstor the prep waits for blockstor's own Deployments and for
every LinstorSatellite to apply, registers a Node per Kubernetes node at
its InternalIP, creates the data zpool and its StoragePool on each
satellite, and waits until every satellite has reported its pool, since
placement does not count a pool before that. The pool guard reads
StoragePool objects and lists datasets through blockstor-satellite.

The backend is validated before the guard starts polling. Inside the
loop every failed read is retried: the remote jq exits 2 on the output
a restarting controller can print, so no read status can mean "give
up".

blockstor needs DRBD and the QEMU lane's private disk, so the pair with
COZY_LINSTOR_DRBD_ENABLED=false is refused rather than installed into a
prep that cannot finish. No CI lane sets the variable, so the default
runs are unchanged.

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
Aleksei Sviridkin 60cf13dbc4 fix(ci): build a stacked PR's images from its line's fork point (#5463)
## What this PR does

A pull request stacked on another feature branch builds its images from
its own diff against that branch, so one that changes only tests builds
no images. The overlay then fills every package from main's or a release
line's artifact, which has none of the stack's changes, and the stack's
charts run on images that do not match them. In one stacked run
cozystack-controller crash-looped on `flag provided but not defined:
-enable-gpu`.

With this change the build list of such a pull request comes from the
fork point with the line whose artifact the overlay reads, so the images
of the pull requests below it are built too. On main and the release
lines nothing changes. When the fork point cannot be found, CI warns,
builds every image, Talos included, and keeps the committed refs out of
the overlay.

#4460 already fixed the overlay tag for a feature-branch base; this is
the build list beside it. #4911 applies the same fork-point rule to the
Kairos worker disks only; this PR covers every image.

The new hack/pr-changed-paths_test.bats and the existing overlay tests
pass locally under Bats. I have not seen a stacked pull request run
through this workflow yet.

Closes #5444

### Screenshots

### Downstream repositories

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

### Release note

```release-note
fix(ci): build a stacked pull request's images from the fork point of the line its base belongs to, so a stack that changes only tests no longer runs e2e on main's images.
```


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

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

## Summary by CodeRabbit

* **Build & Validation**
* Pull request checks now account for renamed files when determining
which builds and tests to run.
* If changed-file detection fails, validation falls back to the full
build matrix, gated tests, Talos builds, and package coverage.
* Base-package overlays now select artifact references based on branch
context, supporting stacked pull requests and release branches.
* **Tests**
* Added coverage for changed-file detection, rename handling, branch
scenarios, and fallback validation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-28 00:18:23 +03: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 8e5600d5e3 fix(postgres): update PostGIS extensions after an image upgrade (#5477)
## What this PR does

Refs #5459 (item 2)

After an upgrade that moves a `postgis` flavor Postgres to a new PostGIS
release (3.6.1 to 3.7.0 for v14-v18 on the current `main`), the PostGIS
library is new but the SQL objects in every database stay on the old
release: `postgis_full_version()` reports `core procs from "3.6.1 ..."
need upgrade`. The release notes tell users to run `ALTER EXTENSION
postgis UPDATE`, but the init Job created the extensions as the
superuser, so the tenant gets `must be owner of extension postgis` and
has no way to run the update.

The init Job now runs that update. It covers `postgis`,
`postgis_raster`, `postgis_topology`, `postgis_sfcgal`,
`postgis_tiger_geocoder`, `address_standardizer` and
`address_standardizer_data_us` in every connectable database where they
are installed:

- The target is the `default_version` the server offers, so the pass
only runs once the server is on the new image. If the server is already
up to date, it does nothing.
- Helm starts the hook while CNPG is still rolling the instances. The
pass waits until the server offers the PostGIS version that the Job's
own image ships, and stops waiting 120 s before the Job deadline (the
same bound the collation pass uses).
- If the rollout is slower than that, the Job fails. The init Job is a
hook, so a run that ends well does not come again before the next change
of the release; a failed one makes the release retry once the server
runs the new image. The version probe is bounded by `timeout 10`.
- `postgis_extensions_upgrade()` is not used: it leaves out
`address_standardizer`, and on every call it updates each installed
extension to `ANY` and back, even when nothing changed. Each extension
gets `ALTER EXTENSION ... UPDATE TO <server default_version>`, with
`postgis` first. Each session pins `search_path` to `pg_catalog,
pg_temp`.
- If the image ships no update path for an extension, the pass prints a
warning and leaves it alone. The check uses `pg_extension_update_paths`.
- A tenant transaction can hold a lock an update needs, and one update
can wait for several in turn. Before each `ALTER EXTENSION`, the session
therefore sets `statement_timeout` and `lock_timeout` to what is left of
the Job, keeping the same one-minute reserve as the collation pass. So
every update, lock waits included, ends before the Job does. A database
reached with no time left counts as failed.
- The update scripts run as the superuser and write to tables a tenant's
admin role is granted `ALL` on, `spatial_ref_sys` among them (the
PostGIS 3.7 script inserts into it). A trigger the tenant attached there
would run with the superuser's privileges.
- The update session therefore sets `session_replication_role =
replica`, so triggers enabled the default way (`ENABLE ORIGIN`, what
`CREATE TRIGGER` gives) do not fire.
- Only the table's owner, the superuser, can enable a trigger `ALWAYS`
or `REPLICA`. A database where such a trigger sits on a table of these
extensions is not updated and is reported.
- A database whose extensions cannot be looked up counts as failed, and
the pass continues with the others.
- If an update fails, the other databases are still processed and then
the Job fails. Under `RetryOnFailure` the release is retried and shows
as failed, so the error does not get lost in the log of a Job that is
deleted an hour later. The pass runs after the collation repair, so a
failure here cannot block index rebuilds.
- The section is rendered only for `flavor: postgis`. For the
`postgresql` flavor, the rendered `init.sh` is byte-identical to `main`.

**Needs a separate decision:** PostGIS 3.7 renamed the
`address_standardizer` library (`address_standardizer-3.so` became
`address_standardizer.so`) and ships no update path from 3.6.1. As a
result, an `address_standardizer` created under 3.6.1 fails after the
upgrade with `could not access file "$libdir/address_standardizer-3"`.
`ALTER EXTENSION` cannot fix this; only `DROP EXTENSION` followed by
`CREATE EXTENSION` as the superuser can. This PR only reports it.
Whether the Job should drop and recreate the extension (which risks
tenant objects that depend on it) is left to reviewers.

### Testing

- Docker, rendered `init.sh` (`helm template --set flavor=postgis`) run
with the Job's environment on the `17.12-3.7.0-standard-trixie` image:
- Run against a server still on `17.7-3.6.1`: it waited, printed "the
server did not move to PostGIS 3.7.0 in time … failing the init-job" and
exited 1.
- A tenant transaction held open on `geography_columns` in `appdb`, with
`JOB_DEADLINE=85`:
- the update in `appdb` was cancelled when the budget ran out
(`canceling statement due to statement timeout`, 25 s);
    - `db2`, reached with no time left, was reported as not updated;
    - the Job exited 1 after 25 s;
- after the blocker ended, the next run updated both databases to 3.7.0
and exited 0;
    - a further run was a no-op.
- Tenant trigger: as a non-superuser `appdb_admin` granted `ALL` on
`public` tables, a `BEFORE INSERT ... FOR EACH STATEMENT` trigger on
`spatial_ref_sys` whose function runs `ALTER ROLE appdb_admin
SUPERUSER`.
    - Without the guard, the update made `appdb_admin` a superuser.
- With it, the update to 3.7.0 passed and `appdb_admin` stayed
non-superuser.
- With the same trigger set `ENABLE ALWAYS` (superuser only), the
database was skipped with an error, the Job exited 1, and the role
stayed non-superuser.
- The same data directory restarted on `17.12-3.7.0`: `postgis`,
`postgis_raster`, `postgis_topology` and `postgis_sfcgal` went from
3.6.1 to 3.7.0 and `postgis_tiger_geocoder` from 3.6.1 to 2025.2 in
`appdb`; `postgis` went to 3.7.0 in a second database. Afterwards
`postgis_full_version()` no longer reports "need upgrade". The md5 of a
spatial join and area query was the same before and after.
  - A second run was a no-op.
- A database with a planted conflicting object failed with `function
st_x(geometry) is not a member of extension "postgis"`. The other
database was still updated, and the Job exited 1.
- `flavor: postgresql`: the rendered `init.sh` is identical to `main`.
- `helm unittest packages/apps/postgres`: 31 suites, 247 tests passed.
- Dev cluster: v1.7.1 chart installed (postgis, v17, 2 replicas,
`postgis` in `appdb` at 3.6.1), then `helm upgrade` to this branch:
- The first attempt passed (exit 0). The Job logged `waiting for the
server to offer PostGIS 3.7.0`, then `updating extension postgis in
database appdb from 3.6.1 to 3.7.0`.
- Afterwards the image is `17.12-3.7.0-standard-trixie` and `postgis` is
3.7.0, with no "need upgrade" left. A spatial query gave the same md5 as
before.
  - A second upgrade left the PostGIS section empty.

**This change is verified only by hand** (Docker and the dev cluster
above). No e2e suite upgrades a postgis-flavor release, and one cannot
be added without an upgrade harness.

### Downstream repositories

The diff only touches
`packages/apps/postgres/templates/init-script.yaml`. It adds no values
key, schema field, version enum, default, app, CRD, hack script or
naming change, so none of the triggers in the map apply.

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

If a release note on the website tells users to run `ALTER EXTENSION
postgis UPDATE` by hand, that note becomes obsolete. I did not find such
a note in the trigger map and did not search the website repository.

### Release note

```release-note
[postgres] The init Job of a postgis-flavor Postgres now updates the PostGIS extensions in every database once the server runs the new image, so tenants no longer get "must be owner of extension postgis" or stay on outdated PostGIS SQL objects after an upgrade. An address_standardizer created under PostGIS 3.6 has no update path to 3.7 and is reported, not changed.
```


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

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

## Summary by CodeRabbit

* **Improvements**
* For PostGIS jobs, installed extensions are checked and updated to the
version available in the job environment, with dependencies handled in
order.
* The process waits for the required PostGIS version and skips
extensions without a supported update path, reporting a warning.
* Databases with relevant always-enabled or replica triggers are
rejected. Checks and updates are bounded by the job deadline; failures
are collected across databases, and the job reports an error if any
database could not be checked or updated.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-27 18:27:52 +03:00
Aleksei Sviridkin 36af0b0110 fix(postgres): skip a stale index while another session builds on its table (#5485)
## What this PR does

Refs #5459 (item 4)

The collation repair pass in the postgres init Job rebuilds each stale
index in its own psql session: it picks the index by OID, takes its name
and runs `REINDEX INDEX CONCURRENTLY <name>`. A rebuild started by a run
that hit its Job deadline keeps going, because its backend only notices
the lost client when the rebuild ends. The next run then lines up behind
that orphaned rebuild on the table lock. Once the orphan swaps in the
new index, the name resolves to the new, already rebuilt index and the
run rebuilds it a second time, holding its table until the new run's own
deadline. On PostgreSQL 17 the waiting run can also deadlock with the
orphan in its final phase, and the deadlock detector then throws away
the orphan's finished build.

This PR skips an index while `pg_stat_progress_create_index` shows
another backend building an index of its table (same database, other
pid). The skip is reported the same way as a failed rebuild, so the run
exits non-zero and the next run carries on. That next run finds the new
index above the resume mark and treats it as done.

The check is the first statement of the session. It runs before the
index is looked up by OID and its name taken, with the table taken from
`pg_index` by that OID. A rebuild that ended before the check has
already removed the index the session looks for, so `present` skips it.
An orphaned backend never starts another statement after the check, so
it cannot swap the index in between. As a result the check also runs
before:
- the `_ccnew` leftover count, which a build in progress would otherwise
inflate (it owns one invalid `_ccnew` index);
- the in-place attempt record of an exclusion constraint's index, so a
skip never counts towards leaving that index to an operator.

The resume mark, the fingerprint, the `_ccnew` leftover rule and the
`lock_timeout`/`statement_timeout` bounds are unchanged.

A build that a live session starts after the check, in the moment before
REINDEX takes its lock, is not covered: SQL has no way to REINDEX by
OID. Only an operator or a tenant racing the Job could hit that window,
because an orphaned rebuild cannot start a new statement.

### Screenshots

Not a UI change.

### Testing

- `helm unittest packages/apps/postgres`: 31 suites, 247 tests passed.
- `helm template` renders. The only change in the rendered `init.sh`
compared with `main` is the new check.
- Ran the repair section of the rendered `init.sh` from `main` and from
this branch in Docker (`postgres:17-trixie`). Each init-job run was a
separate container on the same network as the database, the way the Job
pod and the Cluster are. A run "hit its deadline" by having its
container removed while its `REINDEX INDEX CONCURRENTLY` was in the
`building index` phase. The index was made stale by setting `collversion
= '0'` for `en-x-icu`. The build was slowed deterministically with an
expression index over an ICU column through an immutable function that
sleeps 1 ms per row (about 2.5 minutes per build).
- `main`: run 2 logged `rebuilding index public.t_k` and waited behind
the orphaned build. The deadlock detector then cancelled the orphan
after its full build (`Process 135 waits for ShareLock on virtual
transaction ...; blocked by process 175`), and run 2 rebuilt the index
from scratch, so the index was built twice. In the field report on
PostgreSQL 18 the orphan finished instead, and the waiting run rebuilt
the fresh index a second time.
- this branch (check first in the session): run 2 failed at once with
`index public.t_k in database postgres was skipped: another session is
building an index of its table ...` and exit 1. The orphan finished
alone and the index got a new OID. Run 3 rebuilt nothing, refreshed the
collation version, reset the repair setting and exited 0, with no
invalid indexes left.
- Exclusion constraint index (in-place path) on this branch: while
another session ran `CREATE INDEX CONCURRENTLY` on the same table, the
run skipped the index without recording an in-place attempt. The next
run rebuilt it in place (same OID, new relfilenode) and exited 0.

- Dev cluster (cozystack v1.7.0): this branch's chart with
`17.12-standard-trixie` and 2 instances. A table of 300k rows with the
slow expression index over `en-x-icu`, so a `REINDEX INDEX CONCURRENTLY`
took about 12 minutes. `en-x-icu` was marked stale with `collversion =
'0'`.
- Upgrade 1 started the rebuild (`rebuilding index public.t_k ...`). Its
init Job was deleted mid-build, and the backend kept building after the
Job was gone.
- Upgrade 2 while that build ran: the init Job failed at once with
`index public.t_k in database postgres was skipped: another session is
building an index of its table ...`, without queueing behind the lock.
  - The orphaned build finished alone (index OID 16453 → 16464).
- Upgrade 3: the init Job completed in 10 s with no `rebuilding` line.
The OID stayed 16464, the collation version was refreshed,
`cozystack.collation_repair` was reset, and no invalid indexes were
left.

### Downstream repositories

Walked the trigger map against the diff. The PR changes only
`packages/apps/postgres/templates/init-script.yaml` (SQL inside the init
Job script). It touches no values, schema, README,
ApplicationDefinition, package layout, `hack/`, platform keys or names
that any listed repository mirrors.

- [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
[postgres] The init Job's collation repair no longer rebuilds an index a second time, or deadlocks with a rebuild left running by an earlier run that hit its deadline; it skips an index while another session builds an index of its table, and the next run of the Job carries on.
```


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

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

## Summary by CodeRabbit

* **Bug Fixes**
* Collation repair now detects when another session is building a
planned index and reports an error identifying the index and database.
The database’s repair failure is recorded, rather than proceeding to
inspect or rebuild the index during the concurrent operation. This makes
the conflict visible in the repair results.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-27 18:21:49 +03:00
Aleksei Sviridkin 9314becb72 fix(ci): push the stable chart once, so a re-run keeps cozy-installer:X.Y.Z (#5486)
## What this PR does

Since #5169 finalize publishes the release page last, so a run that
fails in `Publish draft release` gets re-run after the chart is already
pushed. The re-run packaged and pushed the chart again, and `helm
package` doesn't give the same bytes twice (I packaged the same tree
twice with different file times and got two digests), so
`cozy-installer:X.Y.Z` moved to another digest.

Now the chart step pushes only when `cozy-installer:X.Y.Z` is not in the
registry yet. `cozy-installer:latest` still follows the latest decision
on every run.

The test runs the step against stub skopeo, helm and yq: first run
pushes once, re-run pushes nothing, older patch leaves latest alone,
failed push fails the step.

Lines get this in own PRs: #5487 (release-1.7) and #5488 (release-1.6).

### Downstream repositories

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

### Release note

```release-note
fix(ci): a re-run of finalize no longer pushes the stable cozy-installer chart again, so cozy-installer:X.Y.Z keeps the digest of its first push
```


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

## Summary by CodeRabbit

* **Chores**
* Stable installer chart versions are preserved once published.
Re-running a release will not replace an existing version; correcting a
published chart requires removing it from the registry before rerunning.
* If a version is missing, the release can publish it. Registry lookup
or publishing errors stop the release. When configured, the `latest` tag
is updated even if the versioned chart already exists.
* **Documentation**
* Clarified the policy for publishing stable chart versions and handling
existing charts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-27 17:56:34 +03:00
Andrey Kolkov a559b87ea0 fix(postgres): update PostGIS extensions after an image upgrade
An upgrade that moves the postgis flavor to a new PostGIS release leaves
the SQL objects of every database on the old release, and
postgis_full_version() reports "core procs from "3.6.1 ..." need upgrade"
next to the 3.7.0 library. The init Job creates the extensions in its
superuser session, so a tenant that follows the release notes and runs
ALTER EXTENSION postgis UPDATE gets "must be owner of extension postgis",
and the superuser secret is not available to the tenant either. The Job
now runs the update itself, for postgis and the extensions that come with
it, in every database where they are installed.

The target is the version the server offers rather than a version in the
chart, so a database only moves to what the running library implements
and a run on an up-to-date server changes nothing. Helm starts the hook
while CNPG is still rolling the instances, so the pass waits for the
server to offer the PostGIS release of the Job's own image, bounded like
the collation pass. A rollout slower than that fails the Job: the init Job
is a hook, so a run that ends well does not come again before the next
change of the release, while a failed one makes the release retry.
postgis_extensions_upgrade() is not used because it leaves out
address_standardizer and updates every installed extension to ANY and
back on each call; an extension the image ships no update path for, which
is the case for address_standardizer 3.6.1 to 3.7, is reported and left
alone. A tenant transaction can hold a lock an update needs, and one
update can wait for several in turn, so each update, its lock waits
included, runs no longer than what is left of the Job, with the reserve
the collation pass keeps, and a database reached with no time left
counts as failed. An update that fails does fail the Job after every
database has been tried, so the release is retried and shows as failed.
The pass runs after the collation repair, so a failure here cannot hold
back index rebuilds.

The update scripts run as the superuser and write to tables, such as
spatial_ref_sys, that a tenant's admin role is granted ALL on and so may
attach a trigger to; such a trigger would run with the superuser's
privileges. The update session therefore sets session_replication_role to
replica, under which triggers enabled the default way do not fire, and a
database where a trigger on these extensions' tables is enabled ALWAYS or
REPLICA, which only the superuser owning them can do, is not updated. A
database whose extensions cannot be looked up counts as failed instead of
ending the pass, so the others are still updated.

Refs: #5459
Assisted-By: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-27 20:56:20 +07:00
Myasnikov Daniil e99a15dbee fix(ci): push the stable chart once, so a re-run keeps cozy-installer:X.Y.Z
Since finalize publishes the release page last, a run that fails in
Publish draft release is re-run after the chart is already pushed. The
re-run packaged and pushed the chart again, and helm package does not
give the same bytes twice (two packagings of the same tree with
different file times give two digests), so cozy-installer:X.Y.Z moved
to another digest.

The chart step now pushes only when the registry answers that cozy-
installer:X.Y.Z is missing, read as manifest_digest in hack/promote-
retag.sh reads it; any other lookup error fails the step instead of
being taken for a missing tag. cozy-installer:latest still follows the
latest decision on every run.

A bats test runs the step against stub skopeo, helm and yq: the first
run pushes once, a re-run pushes nothing, an older patch leaves latest
alone, a failed push fails the step, and a failed lookup fails it
without packaging or pushing.

Fixes: e1472e58de ("fix(ci): publish the release only after the stable images and chart exist")
Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-27 13:51:28 +00:00
Andrey Kolkov 12f3758567 fix(postgres): skip a stale index while another session builds on its table
A REINDEX CONCURRENTLY started by an init-job run keeps going after the
Job hits its deadline, because its backend only notices the lost client
when the rebuild ends. The next run looks the index up by OID but hands
REINDEX its name; REINDEX then waits behind the orphaned rebuild, and once
that rebuild swaps in the new index, the name resolves to it and the
already rebuilt index is rebuilt again, holding its table until the new
run's own deadline.

Skip such an index and report it like a failed rebuild while
pg_stat_progress_create_index shows another backend building an index
of its table. The check is the first statement of the session, before
the index is looked up: a rebuild that ended before it has removed the
index the session looks for, and an orphaned backend never starts another
statement after it. The next run then finds the rebuilt index above the
resume mark and treats it as done. The check comes before an in-place attempt
is recorded, so a skip never counts towards leaving an exclusion
constraint's index to an operator, and before the _ccnew leftover count,
which the build in progress would otherwise inflate.

Assisted-By: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-27 20:48:57 +07:00
myasnikovdaniil 0c4102cae6 Merge commit from fork
security(info): do not render the tenant ServiceAccount token under OIDC
2026-11-27 18:34:40 +05:00
myasnikovdaniil 3add3d0a5a Merge commit from fork
fix(backups): confine Velero restore-copy to the tenant namespace subtree
2026-11-27 18:31:07 +05:00
myasnikovdaniil 9b0dedeb7a Merge commit from fork
fix(bucket): refuse COSI classes of another SeaweedFS instance
2026-11-27 18:22:11 +05: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
Myasnikov Daniil 5674d01c95 security(info): do not render the tenant ServiceAccount token under OIDC
The Info application selects the ServiceAccount token Secret for the
tenantsecrets API, and the use tier can read tenantsecrets, so the token
and the rights bound to its ServiceAccount were readable by every use
member of the tenant.

With OIDC enabled the dashboard signs in with the user's own ID token and
nothing consumes the token, so the Secret is no longer rendered. Removing
it also invalidates tokens that were already read.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-27 13:48:04 +01:00
Aleksei Sviridkin 8641ebbf63 fix(ci): publish the release only after the stable images and chart exist (#5169)
## What this PR does

Finalize undrafted the release before retagging the rc images and
pushing the cozy-installer chart, so release page announced version
whose images and chart still returned `manifest unknown` (7m47s on
v1.7.0:
https://github.com/cozystack/cozystack/actions/runs/40864518300). Failed
retag or chart push also left public release that re-run couldn't
repair, because re-run looks for draft and finds none.

Now draft lookup and `make_latest` decision are in own step `Resolve
draft release`, before any registry write. Retag, chart and `Publish
draft release` take the decision from its outputs, and publish goes
last. Missing draft fails before anything is pushed, failed retag or
chart leaves the draft for re-run. Body selection, orphaned draft
repair, `prerelease` and restoring `latest` after older patch are
unchanged.

Deciding `latest` before the retag opens a window of minutes where two
release PRs merged close together both decide they are newest, and the
older line ends up with `latest` on release page, image `:latest` and
`cozy-installer:latest`. So finalize runs one release at a time:
job-level concurrency group built from the job's own `if:` (other closed
PRs never join it), `cancel-in-progress: false` and `queue: max`, so
third merged release waits instead of cancelling the pending one.

Docs and comments in `tags.yaml` and `promote-rc.yaml` that said release
is already public when finalize pushes the stable tag now say when it is
published. Release checklist no longer says to undraft by hand when
draft lookup fails.

Closed-PR workflow runs from base branch, so supported lines get this in
own PRs: #5480 (release-1.7) and #5481 (release-1.6).

Tests: contract tests pin step order, that nothing publishes after
failed registry step (no `continue-on-error`, no `if:` on publish,
registry steps skip only for prerelease) and the concurrency group.
Behaviour tests run both github-script steps under node against stubbed
API (missing draft, orphaned draft, older patch after newer minor, all
shipped changelog tags). Every new test fails against the old workflow,
I also checked them against mutated copies of it.

### Downstream repositories

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

### Release note

```release-note
fix(ci): finalize publishes the release page last, after the stable image tags and the cozy-installer chart exist, and finalizes one release at a time, so a release is no longer public while its images return manifest unknown
```
2026-11-27 15:33:44 +03: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
Myasnikov Daniil e1472e58de fix(ci): publish the release only after the stable images and chart exist
Finalize undrafted the release before it retagged the images and
published the cozy-installer chart, so for the length of the retag the
release page announced a version whose images and chart returned
manifest unknown. The retag took 80-95 seconds on the 1.6.x patches and
several minutes on v1.7.0. A failure in either step also left a public
release that a re-run could not repair, because the re-run looked for a
draft and found none.

Move the draft lookup and the latest decision into their own step that
runs before any registry write, hand the decision to the retag, the
chart and the release page as step outputs, and undraft last. A missing
draft now fails while no stable name exists, and a failed retag leaves
the draft in place for a re-run. The comments and docs that took the
release to be public by the time finalize pushes the stable tag now say
when it is published.

Deciding latest before the retag opens minutes in which two release PRs
merged close together would both decide they are the newest, leaving
latest on the older line on the page, the image aliases and the chart.
Finalize therefore runs one release at a time, in a concurrency group
that only release PRs join and that queues every merged release rather
than cancelling the one waiting.

The finalize bats suites run both github-script steps under node against
a stubbed API: a missing draft, an orphaned draft, an older patch after
a newer minor, and every shipped changelog's tag. A contract test fails
on a registry step allowed to fail, a publish step that runs after a
failure, a `latest` that moves without the decision, or finalize runs
that may overlap.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-27 10:25:01 +00: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
myasnikovdaniil 01a57f7169 docs(release): add changelog for v1.7.2 (#5471)
This PR adds the changelog for release `v1.7.2`.

✅ Changelog has been automatically generated in
`docs/changelogs/v1.7.2.md`.
2026-11-27 12:39:14 +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
Myasnikov Daniil 8ef5ad1324 feat(api): treat objects that cannot be completed as one value
The merge completes an object field by field only when its schema
declares properties. An atomic object (x-kubernetes-map-type: atomic), a
dictionary value, a free-form object and an object that also takes
arbitrary keys are stored as written, so nothing can complete them
later. A default osImage.builtin plus a user's osImage.factory gave a
spec the kubernetes-nodes chart refuses to render, and an entry such as
a RabbitMQ vhost without roles was accepted and stored the same way.

The merge now copies such an object whole or leaves the user's value
alone, and an entry is validated for it as a whole, like an array row.
A branch of an allOf, anyOf or oneOf that names a property is judged
like the property declared next to it. An entry that gets this wrong is
skipped with a warning like any other invalid entry.

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
cozystack-ci[bot] 5d012b83bd docs: add changelog for v1.7.2
Signed-off-by: cozystack-ci[bot] <274107086+cozystack-ci[bot]@users.noreply.github.com>
2026-11-27 07:25:31 +00:00