Files
cozystack/packages
Aleksei Sviridkin 406837f784 [Backport release-1.6] fix(postgres): move tenant PostgreSQL to patched standard-trixie images (#5555)
## What this PR does

Supersedes #5433, which has the same head (fd1c38e19) and was approved
there. It moves to a branch in this repository because the CI of a fork
PR cannot push images to the registry, so the package builds failed and
E2E never ran.

Refs #5459. Backport of #5405 to `release-1.6` together with the fixes
#5459 asked for, as [fixes that exist only on a release
line](https://github.com/cozystack/cozystack/blob/main/docs/release/backports.md#fixes-that-exist-only-on-a-release-line)
describes. The same set went to `release-1.7` as #5526.

**Merge order.** No 1.7 release carries #5526 yet; v1.7.0 through v1.7.3
pin the bullseye images. A 1.6 patch with this change, released before a
1.7 patch with #5526, would let a cluster upgrade from it to such a
release and go back to bullseye, with nothing to rebuild its indexes.
Release this only after a 1.7 patch that carries #5526.

Commits, rebased onto the current `release-1.6`:

1. Hand port of #5405, part 1: the collation repair pass.
2. Hand port of #5405, part 2: the move to `<minor>-standard-trixie`,
with each major bumped to the minor that fixes CVE-2026-116331 (13 stays
on 13.22).
3. #5485: skip an index while another session builds on its table.
4. #5472: keep bullseye clusters on their image until a clean locale
check. **Adapted.**
5. #5478: rebuild indexes on `C.UTF-8` and other `C.*` collations when
the Debian release changes.
6. #5505: a failed Job that opts in with
`workloads.cozystack.io/report-failure` makes the WorkloadMonitor not
operational. **Reduced.**
7. #5479: run the collation repair in a Job outside the Helm hook.
**Adapted.**

#5477 (PostGIS extension update) is not carried, because 1.6 has no
postgis flavor. Each fix is `git cherry-pick -x -m 1` of its merge
commit, and each adapted one explains the adaptation in its commit
message.

### What differs from main

- **No postgis flavor.** None of the following is carried: the flavor
conditions in the hold rules, the flavor guard, the postgis image
branch, the `flavor` value, the PostGIS update in `repair.sh`, and the
postgis test cases. Nothing in the chart reads `.Values.flavor`.
- **#5472, backup driver.** The CNPG backup driver on 1.6 predates the
destination, artifact-size, flavor and major-version changes that the
main version builds on. Only the image handling is ported: the live
Cluster's `spec.imageName` goes into the backup snapshot, and the
restore passes it to the chart as `bootstrap.sourceImageName`. The 1.6
driver never sets `bootstrap.enabled` back to false and does not compare
the backup's major with `spec.version`. So the value is set or cleared
on every restore instead of being cleared with `bootstrap.enabled`, and
the major is not read from the image.
- **#5505, WorkloadMonitor.** On 1.6 the WorkloadMonitor status has only
`operational`, and adding `reason`/`message` would be a CRD change. Only
the rule is ported:
- A Job that carries the monitor's selector labels and
`workloads.cozystack.io/report-failure: "true"` and has `Failed=True`
makes the monitor not operational. Only the newest Job per controller
owner counts. The Job cache is filtered by that label and stripped.
- The application shows `WorkloadsReady=False` with the existing
`WorkloadMonitorCheck` reason, and the failed Job is named in the
controller log.
  - The CRDs are unchanged.
- **#5479.** The adopted-restore record that main moves to the end of
`init.sh` does not exist on 1.6. The init Job's deadline comment now
describes what `JOB_DEADLINE` bounds there: the reruns of `run.sh`.
- **Identical to main:** `collation-repair.yaml`,
`locale-check-hook.yaml`, `collation_repair_test.yaml`, and `repair.sh`
apart from the PostGIS pass. `locale_guard_test.yaml` and
`_versions.tpl` differ only by the removed postgis parts.

### What a 1.6 user gets

- Clusters on the bare bullseye tags (13.22, 14.20, 15.15, 16.11, 17.7,
18.1) stay on them until a pre-upgrade check finds nothing that depends
on a changing collation, or until `allowCollationChange: true` is set. A
held cluster gets no further minors, so CVE-2026-116331 stays open on
it.
- A clean or opted-in cluster moves to `standard-trixie`. The
`<release>-collation-repair` Job repairs its indexes after the rollout,
and the HelmRelease does not wait for that Job. A failed repair shows as
`WorkloadsReady=False`.
- After a restore through the backup driver, `bootstrap.enabled` stays
true on 1.6, as it did before this change. Until an operator sets it
back to false, the init Job, the locale check and the collation repair
do not run, and a cluster restored from a bullseye backup stays on
bullseye.

### Testing

- `go build ./...`, and `go vet` on `internal/controller`,
`internal/backupcontroller/...`, `cmd/cozystack-controller` and
`api/v1alpha1`: clean.
- `go test ./internal/controller/ ./internal/backupcontroller/...
./pkg/registry/apps/application/`: pass.
- `helm unittest packages/apps/postgres`: 106 passed.
- `make generate`, both in `packages/apps/postgres` and at the root,
leaves the tree clean. No CRD changes against `release-1.6`.
- `helm template` (install and `--is-upgrade`) renders the init Job and
the repair starter. The rendered `run.sh`, `init.sh` and `repair.sh`
pass `bash -n`, and the starter script passes `sh -n` (dash, busybox).
- `hack/check-commit-trailers.sh origin/release-1.6..HEAD` (the script
from main): OK.
- Dev cluster run at 4e6f5743e, whose tree differs from this head only
by two value docs: all six scenarios passed
([results](https://github.com/cozystack/cozystack/pull/5433#issuecomment-7313792086)).

### Screenshots

### Downstream repositories

Walked the trigger map against the diff. The postgres
`values.schema.json` gains `allowCollationChange` and
`bootstrap.sourceImageName`, the same fields as on main and 1.7, so the
follow-up is cozystack/terraform-provider-cozystack#91. No other trigger
applies.

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: cozystack/terraform-provider-cozystack#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] Tenant PostgreSQL moves to the minors that fix CVE-2026-116331 (18.7, 17.12, 16.16, 15.20, 14.25; 13 stays on 13.22 and remains exposed) on the standard-trixie images, with a safe collation repair. A cluster still on a Debian bullseye image stays on it until a pre-upgrade check finds nothing that depends on a collation other than C, POSIX or builtin, or until `allowCollationChange` is set; a held cluster gets no further minors. The index repair, including indexes on C.UTF-8, runs in a `<release>-collation-repair` Job after the rollout instead of blocking the upgrade, and a failed repair shows on the application as `WorkloadsReady=False`. After a restore, set `bootstrap.enabled` back to false so that the check and the repair run. Upgrade from this release only to a v1.7 patch that carries #5526.
```
2026-12-02 11:44:03 +03:00
..