Commit Graph
8865 Commits
Author SHA1 Message Date
Myasnikov Daniil 09f6fb5757 perf(ci): build release lines from their own cache, in parallel
Release-line image builds read only main's build cache. Once main moved
its builder and base images, release-1.7's Dockerfiles stopped matching
that cache, and the rc Build step went from 19 to 53 minutes on amd64
and from 10 to 46 on arm64 between v1.7.1-rc.2 and v1.7.2-rc.2.

Each line now keeps a cache of its own. build-release.yaml writes
buildcache-release-X.Y on every push to the line, and rc builds import
it together with main's buildcache. The arm64 rc build, the only arm64
build a line has, keeps buildcache-arm64-release-X.Y itself.
CACHE_FROM_TAGS lists every cache a build imports; unset, it is
CACHE_TAG, as before.

The units of hack/build-matrix.sh now build four at a time (make build-
parallel, hack/build-units.sh), since they spend most of their time on
registry round trips, one image after another. Every output line carries
its unit and is written as it comes, so a job that times out still shows
where it stopped. objectstorage-controller waits for the rest because it
writes seaweedfs' values.yaml. The rc jobs also leave their buildx
builder to the throwaway runner: removing it took up to 11 minutes on
arm64.

A cache write that fails no longer fails the build (ignore-error=true on
every --cache-to): OCIR refuses a blob upload now and then, which
already failed the arm64 nightly twice in its last thirty runs, and rc
and line builds now write a cache too.

