feat: add support for in-place major upgrades with Image Volume extensions by NiccoloFei · Pull Request #10366 · cloudnative-pg/cloudnative-pg
This patch, together with https://commitfest.postgresql.org/patch/6562/ which has been committed into PG19, provides support for in-place major upgrades (via pg_upgrade) of Clusters that use Image Volume extensions.
Changes
- Mount ImageVolume extensions of both
oldandnewmajor versions inside theupgradejob - To allow
oldandnewImageVolumes to coexist (since the volume name would collide), I've renamed all new extensions by adding anupgrade-target-prefix (just in theupgradejob) - Adjusted
custom.confGUCs ofpgdata-newaccording to the rename of the extensions - Provide extension's related
EnvVarsto the upgrade job (for botholdandnewextensions)
Testing
Start from the following Cluster:
apiVersion: postgresql.cnpg.io/v1 kind: ImageCatalog metadata: name: postgresql-trixie namespace: default spec: images: - major: 18 image: ghcr.io/cloudnative-pg/postgresql:18.3-minimal-trixie extensions: - name: postgis image: reference: ghcr.io/cloudnative-pg/postgis-extension:3.6.2-18-trixie ld_library_path: - system - major: 19 image: ghcr.io/cloudnative-pg/postgresql-trunk:19-202603231300-minimal-trixie extensions: - name: postgis image: reference: ghcr.io/niccolofei/postgis:3.6-19-trixie ld_library_path: - system --- apiVersion: postgresql.cnpg.io/v1 kind: Cluster metadata: name: cluster-postgis spec: instances: 1 postgresql: extensions: - name: postgis imageCatalogRef: apiGroup: postgresql.cnpg.io kind: ImageCatalog name: postgresql-trixie major: 18 storage: size: 1Gi --- apiVersion: postgresql.cnpg.io/v1 kind: Database metadata: name: cluster-postgis-app spec: name: app owner: app cluster: name: cluster-postgis extensions: - name: postgis - name: postgis_raster - name: postgis_sfcgal - name: fuzzystrmatch - name: address_standardizer - name: address_standardizer_data_us - name: postgis_tiger_geocoder - name: postgis_topology
ghcr.io/niccolofei/postgis:3.6-19-trixieis a PostGISstable-3.6extension image built from source on top ofghcr.io/cloudnative-pg/postgresql-trunk:19-202603231300-minimal-trixie.
- Wait for the Cluster to be up and running and for the extensions to be created
- Optionally create some tables & insert some data that utilize PostGIS data types
- Point
spec.imageCatalogRef.majorto19and apply - The major upgrade job should complete and the new Cluster should start
- If you haven't specified a new
versionfor each extensions, the old one will be retained and you'll have to either:ALTER EXTENSION <extname> upgradeeach extension- run
update_extensions.sqlproduced bypg_upgrade, which can be found inside thepg_data
Note: because we are testing with development versions built from source, when upgrading extensions you'll most likely receive an error such as
message: extension \"postgis\" has no update path from version \"3.6.2\" to version \"3.6.3dev\
in case there's not yet an upgrade path available from the previous version.
Closes #10049
Assisted-by: Claude