CrunchyData / postgres-operator

Production PostgreSQL for Kubernetes, from high availability Postgres clusters to full-scale database-as-a-service.
https://access.crunchydata.com/documentation/postgres-operator/v5/
Apache License 2.0
3.93k stars 592 forks source link

spec.toPostgresVersion in body should be less than or equal to 14 #3542

Closed Martin-Hogge closed 1 year ago

Martin-Hogge commented 1 year ago

I've had just upgraded my pgo cluster from 5.1.0 to 5.3.0 and my postgresql version from 13 to 14.

I would like now to upgrade my postgresql version from 14 to 15 as it should be supported by the latest version of pgo according to the release notes: https://access.crunchydata.com/documentation/postgres-operator/v5/releases/5.3.0/

This is my pgupgrade yaml file:

apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PGUpgrade
metadata:
  name: pgupgrade-07
  namespace: adisoft-dev
spec:
  postgresClusterName: postgres-adisoft-dev
  fromPostgresVersion: 14
  toPostgresVersion: 15
  image: registry.developers.crunchydata.com/crunchydata/crunchy-upgrade:ubi8-5.3.0-0

When I try to execute it I get the following message:

The PGUpgrade "pgupgrade-07" is invalid: spec.toPostgresVersion: Invalid value: 15: spec.toPostgresVersion in body should be less than or equal to 14

Here is my cluster:

Name:         postgres-adisoft-dev
Namespace:    adisoft-dev
Labels:       <none>
Annotations:  postgres-operator.crunchydata.com/allow-upgrade: pgupgrade-03
API Version:  postgres-operator.crunchydata.com/v1beta1
Kind:         PostgresCluster
Metadata:
  Creation Timestamp:  2023-01-23T13:54:39Z
  Finalizers:
    postgres-operator.crunchydata.com/finalizer
  Generation:  3
  Managed Fields:
    API Version:  postgres-operator.crunchydata.com/v1beta1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .:
          f:kubectl.kubernetes.io/last-applied-configuration:
      f:spec:
        .:
        f:backups:
          .:
          f:pgbackrest:
            .:
            f:configuration:
            f:global:
              .:
              f:repo1-path:
              f:repo1-retention-full:
              f:repo1-retention-full-type:
              f:repo1-s3-uri-style:
            f:image:
            f:repos:
              .:
              k:{"name":"repo1"}:
                .:
                f:name:
                f:s3:
                  .:
                  f:bucket:
                  f:endpoint:
                  f:region:
                f:schedules:
                  .:
                  f:full:
        f:instances:
          .:
          k:{"name":"instance1"}:
            .:
            f:affinity:
              .:
              f:podAntiAffinity:
                .:
                f:requiredDuringSchedulingIgnoredDuringExecution:
            f:dataVolumeClaimSpec:
              .:
              f:accessModes:
              f:resources:
                .:
                f:requests:
                  .:
                  f:storage:
            f:metadata:
              .:
              f:annotations:
                .:
                f:cluster-autoscaler.kubernetes.io/safe-to-evict:
              f:labels:
                .:
                f:app:
            f:name:
            f:replicas:
            f:walVolumeClaimSpec:
              .:
              f:accessModes:
              f:resources:
                .:
                f:requests:
                  .:
                  f:storage:
        f:monitoring:
          .:
          f:pgmonitor:
            .:
            f:exporter:
              .:
              f:image:
        f:patroni:
          .:
          f:dynamicConfiguration:
            .:
            f:postgresql:
          f:leaderLeaseDurationSeconds:
          f:port:
          f:syncPeriodSeconds:
        f:port:
        f:users:
          .:
          k:{"name":"adisoft"}:
            .:
            f:databases:
              .:
              v:"adisoft":
            f:name:
            f:options:
          k:{"name":"bv"}:
            .:
            f:databases:
              .:
              v:"adisoft":
            f:name:
            f:options:
          k:{"name":"mh"}:
            .:
            f:databases:
              .:
              v:"adisoft":
            f:name:
            f:options:
          k:{"name":"nh"}:
            .:
            f:databases:
              .:
              v:"adisoft":
            f:name:
            f:options:
          k:{"name":"pdc"}:
            .:
            f:databases:
              .:
              v:"adisoft":
            f:name:
          k:{"name":"tg"}:
            .:
            f:databases:
              .:
              v:"adisoft":
            f:name:
            f:options:
    Manager:      kubectl-client-side-apply
    Operation:    Update
    Time:         2023-01-23T13:54:39Z
    API Version:  postgres-operator.crunchydata.com/v1beta1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:finalizers:
          .:
          v:"postgres-operator.crunchydata.com/finalizer":
    Manager:      postgrescluster-controller
    Operation:    Update
    Time:         2023-01-23T13:54:39Z
    API Version:  postgres-operator.crunchydata.com/v1beta1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          f:postgres-operator.crunchydata.com/allow-upgrade:
    Manager:      kubectl-annotate
    Operation:    Update
    Time:         2023-01-23T14:38:26Z
    API Version:  postgres-operator.crunchydata.com/v1beta1
    Fields Type:  FieldsV1
    fieldsV1:
      f:status:
        f:postgresVersion:
    Manager:      pgupgrade-controller
    Operation:    Update
    Subresource:  status
    Time:         2023-01-23T14:40:22Z
    API Version:  postgres-operator.crunchydata.com/v1beta1
    Fields Type:  FieldsV1
    fieldsV1:
      f:spec:
        f:image:
        f:postgresVersion:
        f:shutdown:
    Manager:      kubectl-patch
    Operation:    Update
    Time:         2023-01-23T14:44:55Z
    API Version:  postgres-operator.crunchydata.com/v1beta1
    Fields Type:  FieldsV1
    fieldsV1:
      f:status:
        .:
        f:conditions:
          .:
          k:{"type":"PGBackRestReplicaCreate"}:
            .:
            f:lastTransitionTime:
            f:message:
            f:observedGeneration:
            f:reason:
            f:status:
            f:type:
          k:{"type":"PGBackRestReplicaRepoReady"}:
            .:
            f:lastTransitionTime:
            f:message:
            f:observedGeneration:
            f:reason:
            f:status:
            f:type:
        f:databaseRevision:
        f:instances:
          .:
          k:{"name":"instance1"}:
            .:
            f:name:
            f:readyReplicas:
            f:replicas:
            f:updatedReplicas:
        f:monitoring:
          .:
          f:exporterConfiguration:
        f:observedGeneration:
        f:patroni:
          .:
          f:systemIdentifier:
        f:pgbackrest:
          .:
          f:repos:
            .:
            k:{"name":"repo1"}:
              .:
              f:name:
              f:replicaCreateBackupComplete:
              f:repoOptionsHash:
              f:stanzaCreated:
        f:proxy:
          .:
          f:pgBouncer:
            .:
            f:postgresRevision:
        f:usersRevision:
    Manager:         postgrescluster-controller
    Operation:       Update
    Subresource:     status
    Time:            2023-01-24T15:12:04Z
  Resource Version:  565409661
  UID:               a606dbd8-d99a-4e3f-a072-6a37f11ce403