Tested with bats: the cache macro, the unit builder against a fake make
(the BUILD_JOBS limit, ordering, a failing unit, a failing
objectstorage-controller, a unit list that cannot be generated, and
output that shows while a unit still builds) and the workflow settings,
plus a dry run of hack/build-units.sh over the real units with make -n.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-12-01 02:10:21 +03:00
Aleksei Sviridkin a4ddf5422e docs(release): add changelog for v1.7.3 (#5498)
This PR adds the changelog for release `v1.7.3`.

✅ Changelog has been automatically generated in
`docs/changelogs/v1.7.3.md`.
2026-12-01 01:54:17 +03:00
Timofei Larkin fa9b8f07a2 feat(postgres)!: mint tenant passwords through the credentials API (#4922)
## What this PR does

Postgres passwords are no longer readable from `<release>-credentials`,
which every `use` member and every parent tenant can read today, and
`users.<name>.password` is ignored. An administrator mints a password on
the user's `Credential` and sees it once. The account Secret stores only
the SCRAM verifier, CloudNativePG applies it, and the next mint or a
revoke kills the previous password. This is the Postgres part of the
user secrets API design (cozystack/community#137) on top of #4921.

- The chart renders one `scram-sha-256` CredentialTemplate per user and
points each managed role at its account Secret.
- The CloudNativePG bootstrap secret of the `app` owner is now that
user's account Secret, so the chart no longer generates a password into
`<release>-app-owner`.
- `users.<name>.createRole: true` is refused at render. A CREATEROLE
user becomes a member of each role it creates, CloudNativePG revokes
every membership a managed role does not declare, and that revoke fails
on the dependent grant, so the role gets stuck in `cannotReconcile`.
CloudNativePG has no per-role switch to leave memberships alone.
- `credentials-migrate` and migration 64 convert existing releases. The
pre-upgrade hook applies the CredentialTemplate CRD, writes each account
Secret from the current password as a verifier, and marks the release
for seeding only when every account got one. The finish Job runs under
its own `cozystack-credentials-migration-64` identity and removes
`<release>-credentials` once the controller adopted the accounts. A
transient API error is retried before a release is recorded as left out.

Live results, on a three-node test cluster upgraded from 1.7.1, with a
client logging in every second:

- Upgrade: the migration wrote the verifiers, the controller adopted
them, the finish Job removed the old Secret, and the client logged in
1014 times with no failure. A later run that upgraded all converted
engines at once (migrations 64-71) also had no Postgres failure, for
`web` and for the database owner `app`.
- A mint returns a password that logs in over TCP; the next mint and a
revoke each kill the previous password within 2 s. A stale precondition
gets 409 with no password, and a tenant viewer can't mint.
- Removing a user removes its template, Secret and role. `createRole:
true` fails at render.
- After a mint on `app`, the password survived a primary failover and
two restarts: CloudNativePG did not reset it from the bootstrap Secret.

Breaking for users: passwords can't be read any more, so clients switch
to a minted one after the upgrade. A release with `users.*.createRole:
true` is left out of the conversion: it keeps its previous chart
version, raises `CredentialsMigrationIncomplete`, and fails every
upgrade until the flag is set to `false`.

The red `E2E (in-tree)` comes from `mariadb-2-backup-roundtrip`, where
SeaweedFS rejected a freshly granted BucketAccess key before any
Postgres code ran; the three postgres tests pass.

### Screenshots

No UI change.

### Downstream repositories

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: needed, a Postgres note for the credentials API docs
(cozystack/website#753) and an upgrade note that clients must mint and
`createRole` must be off
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: needed, `cozystack_postgres` still sends
`users.<name>.password`
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
feat(postgres)!: Postgres passwords are issued through the credentials API and are no longer readable from `<release>-credentials`; `users.<name>.password` is ignored. An administrator mints a password on the user's Credential; it is shown once and applies within seconds. Existing passwords keep working through the upgrade: migration 64 converts every Postgres release and then removes the old Secret. `users.<name>.createRole: true` is no longer supported: a release that sets it is not converted, raises `CredentialsMigrationIncomplete` and fails its upgrades until the flag is set to `false`. Switch clients to minted passwords after the upgrade.
```
2026-12-01 00:44:53 +03:00
Aleksei Sviridkin 48d91c2413 feat(release): sign the release images and attach their SBOMs (#5042)
## What this PR does

Follow-up to #4997 (merged as d32092ac9), which puts the SBOM into each
release image's index. Rebased onto `main` at that merge, one commit
`57346c16d`; bats on the touched files 36/36, shellcheck clean. This is
the follow-up agreed there, and the image half of #4759: the release
images get signed, and their SBOMs become a release asset, along the
lines of #4861.

Refs #4759, #2937, #3278

`hack/sign-release-images.sh` runs in `tags.yaml::prepare-release` after
the stitch, before `make upload_assets`. It enumerates every first-party
`<repo>@<digest>` the repinned tree holds the way
`hack/stitch-multiarch.sh` does (the shared enumeration, refs under the
registry, `cozystack-packages` left out), skips each one that already
verifies, signs the rest with the job's OIDC identity, one `cosign sign
--yes` call per ref so that cosign's per-call `--timeout` (3 minutes by
default) does not have to cover every ref's key, Fulcio certificate,
Rekor entry and registry round trips, and verifies every one against the
identity regexp of `hack/sign-release-assets.sh` before returning; the
two scripts' regexps are held equal by bats. A signature that does not
verify fails the job with nothing uploaded. A signature over an index
covers every manifest the index lists by digest, the attestation
manifest with the SBOM included, so the SBOM has no signature of its
own. cosign v3.1.3 writes the signature as a Sigstore bundle, an OCI
referrer of the digest in the same repository (`--new-bundle-format`
defaults to true). GHCR answers `/v2/<name>/referrers/<digest>` with
404, so go-containerregistry lists the referrer under the fallback tag
`sha256-<hex>`, without `.sig`, which `cosign verify` reads the same
way; the `.sig` tag exists only with `--new-bundle-format=false`.
`hack/promote-retag.sh` copies a digest to its stable tag inside that
repository, so the stable release's images carry the rc's signatures.
`promote-rc.yaml::promote` runs the rc tree's script with
`--verify-only` before it stages the stable release, and prints a notice
instead for an rc cut from a tree without the script. Under
`--verify-only` cosign's stderr is kept, so a registry 429 or a Rekor
fetch error is not reported as a missing signature;
`docs/release/ci-failures.md` has a row for that step.

`hack/collect-image-sboms.sh` reads `docker buildx imagetools inspect
<ref> --format '{{ json .SBOM }}'` for the same refs, takes the
platforms the index serves from `--raw` (entries that are not
attestation manifests, keyed as buildx keys them), and writes
`<image>.<os>-<arch>.spdx.json` per platform (or `<image>.spdx.json` for
an image with one platform, whose SBOM buildx prints unkeyed) into
`cozystack-images-sbom.tar.gz`, with fixed order, times and owners so a
re-run gives the same bytes. An image without a non-null SBOM for every
platform its index serves fails the run, naming it and the platforms:
after #4997 every pinned first-party image is built with `SBOM=1`, so a
missing one is a lost attestation, and I preferred no allowlist over one
with no entry (the Talos installer image, which has no SBOM, is not
pinned in the tree).

`hack/upload-assets.sh` adds `cozystack-images.txt` (the refs, one per
line, from `--list`) and the archive to the list it hands to
`hack/sign-release-assets.sh`, so the existing checksums signature
covers both and nothing new signs anything. `promote-rc.yaml` downloads
every rc asset, so both travel to the stable release as the other assets
do. `docs/release/signatures-and-sbom.md` describes the two files and
the image signatures, drops #4997's "The attestations are not signed",
and gains a "How to verify a release" block that checks the checksums,
every asset, every image signature and unpacks the SBOMs in one go, the
image loop in a subshell that exits on the first image that fails;
`docs/agents/image-refs.md` lists the two new consumers of the
enumeration; the SBOM row and the "Signed / reproducible builds" gap of
`docs/security/self-assessment.md` now say what a release publishes and
signs.

### How it was checked

- Bats 1.14.0: `hack/sign-release-images.bats` (13 tests: the refs it
signs and skips, one `cosign sign` call per ref, the identity and issuer
it verifies, equality with the assets regexp and with
`docs/release/signatures-and-sbom.md`, the fenced verify block of
`docs/release/signatures-and-sbom.md` run with cosign stubbed, which
fails on a rejected first image, on a list read from stdin, on a
checksums file that lacks either image asset and on one that lists one
asset twice in place of the other, a failed verify, `--verify-only`,
`--list`, an empty tree, and the shape of both workflow steps by `yq`)
and `hack/collect-image-sboms.bats` (5: file names and content per
platform, member order, owners and times read from the archive headers,
the same bytes twice, an image without an SBOM, an index with an SBOM on
one platform only, a platform with `"SPDX": null`, an empty tree;
dropping `--sort=name`, the owner flags or `--mtime` fails it on XFS and
ZFS), both with cosign and docker stubbed; `hack/upload-assets.bats`
updated for the two assets; `hack/sign-release-assets.bats` and
`hack/ci-tool-installs-contract.bats` unchanged and green. The
repository's bats contract suites (strict setup, no negated asserts, no
exit traps, runner coverage) pass with the two new files. `make
bats-unit-tests`: see the last comment of this PR for the count.
- `shellcheck -x` on both scripts; `zizmor` on `tags.yaml` and
`promote-rc.yaml` reports nothing.
- Checked against the registry, not the code: GHCR has no referrers API
for a cozystack image (404), so the referrer lands in the `sha256-<hex>`
fallback tag; `hack/promote-retag.sh` copies within the repository; `gh
release download` in promote takes every rc asset.
- Not checked: a real keyless run (the first alpha after the merge, like
#4861 and #4997), a stitched index against a live registry (the `.SBOM`
shape follows buildx v0.31.0 `util/imagetools/printers.go`: keyed by
platform for more than one platform, bare otherwise; @lexfrei's ttl.sh
run on #4997 saw the map), and the time the signing adds to
`prepare-release`.

### Decisions for the release owners

- The packages artifact (`cozystack-packages`) and the installer chart
are not signed: promotion republishes both under a new digest, so
signing them means a signing step in `promote` too. Follow-up if wanted.
- Every pre-release signs about forty indexes, each with its own Fulcio
certificate and Rekor entry. #4861 already writes one per release, so
the policy question is settled; the volume is new.
- An image without an SBOM fails the release rather than being listed as
missing. If an exception appears, an allowlist with a reason, as
`hack/multiarch-allowlist`, is the shape to add.
- The identity regexp accepts `promote-rc.yaml` on `main` as well as
`tags.yaml` on a `v*` tag, though only `tags.yaml` signs images today,
so that `docs/release/signatures-and-sbom.md` has one expression for
every release signature. A reader who wants the tighter check drops the
alternative.

### Screenshots

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

### Downstream repositories

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

I walked the trigger map against the diff. `hack/upload-assets.sh` adds
two assets and renames none, so the install pages that hardcode asset
filenames on the website are untouched. `tags.yaml` gains a step between
the stitch and the upload and `promote-rc.yaml` a check before the
upload; who cuts and who promotes a release, which the ccp guidance
rests on, is the same. `hack/package.mk` and `hack/common-envs.mk` are
not touched.

### Release note

```release-note
feat(release): every first-party container image of a release is signed with cosign, keylessly, by the `tags.yaml` run that prepared it, and a release carries `cozystack-images.txt` (the pinned images by digest) and `cozystack-images-sbom.tar.gz` (the SPDX SBOM of each image, per platform) as assets covered by the signed checksums. `docs/release/signatures-and-sbom.md` shows how to verify a release end to end. Releases cut from this change on have them.
```



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

## Summary by CodeRabbit

* **New Features**
* Releases now include a list of pinned first-party image digests and an
archive of image software bills of materials (SBOMs), with coverage for
each image platform.
* Release image digests are signed, and release checksums cover the
image list and SBOM archive.
* RC promotion checks image signatures before creating a stable release;
unsigned images can block promotion.
* **Documentation**
* Added guidance on release image signatures, SBOM assets, verification,
and related release failures.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-30 21:41:44 +03:00
Timofei LarkinandIvanHunters 8a31d2b09f test(postgres): check that a minted password is shown only once
The e2e test mints a password, logs in with it, and checks every place
it could be read again: the account Secret must hold a SCRAM verifier,
decoded rather than matched in the raw base64; neither the application,
any Helm revision nor what the tenant's super-admins read through
tenantsecrets may carry it; and they cannot read the account Secret.
Each read is captured in an assignment, which stops the script on
failure, so a failed kubectl, base64 or gunzip cannot leave a check with
nothing to assert on, and at least one Helm release Secret is required.
The step runs under bash and passes the password to psql on stdin, never
as an exec argument.

Co-authored-by: IvanHunters <xorokhotnikov@gmail.com>
Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:27 +01:00
d7144cda9e feat(platform): migrate Postgres accounts to minted credentials
Migration 64 converts the existing Postgres releases. It first applies
the CredentialTemplate CRD baked into its image, owned by the
cozystack-controller release so that release's upgrade adopts it: on a
live upgrade the tenant releases switched to the converted chart about
17 minutes before cozystack-controller upgraded, and every render in
between failed on the unknown kind. It then runs credentials-migrate
seed, which writes the account Secrets from <release>-credentials so
clients keep logging in at every point of the upgrade. A release that
grants createRole is left out and keeps its previous chart.

The finish half runs from a Job the migration creates, not from the
platform chart: a chart-rendered Job has a fixed name and an image that
changes every release, so the next platform upgrade cannot patch its
immutable pod template, and helm-controller would wait on a Job that
runs up to 30 minutes and exits non-zero while any release is left out.
The Job runs the image the hook runs as, read from its own pod, under a
least-privilege ClusterRole rather than cluster-admin, and its
ServiceAccount is owned by the Job so the garbage collector removes it.
The identity carries the migration number like the Job, so a later
conversion migration cannot delete the ServiceAccount a still-running
earlier Job uses.

The CredentialsMigrationIncomplete alert keys on the incomplete label of
the state ConfigMap through kube-state-metrics, which allowlists only
that one ConfigMap label, so a release whose plaintext was never retired
stays visible after the Job's TTL. The bats suite pins the CRD apply,
seed, image read, Job apply, ownership and stamp steps as fail-closed;
its fake kubectl counts the Job's name inside the Job document only.

Co-authored-by: IvanHunters <xorokhotnikov@gmail.com>
Co-authored-by: Andrei Kvapil <kvapss@gmail.com>
Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:27 +01:00
Timofei LarkinandAndrei Kvapil c9653cbb79 build(platform): build credentials-migrate into the migrations image
The conversion migrations run credentials-migrate, which shares the
password format functions with the API so a converted release and a mint
store the same form, so the migrations image now builds it from this
repository and its build context is the repository root. The image also
carries the CredentialTemplate CRD for the migrations to apply. The
builder pins the Go version go.mod requires.

Co-authored-by: Andrei Kvapil <kvapss@gmail.com>
Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:27 +01:00
Timofei LarkinandIvanHunters f982ea2cb9 fix(examples): mint the Postgres password in the backup examples
The examples read the application password from <release>-credentials,
which the chart no longer renders. They now mint it and pass it to psql
on stdin rather than as a kubectl exec argument, which travels in the
request URI the audit log records at any level. The minted password is
cached in a per-run mktemp -d directory, private and fresh each run, so
a later run never reads a password a mint has since replaced and no
other host user can read it. The helper's tests stub the mint.

Co-authored-by: IvanHunters <xorokhotnikov@gmail.com>
Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:27 +01:00
a67fa94fdb feat(postgres)!: issue user passwords through the credentials API
The chart generated every user's password at render time into
<release>-credentials, which tenants could read again at any time and
which Helm history kept for MaxHistory revisions, so a deployment whose
policy requires a credential shown once could not run PostgreSQL here.

The chart now renders a CredentialTemplate per user, and the users move
under CloudNativePG's managed roles, each pointing at its account
Secret, so the operator creates the role with the SCRAM verifier the
Secret holds, applies a changed Secret live, and reverts a password set
inside PostgreSQL. Every role is rendered as the init-script created it,
because the operator reverts an attribute that differs, revokes a parent
role missing from inRoles and clears a comment the spec leaves unset.
The init-script stops creating, passwording and altering accounts, where
it would be a second writer, and keeps the two things the operator has
no field for: the marker membership and the reset of the
createrole_self_grant an earlier chart set. Its marking pass waits a
bounded time for CloudNativePG to create the declared roles before it
marks them. users.app adopts the owner CloudNativePG bootstraps, whose
password the instance manager applies again from the bootstrap secret
on every pod start, so that secret is the app user's account Secret
and both writers apply the one stored verifier. A users.<name>.password
left in values draws an admission warning that points at a mint on the
user's Credential.

createRole is refused on every render path. A role a CREATEROLE user
creates makes that user a member of it, CloudNativePG revokes every
membership a managed role is not declared to hold, and the revoke fails
on the dependent self-grant, so the user would sit in cannotReconcile on
ordinary use; there is no per-role switch to leave memberships alone.
The account-name checks render with the managed roles too, so a restore
cannot bypass them: a user CloudNativePG or PostgreSQL reserves, a
database whose derived <name>_admin or <name>_readonly role starts with
pg_ or cnpg_ (which makes the CloudNativePG webhook reject the whole
Cluster), and a user whose account name is no valid object name are
refused. The chart's account naming is pinned to the API's on one table
of names.

A pre-upgrade hook refuses to let CloudNativePG adopt a role the chart
did not mark, because the operator adopts a managed role within seconds
of the spec reaching it, before any post-upgrade job could look. It
reads the live Cluster first and connects to the database only when the
upgrade adds a name CloudNativePG does not manage yet, so a database
that is down does not block the resize that might fix it. For each
absent declared database role it creates and marks the role as the
superuser before the Cluster applies, so no tenant can plant it in the
adoption window. The refusal and the create run in one psql session,
keyed on a snapshot of the role's existence taken at the top, so a role
planted in between collides with the CREATE and stops the hook; the
statements are built with format() and \gexec, since psql does not
substitute :'role' inside a DO $$ block. Verified on postgres:18: a
fresh role is created NOINHERIT, commented and marked, a role planted
after the snapshot fails the hook, and an existing unmarked role is
refused. The hook reads the Cluster at run time with a ServiceAccount
that may get only that Cluster, rather than through a template lookup,
which nothing re-renders when the object changes. The flag an earlier
chart set when a user held createRole is still read and never set, so
such a release keeps refusing to adopt a role it did not mark.

The EndpointAttachment e2e suite read testuser's password from that
Secret to probe the attached addresses. It now mints one per probe and
waits until the application's own Service accepts it, so the attached
address is still queried exactly once.

BREAKING CHANGE: PostgreSQL passwords are no longer readable from
<release>-credentials. A password is issued once, by a mint on the
account's Credential in core.cozystack.io, and replaced by the next
mint. users.<name>.createRole is refused; a release that sets it keeps
its previous chart version and passwords until it is false. Deleting a
Postgres application whose release is suspended is refused. The
conversion needs a platform variant with migrations enabled.

Co-authored-by: IvanHunters <xorokhotnikov@gmail.com>
Co-authored-by: Andrei Kvapil <kvapss@gmail.com>
Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:27 +01:00
780a358083 feat(credentials-migrate): convert accounts to minted credentials
A converted chart reads each account's stored value from an account
Secret the platform keeps, and nothing writes those Secrets for the
applications that exist before the chart switches. Without a conversion
every existing account would stop logging in at the switch.

The command has two halves. seed runs from the platform's pre-upgrade
hook, before any component chart changes version: it writes the account
Secrets unowned, with the stored form of the password the tenant could
read until now and origin Migrated, records each release's chart
version, and marks a release for seeding only when every account got its
Secret, so the CredentialTemplate controller never seeds a random
password over one the release's clients still use. It takes the kind's
format and accounts path from flags, because the hook runs before the
converted chart renders any template. finish runs from a Job once the
charts have switched: per release it waits for the converted chart to be
Ready, strips any password left in the values and deletes the old source
Secret.

seed fails closed. Only a release whose accounts cannot be resolved from
its values is left out; any other error fails the hook and the upgrade
retries, since a left-out release whose source Helm then deletes would
keep neither an account Secret nor the plaintext. finish holds a release
recorded without a chart version rather than retiring it as soon as it
renders, old chart included.

A transient API or connection error is retried on the same release a few
times. If it persists, the release is recorded for the incomplete alert
but announced with CredentialsMigrationRetrying, a Normal event, since
the Job's restart retries it; only an error no retry fixes records the
Warning CredentialsMigrationSkipped "left this release out", which reads
as a release that needs a person. While any release is left out, the
state ConfigMap carries credentials.cozystack.io/incomplete=true.

The stored form comes from the platform's own format package, so a
migrated release and a mint store the same value.

Co-authored-by: IvanHunters <xorokhotnikov@gmail.com>
Co-authored-by: Andrei Kvapil <kvapss@gmail.com>
Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:14 +01:00
IvanHunters b4f2f13ce3 feat(credentials): tell whether a legacy password survives login
PostgreSQL applies SASLprep to the presented password at login, and
ALTER ROLE ... PASSWORD did the same when it stored the old verifier, so
a SCRAM verifier built from the raw bytes of a legacy password silently
fails to authenticate any password SASLprep changes, such as one
carrying a soft hyphen. CarriesOver tells the conversion which passwords
it may keep, so the rest are left to their first mint.

pg_saslprep returns every all-ASCII input unchanged through its
pg_is_ascii fast path before the prohibited-character step runs, so an
all-ASCII password, ASCII controls included, carries over. Every format
other than scram-sha-256 stores or hashes the raw bytes and always
carries over.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:13 +01:00
Aleksei Sviridkin c8ffc87717 fix(postgres): run the collation repair outside the Helm hook (#5479)
## What this PR does

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

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

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

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

Decisions for reviewers:

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

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

### Testing

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

### Downstream repositories

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

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

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

### Release note

```release-note
[postgres] An image change of a tenant PostgreSQL no longer fails the Helm upgrade while CNPG rolls the instances. The collation repair now runs in a separate `<release>-collation-repair` Job, started after each upgrade, which waits for the new image and retries after connection drops. Check that Job's status and log to confirm the repair finished.
```
2026-11-30 18:24:14 +03:00
Aleksei Sviridkin 0c00c4545e ci(release): refuse a Promote RC dispatch from any ref but main (#5181)
## What this PR does

Adds a first step to the `parse` job of `promote-rc.yaml` that fails
when `github.ref` is not `refs/heads/main`, before anything is written.
This is A20 in #3278.

A `workflow_dispatch` runs the copy of the workflow at the dispatched
ref. On 2026-10-16 a dispatch from `release-1.6` ran that branch's older
copy (one job instead of five,
https://github.com/cozystack/cozystack/actions/runs/38882938797) and was
re-run from `main`. Since #4861 the release assets are signed, and the
same dispatch would now fail at the upload step, after the staging
branch, the `promotion-*` candidate and the draft release already exist.
`docs/release.md` also pins the signature identity to this workflow on
`main`, so a dispatch from another ref should stop at the front door.

The step follows the shape of `Validate dispatch branch` in
`cut-prerelease.yaml`: one shell comparison, an `::error::` that names
`main`, `exit 1`.

## Test

`hack/promote-rc-dispatch-ref_test.bats` extracts the step's `run` with
`yq` and executes it under `dash` for `refs/heads/main` (passes), a
release branch, a tag and an empty ref (each fails and names `main`),
and pins the step to be `parse`'s first step reading `github.ref`. It
runs with the rest of `hack/*_test.bats` via `make bats-unit-tests`.
`zizmor` on the workflow reports no findings.

## Docs

One clause in step 3 of the regular release sequence in
`docs/release.md`. #5169 edits the same file further down and the
`promote` job of the same workflow; the hunks do not overlap.

## Checklist

- [x] Commit is signed off with `--signoff`
- [x] Commit carries exactly one `Assisted-by: LLM` trailer
- [x] `hack/check-commit-trailers.sh upstream/main..HEAD` passes
- [x] `bats hack/promote-rc-dispatch-ref_test.bats` and `bats
hack/bats-strict-setup.bats` pass

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

## Summary by CodeRabbit

* **Workflow Updates**
* Release candidate promotions dispatched from branches or tags other
than `main` are rejected. Older workflow copies on release branches may
still create a staging branch and draft release before stopping.
* **Documentation**
* Release instructions clarify that promotions must be dispatched from
`main`, regardless of the release line, and note the behavior of older
workflow copies.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-30 18:18:50 +03:00
Marian Koreniuk b08b4949eb feat(release): sign the release images and attach their SBOMs
A release has signed its assets since #4861, but not the container
images a cluster installed from it pulls, and the SBOM each image carries
since #4997 sat in the registry only, readable with buildx and signed by
nothing. A user could verify the ISO they booted and not the platform it
installed.

hack/sign-release-images.sh signs every first-party digest the repinned
tree holds with cosign, keylessly, in prepare-release after the stitch,
one cosign call per digest so that cosign's per-call timeout does not
grow with the number of images. It skips a digest that already
verifies, so a re-run stacks no second signature, and verifies each one
against the identity docs/release/signatures-and-sbom.md names before
hack/upload-assets.sh runs, so nothing is uploaded over an unsigned
image. The draft release is created only after that step, so a failed
signing run leaves no draft for a re-run to take for a finished
release. The signature over an index covers the attestation manifest
the index lists, so the SBOM needs none of its own, and cosign stores it
as a referrer of the digest in the repository hack/promote-retag.sh
copies the digest within, so promote-rc.yaml only verifies, with the rc
tree's script, before it stages the stable release, and prints cosign's
reason for every digest that fails.

hack/collect-image-sboms.sh reads the SBOM attestation of every such
image back into cozystack-images-sbom.tar.gz, one SPDX document per
platform, and fails on an image that lacks one for any platform its
index serves. With cozystack-images.txt, the digests the signatures are
bound to, both join the asset list hack/upload-assets.sh hands to
hack/sign-release-assets.sh, so the existing checksums signature covers
them. docs/release/signatures-and-sbom.md gains the verification recipe
for a whole release, which requires a signed checksum entry for each of
the two image assets; cozystack-scheduler, whose image a separate
repository builds, is not in the list. The bats files pin the scripts,
the recipe, the upload list and the two workflow steps.

Refs #2937, #3278

Assisted-by: LLM
Signed-off-by: Marian Koreniuk <moriarti@cp.if.ua>
2026-11-30 15:22:01 +01:00
Aleksei Sviridkin a768c81b49 feat(linstor): add Blockstor as a selectable storage backend (#2942)
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
- Scopes are not an exhaustive list; pick the most specific scope for
the change and extend the list when a genuinely new area appears.
Examples:
- System components: dashboard, platform, operator, cilium, kube-ovn,
linstor, fluxcd, cluster-api
- Managed apps: postgres, mariadb, redis, kafka, clickhouse,
virtual-machine, kubernetes
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or
add a `BREAKING CHANGE:` footer
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Add the label `kind/backport` if it's a bugfix that needs to be
backported to a previous version.
-->

## What this PR does

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

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

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

Default path:

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

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

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

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

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

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

RBAC and exposure:

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

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

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

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

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

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

### Testing

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

### Not tested

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

### Screenshots

N/A, no UI change.

### Downstream repositories

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

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

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: https://github.com/cozystack/website/pull/667 documents the
backend, `storage.acknowledgeBackendChange` and this chart. It still
describes blockstor 0.2.0 and has to follow this PR to 0.4.0 and to the
master key opened from `linstor-passphrase`. Its LINSTOR to Blockstor
migration guide belongs with #5466. It stays unticked and merges after
this PR.
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

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

### Release note

```release-note
feat(linstor): Blockstor can be selected as the storage control plane for new clusters with `storage.backend: blockstor` on the platform. LINSTOR stays the default and existing clusters are unchanged. Blockstor is experimental, and moving a cluster that already has LINSTOR volumes to it is not part of this change.
```
2026-11-30 15:47:15 +03:00
Aleksei Sviridkin 23b94d6d1a feat(workloadmonitor): report failed Jobs that opt in as not operational (#5505)
## What this PR does

Refs #5459

A chart that runs workload-critical work in a Job outside its Helm
release has no way to report a failed run on the Application today:
`Ready` mirrors the HelmRelease, which is already applied, and
`WorkloadsReady` only looks at pods, PVCs, Services, BucketClaims and
DataVolumes. The immediate case is #5479, where the postgres collation
repair and PostGIS update move out of a blocking hook into a Job started
outside the release. If that Job fails (duplicates under a UNIQUE index,
a PostGIS update that does not go through), the indexes stay wrong while
the Application shows `Ready=True` and `WorkloadsReady=True`.

This PR implements the proposal in
https://github.com/cozystack/cozystack/issues/5459#issuecomment-7268007229
by adding a generic rule to the WorkloadMonitor controller: a `batch/v1`
Job in the monitor's namespace that carries the monitor's selector
labels plus `workloads.cozystack.io/report-failure: "true"`, and has
`Failed=True`, makes the monitor not operational, with reason
`JobFailed` and a message such as `Job postgres-x-collation-repair
failed: BackoffLimitExceeded: Job has reached the specified backoff
limit`. cozystack-api passes it through unchanged as
`WorkloadsReady=False` with that reason and message. The rule knows
nothing about postgres: a chart opts a Job in explicitly with that
label. A Job with only the selector labels, which every chart and every
operator inheriting labels from the workload may carry, never affects
the monitor. The postgres side (the labels on the repair Job, no
`ttlSecondsAfterFinished`) lands on #5479.

Behaviour:

- A Job that is deleted, or replaced by a run that does not fail, clears
the verdict. Of the Jobs one controller owns, only the newest counts, so
a CronJob's failed run that stays in its history after a later success
does not keep the monitor down.
- The message lists failed Jobs sorted by name, at most three, then `N
more Jobs failed`.
- Precedence: a DataVolume verdict comes first (unchanged; its stored
value is kept while DataVolumes cannot be read), then `JobFailed`, then
`BucketClaimNotReady`. `minReplicas` still sets `Operational=false`
without a reason, so a failed Job beside too few replicas reports
`JobFailed`.
- Jobs are watched and mapped to monitors the same way pods are. The
manager caches only Jobs that carry the opt-in label, with a transform
that keeps only metadata (labels, owners, timestamps) and conditions.
- RBAC: a `+kubebuilder:rbac` marker for `jobs.batch` get/list/watch
documents the need. The markers under `internal/controller` do not
generate YAML, and the cozystack-controller ClusterRole in
`packages/system/cozystack-controller/templates/rbac.yaml` already
grants get/list/watch on every resource, as it does for pods, PVCs,
BucketClaims and DataVolumes, so the chart needs no change.

No chart sets the opt-in label yet, so nothing reports until a chart
adopts it. The postgres chart sets the selector labels in the Cluster's
`inheritedMetadata`, so CNPG's initdb and join Jobs carry them; without
the opt-in they are ignored, as are backup CronJob runs and any other
labelled Job.

### Testing

- `go build ./...`, `go vet` on `./internal/controller/`,
`./cmd/cozystack-controller/`, `./api/v1alpha1/`: clean.
- `go test ./internal/controller/... ./pkg/registry/apps/application/...
./api/...`: pass.
- New unit tests (fake client): a failed Job sets `Operational=false`,
reason `JobFailed` and the message; a succeeded, running, `Failed=False`
or other-selector Job, and a failed Job without the opt-in label or with
it set to anything but `"true"`, has no effect; a failed Job deleted or
replaced by a successful run clears the verdict; a stale `JobFailed` is
cleared before the DataVolume reader is installed; precedence against
`minReplicas`, an unprovisioned BucketClaim and a DataVolume verdict;
message sorting, the three-Job bound, newest-run-per-controller and Jobs
being deleted; the cache transform keeps what the rule reads.
cozystack-api: a monitor with `JobFailed` yields `WorkloadsReady=False`
with that reason and message.
- `make generate`: no changes.
- Not run against a cluster: the Job watch and the transformed cache
were not exercised end to end.

### Downstream repositories

Walked the trigger map against the diff
(`api/v1alpha1/workloadmonitor_types.go` constant only, no CRD schema
change; `internal/controller`; `cmd/cozystack-controller`; tests). No
package, platform values, ApplicationDefinition, installer, hack
tooling, telemetry or commit-convention change.

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

### Release note

```release-note
feat(workloadmonitor): a failed Job that carries a WorkloadMonitor's selector labels and `workloads.cozystack.io/report-failure: "true"` now makes the workload not operational, so the Application reports `WorkloadsReady=False` with reason `JobFailed` and a message naming the Job and its failure. Deleting the Job, or a later run that does not fail, clears it.
```
2026-11-30 14:04:15 +03:00
Andrey Kolkov 66bba3bf1e fix(postgres): run the collation repair outside the Helm hook
The collation repair ran at the end of the post-upgrade init-job and,
when the image moved, waited for the primary to run it. Helm starts that
hook as soon as the Cluster is patched; CNPG then rolls the replicas
first and the primary last, and every instance whose clients hold
sessions sits in smart shutdown for smartShutdownTimeout (180s on
existing clusters). With three instances the wait took about eight of
the Job's nine minutes, the Job printed "the init-job is out of time,
the next run of it carries on" and the HelmRelease went UpgradeFailed
until Flux retried. When the Job's psql met the primary restart instead,
it failed with "FATAL: the database system is shutting down" and failed
the upgrade the same way. A rebuild of a large index does not fit the
hook budget either.

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

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

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

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

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

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

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

Refs: #5459
Assisted-By: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-30 17:58:17 +07:00
Andrey Kolkov 5795b5f658 feat(workloadmonitor): report failed Jobs that opt in as not operational
Some charts run work that matters to the workload in a Job outside the Helm
release, such as an index repair after an image upgrade. Once the release has
applied, Ready stays True whatever that Job does, so a failed run was visible
only to someone who went looking for the Job.

A Job that carries a monitor's selector labels and
workloads.cozystack.io/report-failure set to "true", and has Failed=True, now
makes the monitor not operational with reason JobFailed and a message naming
the Job and its failure, which the Application surfaces as
WorkloadsReady=False. The opt-in is explicit because the selector labels
alone are carried by Jobs that say nothing about the workload's health: Jobs
an operator labels by inheritance from the workload, such as CloudNativePG's
initdb and join Jobs under the postgres chart, and backup runs. Of the Jobs
one controller owns only the newest counts, because a CronJob keeps failed
runs in its history after a later run succeeds; a Job that is deleted or
replaced by a successful run clears the verdict.

A DataVolume verdict still comes first, since its stored value is kept across
restarts until the DataVolumes can be read again. A failed Job outranks an
unprovisioned BucketClaim: it stays failed until something replaces it, while a
claim is usually still being provisioned.

The manager caches only Jobs that carry the opt-in label, and of them only
their metadata and conditions. The controller's ClusterRole already grants
read on every resource.

Refs: #5459
Assisted-By: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-30 13:42:03 +07:00
Aleksei Sviridkin 222c31fcf8 fix(seaweedfs): pin the in-tree image to a build ghcr serves (#5503)
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Types: feat, fix, security (a fix that comes through a security
advisory), docs, style, refactor, perf, test, build, ci, chore
- Scopes are not an exhaustive list: pick the most specific scope for
the change and extend the list when a genuinely new area appears.
Examples:
- System components: dashboard, platform, operator, cilium, kube-ovn,
linstor, fluxcd, cluster-api
- Managed apps: postgres, mariadb, redis, kafka, clickhouse,
virtual-machine, kubernetes
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or
add a `BREAKING CHANGE:` footer
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Fixes merged to `main` reach the release lines the backport batch runs
for automatically, so do not open backport PRs by hand:
https://github.com/cozystack/cozystack/blob/main/docs/release/backports.md
-->

## What this PR does

The in-tree seaweedfs pin on main points at `4.48@sha256:5360a02b...`, a
pull request build that only ever lived in the CI registry. That
registry has pruned it and ghcr never had it, so any install that does
not overlay current-main refs fails to pull the image.

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

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

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

### Screenshots

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

### Downstream repositories

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

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

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

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

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

### Release note

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

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


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

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

## Summary by CodeRabbit

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

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-30 00:59:23 +03:00
Aleksei Sviridkin 0f84f1c8dc fix(postgres): rebuild indexes on C.UTF-8 when the Debian release changes (#5478)
## What this PR does

Refs #5459 (item 1: `C.UTF-8` is not repaired and nobody is warned).

After the move to the `-standard-trixie` operand images, an index on a
`COLLATE "C.UTF-8"` column, or any text index in a database created with
`LC_COLLATE 'C.UTF-8'`, is silently corrupt: Debian bullseye's patched
`C.UTF-8` and the glibc 2.35+ `C.UTF-8` order characters differently,
but PostgreSQL records no collation version for `C.*` locales, so the
collation repair in the init Job never selected those indexes. On
PostgreSQL 15+ there was not even a warning. Lookups through such an
index miss rows, and a unique index on it stops seeing duplicates.

One commit. The repair pass now treats libc `C.<codeset>` collations,
and a libc `C.<codeset>` database default, as versioned by the Debian
release of the server's build (the `pgdgNN` suffix of `server_version`).
Their indexes then go through the existing resumable rebuild path (OID
mark, in-place handling for exclusion constraints, `_ccnew` leftovers,
unique-duplicate failure reporting), which this PR leaves unchanged.
Because PostgreSQL stores nothing to compare with, the release each
database was last repaired for is stored in a new per-database setting,
`cozystack.collation_release`, next to the existing
`cozystack.collation_repair`:

- a database without the setting gets the release of the server the pass
first sees it on. The pass looks before it waits for the rollout, so the
old release is persisted even if that run fails, and a retry that runs
after the primary restarted still rebuilds;
- if the server already runs the new glibc when the pass first sees the
database, a libc collation whose recorded version differs from the
server's (`en_US.utf8` 2.31 vs 2.41, present in every database created
from these images) marks it as not repaired for any release;
- otherwise (a new cluster, a database added later) the current release
is recorded and nothing is rebuilt;
- the setting is updated to the current release only when the database
is repaired without failures.

The PG<15 warning `database ... uses the locale C.UTF-8, for which this
PostgreSQL major records no collation version ...` no longer fires for
`C.*` locales, since those are now repaired. The range-partition warning
says for a `C.*` key that it is reported only once, instead of claiming
that a collation version was left as recorded.

The e2e postgres suite now also sets another release on its database,
creates a unique `C.utf8` column, and checks that the upgrade rebuilds
that index, that amcheck passes on it, and that the setting ends at the
server's release.

The change stays inside the `== refresh collation versions` SQL prelude
and its final block. It does not touch the rollout wait, the per-index
rebuild session or the extension section, which other open fixes for
#5459 change.

### What it cannot see

A cluster where a pass without this change already ran on the new glibc
(v1.7.2-rc.1, or `main` since #5405) has already refreshed its libc
collation versions, so no trace of the move is left. This pass then
records the current release for it and does not rebuild its `C.*`
indexes. Rebuild those by hand with `REINDEX INDEX CONCURRENTLY` (or
`REINDEX DATABASE`), as the release note says.

### Coordination with #5472

#5472, now merged, told operators in the `allowCollationChange`
description to rebuild indexes on `C.UTF-8` by hand. This PR merges
second, so it drops that sentence from `values.yaml`, `types.go`, the
README, the schema and the cozyrd: the init Job now rebuilds those
indexes itself.

### Testing

Docker, no Kubernetes: data written on
`ghcr.io/cloudnative-pg/postgresql:17.7` / `13.22` (bullseye, glibc
2.31, `pgdg11`), then the same data directory started on
`17.12-standard-trixie` / `13.22-standard-trixie` (glibc 2.41,
`pgdg13`). The repair section was rendered with `helm template`,
extracted from the init-script Secret, and run from a container of the
trixie image with the env the Job sets (`PGHOST`, `PGUSER`,
`JOB_DEADLINE`). Data: 200,000 distinct keys mixing ASCII punctuation,
`é`, U+FFFD, U+FFFF, U+1D400 and U+1F600. Tables: a `UNIQUE` column
`COLLATE "C.UTF-8"`, an `en_US.utf8` column, a plain `C` column, and a
`cutf8db` database with `LC_COLLATE 'C.UTF-8'`.

| Scenario | Result |
| --- | --- |
| Pass from `main`, PG17 and PG13 | rebuilds only the `en_US.utf8`
index; `t_c_k_key`: `item order invariant violated`, 178,162 of 200,000
keys not found; `cutf8db.t_d_k`: 179,426 not found |
| This PR, Job starts on bullseye, server then restarts on trixie (PG17,
PG13) | `pgdg11` recorded while waiting; `C.UTF-8` column index,
`C.UTF-8` database default index and `en_US.utf8` index rebuilt; amcheck
ok, 0 misses; plain `C` index keeps its OID |
| This PR, first run times out waiting for the rollout, retry after the
restart (libc versions refreshed by hand in between so only the
persisted release can trigger) | retry rebuilds both `C.*` indexes;
amcheck ok, 0 misses |
| This PR, server already on trixie at first run | detected through the
stale libc collation versions; both `C.*` indexes rebuilt |
| Second and third run | nothing rebuilt, setting stays `pgdg13` |
| New cluster created on trixie | nothing rebuilt, `pgdg13` recorded |
| Range partitions on `C.UTF-8` and on `en_US.utf8` | partition indexes
rebuilt once; the `C.*` partition warned once; later runs rebuild
nothing |

`helm unittest packages/apps/postgres`: 31 suites, 247 tests passed.

Dev cluster (cozystack v1.7.0):

- Setup: an app installed from the v1.7.1 chart (`postgresql:17.7`,
bullseye, 2 instances). In `appdb`, a `UNIQUE` column `COLLATE
"C.UTF-8"` with 50,000 keys built from ASCII letters and punctuation,
`é`, U+FFFD, U+1D400 and U+1F600.
- `helm upgrade` to this branch passed on the first attempt. The init
Job logged `rebuilding index public.t_c_k_key in database appdb: its
collation changed version`.
- Afterwards:
  - the Cluster runs `17.12-standard-trixie`;
  - the index OID changed (16424 → 16507);
- `bt_index_check(t_c_k_key, true)` is clean on the primary, on the
replica and through `-ro`, with 0 lookup misses;
  - `cozystack.collation_release` is `pgdg13`.
- A second upgrade rebuilt nothing.

The extended chainsaw e2e step has not run yet, so CI will be its first
run.

Docker, with the rendered repair pass run against
`17.12-standard-trixie` and `UNIQUE` columns `COLLATE "C.utf8"`:

- A database with no recorded release and a stale libc collation
(`CREATE COLLATION ... (provider = libc, locale = 'en_US.utf8', version
= '0')`): the index is rebuilt and `pgdg13` is recorded.
- A database whose only stale piece is its libc default collation
(`datcollversion` changed): the index is rebuilt, and `pgdg13` is
recorded.
- A fresh database: nothing is rebuilt, and `pgdg13` is recorded.
- A second run rebuilds nothing.

The e2e suite now also covers a database with no recorded release, the
state every existing cluster starts from. That database holds a stale
`en_US.utf8` libc collation and a `UNIQUE` column on `C.utf8`, and the
test asserts the new index OID, `bt_index_check`, and the recorded
release. A libc collation on locale `C` with an explicit version cannot
serve as the probe: `ALTER COLLATION ... REFRESH VERSION` refuses to
move it to the NULL version of a `C` locale.

### Downstream repositories

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

The diff touches only
`packages/apps/postgres/templates/init-script.yaml` and the postgres e2e
test. No values, schema, README, API or CRD change, so none of the
generated reference docs move. Boxes are left empty for a maintainer to
decide: the website may describe the trixie move and its collation
repair in upgrade notes, and if it lists which collations get repaired,
`C.UTF-8` should be added there. I did not check that.

### Release note

```release-note
[postgres] The init Job now also rebuilds indexes on libc `C.UTF-8` (and other `C.<codeset>`) collations, and on databases whose default collation is such a locale, when the server moves to an image built on another Debian release. PostgreSQL records no version for these collations, so before this fix such indexes stayed corrupt after the move to the standard-trixie images, with no warning. The Debian release each database was repaired for is kept in the `cozystack.collation_release` database setting. A cluster that already ran the previous repair on a trixie image (v1.7.2-rc.1 or a `main` build since the move) is not recognised: rebuild its indexes on `C.*` collations by hand with `REINDEX`.
```


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

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

## Summary by CodeRabbit

* **Bug Fixes**
* PostgreSQL collation repair now detects changes affecting
`C.<codeset>` collations across PostgreSQL build releases, including
cases where PostgreSQL does not record collation versions. Affected
indexes are identified and rebuilt during repair.
* Partition-related warnings clarify when collation changes can or
cannot be detected. After repair, the process records the PostgreSQL
release to help identify when a later repair may be needed.
* **Documentation**
* Updated `allowCollationChange` guidance to explain that the
initialization process rebuilds indexes for `C.UTF-8` and other `C.*`
locales, removing the instruction to rebuild those indexes manually.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Refs: #5459
Fixes: b40be51a6b ("fix(postgres): move the default flavor to patched standard-trixie images")
Fixes: a10e449a56 ("fix(postgres): rebuild indexes whose collation changed version")
Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-28 09:32:53 +07:00
Aleksei Sviridkin 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
Marian Koreniuk e89821ca2e ci(release): refuse a Promote RC dispatch from any ref but main
A workflow_dispatch runs the copy of promote-rc.yaml at the ref it was
dispatched from. On 2026-10-16 a dispatch from release-1.6 ran that
branch's older copy, one job instead of five, and had to be re-run from
main. Since the release assets are signed, the same dispatch would now
fail at the upload step, after the staging branch, the promotion-*
candidate and the draft release already exist, and
docs/release/signatures-and-sbom.md pins the signature identity to this
workflow on main.

Make the first step of parse compare github.ref with refs/heads/main and
fail with an error that names main, so a dispatch from a release branch,
a tag or a SHA stops before the first write. The bats test runs the
step's shell under dash for main, a release branch, a tag and an empty
ref, and pins the step to be the first one in parse.

The release docs tell the operator to dispatch from main and state that
only a copy carrying the check refuses other refs: older release-X.Y
copies stay callable and still write before stopping.

Assisted-by: LLM
Signed-off-by: Marian Koreniuk <moriarti@cp.if.ua>
2026-11-27 19:14:10 +01: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