Files
cozystack/packages/apps/postgres/tests/flavor_test.yaml
T
Andrey Kolkov b40be51a6b fix(postgres): move the default flavor to patched standard-trixie images
The default flavor pinned bare image tags, which are the system variant
on Debian bullseye. Upstream stopped building that variant, so the minors
that fix CVE-2026-116331 (18.7, 17.12, 16.16, 15.20, 14.25) are published
for bookworm and trixie only. The CVE is a type confusion in the min/max
aggregate optimisation that lets a role able to create objects run code
as the operating system user of the server, and tenants hold such roles.

Pin the patched minors on standard-trixie, and move the postgis flavor to
the same minors. The standard variant, because backups go through the
barman-cloud plugin and need none of the barman binaries the system
variant adds. trixie, because the postgis flavor is on it already, so
both image families share one Debian release. PostgreSQL 13 has no
patched release: it keeps 13.22 and moves to trixie with the rest.

For a running default-flavor cluster this changes the Debian release under
the data directory. The init Job rebuilds the indexes that depend on a
collation whose library version changed.

Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-25 15:55:03 +07:00

253 lines
7.3 KiB
YAML

suite: postgres image flavor
# The Cluster and the init Job must resolve the same image, and a live
# cluster must never be moved to the other flavor: only one image family
# carries the PostGIS libraries, and CNPG would roll the swap out as an
# ordinary image update. Tags are matched by pattern so that
# hack/update-versions.sh can bump minors without touching this suite.
release:
name: pg-test
namespace: tenant-test
set:
_cluster:
scheduling: {}
tests:
- it: defaults to the CloudNativePG PostgreSQL image
templates:
- templates/db.yaml
documentSelector:
path: kind
value: Cluster
asserts:
- matchRegex:
path: spec.imageName
pattern: ^ghcr\.io/cloudnative-pg/postgresql:18\.[0-9]+-standard-trixie$
- it: postgis flavor switches the Cluster to the standard-trixie PostGIS image
set:
flavor: postgis
templates:
- templates/db.yaml
documentSelector:
path: kind
value: Cluster
asserts:
- matchRegex:
path: spec.imageName
pattern: ^ghcr\.io/cloudnative-pg/postgis:18\.[0-9]+-[0-9.]+-standard-trixie$
- it: postgis flavor runs the init Job from the same image as the Cluster
set:
flavor: postgis
version: v16
templates:
- templates/init-job.yaml
documentSelector:
path: kind
value: Job
asserts:
- matchRegex:
path: spec.template.spec.containers[0].image
pattern: ^ghcr\.io/cloudnative-pg/postgis:16\.[0-9]+-[0-9.]+-standard-trixie$
- it: refuses to move a live postgresql cluster to postgis
set:
flavor: postgis
kubernetesProvider:
scheme:
"postgresql.cnpg.io/v1/Cluster":
gvr:
group: postgresql.cnpg.io
version: v1
resource: clusters
namespaced: true
objects:
- apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: pg-test
namespace: tenant-test
spec:
imageName: ghcr.io/cloudnative-pg/postgresql:18.1
templates:
- templates/db.yaml
asserts:
- failedTemplate:
errorPattern: "flavor cannot change on an existing cluster \\(running postgresql, requested postgis\\)"
- it: refuses to move a live postgis cluster back to postgresql
kubernetesProvider:
scheme:
"postgresql.cnpg.io/v1/Cluster":
gvr:
group: postgresql.cnpg.io
version: v1
resource: clusters
namespaced: true
objects:
- apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: pg-test
namespace: tenant-test
spec:
imageName: ghcr.io/cloudnative-pg/postgis:18.1-3.6.1-standard-trixie
templates:
- templates/db.yaml
asserts:
- failedTemplate:
errorPattern: "flavor cannot change on an existing cluster \\(running postgis, requested postgresql\\)"
- it: lets a live postgis cluster take a new minor from a mirrored, digest-pinned image
set:
flavor: postgis
kubernetesProvider:
scheme:
"postgresql.cnpg.io/v1/Cluster":
gvr:
group: postgresql.cnpg.io
version: v1
resource: clusters
namespaced: true
objects:
- apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: pg-test
namespace: tenant-test
spec:
imageName: registry.example:5000/cloudnative-pg/postgis:18.0-3.6.0-standard-trixie@sha256:5a6b6d9016f6de30cd389c8a921b8acb64de0421f125a0ed3e95ce1b978bf169
templates:
- templates/db.yaml
documentSelector:
path: kind
value: Cluster
asserts:
- matchRegex:
path: spec.imageName
pattern: ^ghcr\.io/cloudnative-pg/postgis:18\.
- it: points a flavor change to a logical dump, not to a backup restore
set:
flavor: postgis
kubernetesProvider:
scheme:
"postgresql.cnpg.io/v1/Cluster":
gvr:
group: postgresql.cnpg.io
version: v1
resource: clusters
namespaced: true
objects:
- apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: pg-test
namespace: tenant-test
spec:
imageName: ghcr.io/cloudnative-pg/postgresql:18.1
templates:
- templates/db.yaml
asserts:
- failedTemplate:
errorPattern: "move the data with a logical dump \\(pg_dump / pg_restore\\); restoring a backup keeps the flavor it was taken from"
- it: refuses to recover a postgis source into the postgresql flavor
set:
bootstrap:
enabled: true
oldName: pg-source
backup:
s3AccessKey: access
s3SecretKey: secret
kubernetesProvider:
scheme:
"postgresql.cnpg.io/v1/Cluster":
gvr:
group: postgresql.cnpg.io
version: v1
resource: clusters
namespaced: true
objects:
- apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: pg-source
namespace: tenant-test
spec:
imageName: ghcr.io/cloudnative-pg/postgis:18.1-3.6.1-standard-trixie
templates:
- templates/db.yaml
asserts:
- failedTemplate:
errorPattern: "cannot recover a postgis backup of pg-source into the postgresql flavor"
- it: refuses to recover a postgresql source into the postgis flavor
set:
flavor: postgis
bootstrap:
enabled: true
oldName: pg-source
backup:
s3AccessKey: access
s3SecretKey: secret
kubernetesProvider:
scheme:
"postgresql.cnpg.io/v1/Cluster":
gvr:
group: postgresql.cnpg.io
version: v1
resource: clusters
namespaced: true
objects:
- apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: pg-source
namespace: tenant-test
spec:
imageName: ghcr.io/cloudnative-pg/postgresql:18.1
templates:
- templates/db.yaml
asserts:
- failedTemplate:
errorPattern: "cannot recover a postgresql backup of pg-source into the postgis flavor"
- it: recovers a postgis source into the postgis flavor
set:
flavor: postgis
bootstrap:
enabled: true
oldName: pg-source
backup:
s3AccessKey: access
s3SecretKey: secret
kubernetesProvider:
scheme:
"postgresql.cnpg.io/v1/Cluster":
gvr:
group: postgresql.cnpg.io
version: v1
resource: clusters
namespaced: true
objects:
- apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: pg-source
namespace: tenant-test
spec:
imageName: registry.example:5000/cloudnative-pg/postgis:18.0-3.6.0-standard-trixie
templates:
- templates/db.yaml
documentSelector:
path: kind
value: Cluster
asserts:
- equal:
path: spec.bootstrap.recovery.source
value: pg-source
- matchRegex:
path: spec.imageName
pattern: ^ghcr\.io/cloudnative-pg/postgis:18\.