Files
cozystack/packages/apps/postgres/templates/_versions.tpl
T
Myasnikov Daniil 643ee1e7af revert(postgres): take the standard-trixie image move out of release-1.7
The upgrade test from v1.7.1 to v1.7.2-rc.1 on a live cluster found
blockers in this change, so v1.7.2 ships tenant PostgreSQL as v1.7.1
had it, and the change comes back to this line once the fixes are on
main.

This reverts the unit e4b2e99378 that the 2026-11-13 backport batch
carried for #5405 (main 30ce2a3cb1).

CVE-2026-116331 stays open for tenant PostgreSQL on this line until
then: CloudNativePG publishes the fixed minors (18.7, 17.12, 16.16,
15.20, 14.25) only as bookworm and trixie images, with no bare
(bullseye) tag, so the fix needs the image move this reverts.

A cluster that ran v1.7.2-rc.1 is on the standard-trixie images
already. Moving it to this revision puts it back on the bullseye
images without the collation rebuild, so its text indexes on a non-C
collation need a REINDEX afterwards, and a database whose postgis
extension was updated to 3.7.0 does not load with the 3.6.1 image.
No stable 1.7 release carried #5405.

The picks of #5405 stay in this line's history, and backport-batch
counts an original as carried by those picks, so the next batch does not
take #5405 again.

Refs: #5459
Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-26 15:06:20 +00:00

64 lines
3.7 KiB
Smarty

{{- define "postgres.versionMap" }}
{{- $versionMap := .Files.Get "files/versions.yaml" | fromYaml }}
{{- if not (hasKey $versionMap .Values.version) }}
{{- printf `PostgreSQL version %s is not supported, allowed versions are %s` $.Values.version (keys $versionMap) | fail }}
{{- end }}
{{- index $versionMap .Values.version }}
{{- end }}
{{- define "postgres.postgisVersionMap" }}
{{- $versionMap := .Files.Get "files/postgis-versions.yaml" | fromYaml }}
{{- if not (hasKey $versionMap .Values.version) }}
{{- printf `PostgreSQL version %s is not supported by the postgis flavor, allowed versions are %s` $.Values.version (keys $versionMap | sortAlpha) | fail }}
{{- end }}
{{- index $versionMap .Values.version }}
{{- end }}
{{/*
Single source for the operand image: the init Job runs psql against the
Cluster, so both must resolve the same image.
*/}}
{{- define "postgres.imageName" -}}
{{- if eq (default "postgresql" .Values.flavor) "postgis" -}}
ghcr.io/cloudnative-pg/postgis:{{ include "postgres.postgisVersionMap" . | trim }}
{{- else -}}
ghcr.io/cloudnative-pg/postgresql:{{ include "postgres.versionMap" . | trim | trimPrefix "v" }}
{{- end -}}
{{- end -}}
{{/*
The flavor is fixed at bootstrap. The two image families are built on
different Debian releases, so moving a live cluster from one to the other
swaps glibc under an initialised data directory and silently invalidates
every index on collatable text; the postgis-to-postgresql direction also
drops the shared libraries behind every PostGIS object. CNPG would roll
either change out as an ordinary image update, so refuse it here, before
the Cluster is patched. Only the image name is compared: a minor bump or
a registry mirror rewriting the host must keep passing.
A physical recovery carries the same data directory across, so it is held
to the same rule. With no live Cluster of its own yet, the release is
checked against its recovery source while that Cluster still exists; once
the source is gone the chart has nothing to compare against, and the
backup-controller's RestoreJob, which records the flavor on every Backup,
is the path that enforces it.
*/}}
{{- define "postgres.flavorGuard" -}}
{{- $wantName := regexReplaceAll "[:@].*$" (last (splitList "/" (include "postgres.imageName" .))) "" -}}
{{- $live := lookup "postgresql.cnpg.io/v1" "Cluster" .Release.Namespace .Release.Name -}}
{{- if and $live $live.spec $live.spec.imageName -}}
{{- $liveName := regexReplaceAll "[:@].*$" (last (splitList "/" $live.spec.imageName)) "" -}}
{{- if ne $liveName $wantName -}}
{{- fail (printf "postgres: flavor cannot change on an existing cluster (running %s, requested %s). The image families use different glibc versions, which would corrupt text indexes. Create a new Postgres with the wanted flavor and move the data with a logical dump (pg_dump / pg_restore); restoring a backup keeps the flavor it was taken from." $liveName $wantName) -}}
{{- end -}}
{{- else if and .Values.bootstrap.enabled .Values.bootstrap.oldName -}}
{{- $source := lookup "postgresql.cnpg.io/v1" "Cluster" .Release.Namespace .Values.bootstrap.oldName -}}
{{- if and $source $source.spec $source.spec.imageName -}}
{{- $sourceName := regexReplaceAll "[:@].*$" (last (splitList "/" $source.spec.imageName)) "" -}}
{{- if ne $sourceName $wantName -}}
{{- fail (printf "postgres: cannot recover a %s backup of %s into the %s flavor. A physical restore keeps the source's glibc and libraries, which would corrupt text indexes. Set flavor to match the source, or create the new Postgres empty and move the data with a logical dump (pg_dump / pg_restore)." $sourceName .Values.bootstrap.oldName $wantName) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}