Spec:
  Backups:
    Pgbackrest:
      Configuration:
        Secret:
          Name:  pgo-s3-creds
      Global:
        repo1-path:                 /pgbackrest/adisoft-dev/postgres-adisoft-dev/repo1
        repo1-retention-full:       1
        repo1-retention-full-type:  time
        repo1-s3-uri-style:         path
      Image:                        registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi8-2.38-0
      Repos:
        Name:  repo1
        s3:
          Bucket:    adisoft-dev-postgres-backup
          Endpoint:  backupstore.adisoft.be
          Region:    us-east-1
        Schedules:
          Full:  1 1 1 1 1
  Image:         registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-14.2-1
  Instances:
    Affinity:
      Pod Anti Affinity:
        Required During Scheduling Ignored During Execution:
          Label Selector:
            Match Labels:
              postgres-operator.crunchydata.com/cluster:       postgres-adisoft-dev
              postgres-operator.crunchydata.com/instance-set:  instance1
          Topology Key:                                        kubernetes.io/hostname
    Data Volume Claim Spec:
      Access Modes:
        ReadWriteOnce
      Resources:
        Requests:
          Storage:  20Gi
    Metadata:
      Annotations:
        cluster-autoscaler.kubernetes.io/safe-to-evict:  true
      Labels:
        App:   postgres-adisoft-dev
    Name:      instance1
    Replicas:  3
    Wal Volume Claim Spec:
      Access Modes:
        ReadWriteOnce
      Resources:
        Requests:
          Storage:  10Gi
  Monitoring:
    Pgmonitor:
      Exporter:
        Image:  registry.developers.crunchydata.com/crunchydata/crunchy-postgres-exporter:ubi8-5.3.0-0
  Patroni:
    Dynamic Configuration:
      Postgresql:
        Parameters:
          synchronous_commit:         on
          synchronous_standby_names:  *
        pg_hba:
          hostnossl all all all md5
    Leader Lease Duration Seconds:  30
    Port:                           8008
    Sync Period Seconds:            10
  Port:                             5432
  Postgres Version:                 14
  Shutdown:                         false
  Users:
    Databases:
      adisoft
    Name:     adisoft
    Options:  SUPERUSER
    Databases:
      adisoft
    Name:     mh
    Options:  SUPERUSER
    Databases:
      adisoft
    Name:     bv
    Options:  SUPERUSER
    Databases:
      adisoft
    Name:     nh
    Options:  SUPERUSER
    Databases:
      adisoft
    Name:     tg
    Options:  SUPERUSER
    Databases:
      adisoft
    Name:  pdc
