Skip to content

feat: add support for in-place major upgrades with Image Volume extensions#10366

Open
NiccoloFei wants to merge 3 commits intomainfrom
dev/10049
Open

feat: add support for in-place major upgrades with Image Volume extensions#10366
NiccoloFei wants to merge 3 commits intomainfrom
dev/10049

Conversation

@NiccoloFei
Copy link
Copy Markdown
Collaborator

@NiccoloFei NiccoloFei commented Mar 24, 2026

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 old and new major versions inside the upgrade job
  • To allow old and new ImageVolumes to coexist (since the volume name would collide), I've renamed all new extensions by adding an upgrade-target- prefix (just in the upgrade job)
  • Adjusted custom.conf GUCs of pgdata-new according to the rename of the extensions
  • Provide extension's related EnvVars to the upgrade job (for both old and new extensions)

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-trixie is a PostGIS stable-3.6 extension image built from source on top of ghcr.io/cloudnative-pg/postgresql-trunk:19-202603231300-minimal-trixie.
  1. Wait for the Cluster to be up and running and for the extensions to be created
  2. Optionally create some tables & insert some data that utilize PostGIS data types
  3. Point spec.imageCatalogRef.major to 19 and apply
  4. The major upgrade job should complete and the new Cluster should start
  5. If you haven't specified a new version for each extensions, the old one will be retained and you'll have to either:
    • ALTER EXTENSION <extname> upgrade each extension
    • run update_extensions.sql produced by pg_upgrade, which can be found inside the pg_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

Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
@NiccoloFei NiccoloFei requested a review from a team as a code owner March 24, 2026 13:06
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 24, 2026
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.25 release-1.27 release-1.28 labels Mar 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@dosubot dosubot bot added the enhancement 🪄 New feature or request label Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-requested ◀️ This pull request should be backported to all supported releases enhancement 🪄 New feature or request release-1.25 release-1.27 release-1.28 size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support in-place major upgrades with Image Volume extensions

2 participants