Status:
  Conditions:
    Last Transition Time:  2023-01-23T14:45:26Z
    Message:               pgBackRest replica create repo is ready for backups
    Observed Generation:   3
    Reason:                StanzaCreated
    Status:                True
    Type:                  PGBackRestReplicaRepoReady
    Last Transition Time:  2023-01-23T14:47:04Z
    Message:               pgBackRest replica creation is now possible
    Observed Generation:   3
    Reason:                RepoBackupComplete
    Status:                True
    Type:                  PGBackRestReplicaCreate
  Database Revision:       86f54dc978
  Instances:
    Name:              instance1
    Ready Replicas:    3
    Replicas:          3
    Updated Replicas:  3
  Monitoring:
    Exporter Configuration:  855887659
  Observed Generation:       3
  Patroni:
    System Identifier:  7191857338786881569
  Pgbackrest:
    Repos:
      Name:                            repo1
      Replica Create Backup Complete:  true
      Repo Options Hash:               75d4cfc7d
      Stanza Created:                  true
  Postgres Version:                    14
  Proxy:
    Pg Bouncer:
      Postgres Revision:  5c9966f6bc
  Users Revision:         75c6bfd577
Events:                   <none>

My pgo deployment is using registry.developers.crunchydata.com/crunchydata/postgres-operator:ubi8-5.3.0-0 image.

Is it a bug or should I configure something to be able to migrate from 14 to 15 ?

Thank you.

andrewlecuyer commented 1 year ago

@Martin-Hogge please make sure you update your CRD's to the latest versions available for the v5.3.0 release.

For instance, as you can see in the latest version of the PGUpgrade API, a value of 15 is supported for toPostgresVersion:

toPostgresVersion:
  description: The major version of PostgreSQL to be upgraded to.
  maximum: 15
  minimum: 10
  type: integer

https://github.com/CrunchyData/postgres-operator-examples/blob/f1766db0b50ad2ae8ff35a599a16e11eefbd9f9c/kustomize/install/crd/bases/postgres-operator.crunchydata.com_pgupgrades.yaml#L938-L942

Martin-Hogge commented 1 year ago

Ok my bad I didn't sync the fork beyfore upgrading pgo. Thank you for your help !

EugenMayer commented 10 months ago

For anybody stumbling upon this (with the upgrade to 16) and you need to update your CRDs in body should be less than or equal to 15

cd kustomize/install/crd/
kustomize build . | kubectl apply -f - --server-side --server-side

fthe upgrade from 5.4 to 5.5 i had to use

cd kustomize/install/crd/
kustomize build . | kubectl apply -f - --server-side --server-side --force-conflicts

update for 5.4 to 5.5

actually, applying all the CRDS manually as an update will lead to issues when later applying the chart, since PGAdmin will then be already deployed.

Either delete the CRD for PGAdmin before you deploy or rather only update the old/existing CRDs like this

kubectl apply -f bases/postgres-operator.crunchydata.com_pgupgrades.yaml  --server-side 
kubectl apply -f bases/postgres-operator.crunchydata.com_postgresclusters.yaml  --server-side --force-conflicts