plugin-barman-cloud icon indicating copy to clipboard operation
plugin-barman-cloud copied to clipboard

Invalid value: "object": BackupSpec is immutable once set

Open alexeyshishkin-edb opened this issue 1 year ago • 1 comments

Hi, Team !

I'm doing migrations from Barman Native to Barman Plugin (0.7.0) using the same set of commands.

I have two setups:

  1. CNPG 1.26.1
  2. CNPG 1.27.0

My configs are:

tee $cluster_name.yaml.NATIVE << EOF
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: $cluster_name
  namespace: $oname-system
spec:
  instances: 3
  imageName: $cnpg_image_name
  storage:
    size: 1Gi
  backup:
    retentionPolicy: "1d"
    barmanObjectStore:
      destinationPath: s3://cluster-backups/
      endpointURL: http://minio-service:9000
      s3Credentials:
        accessKeyId:
          name: minio-creds
          key: ACCESS_KEY_ID
        secretAccessKey:
          name: minio-creds
          key: ACCESS_SECRET_KEY
      wal:
        compression: gzip
EOF
tee barman-backup.yaml.NATIVE << EOF
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
  name: barman-backup
  namespace: $oname-system
spec:
  cluster:
    name: $cluster_name
  target: prefer-standby
EOF
tee minio-store.yaml << EOF
apiVersion: barmancloud.cnpg.io/v1
kind: ObjectStore
metadata:
  name: minio-store
  namespace: $oname-system
spec:
  configuration:
    destinationPath: s3://cluster-backups/
    endpointURL: http://minio-service:9000
    s3Credentials:
      accessKeyId:
        name: minio-creds
        key: ACCESS_KEY_ID
      secretAccessKey:
        name: minio-creds
        key: ACCESS_SECRET_KEY
    wal:
      compression: gzip
  retentionPolicy: "1d"
EOF
tee $cluster_name.yaml.PLUGIN << EOF
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: $cluster_name
  namespace: $oname-system
spec:
  instances: 3
  imagePullPolicy: Always
  imageName: $cnpg_image_name
  storage:
    size: 1Gi
  plugins:
  - name: barman-cloud.cloudnative-pg.io
    isWALArchiver: true
    parameters:
      barmanObjectName: minio-store
EOF
tee barman-backup.yaml.PLUGIN << EOF
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
  name: barman-backup
  namespace: $oname-system
spec:
  cluster:
    name: $cluster_name
  method: plugin
  pluginConfiguration:
    name: barman-cloud.cloudnative-pg.io
  target: prefer-standby
EOF

The set of commands is: a) kubectl apply --server-side -f $oname-$cnpg_full_version.yaml b) kubectl apply -f minio.yaml c) kubectl apply -f $cluster_name.yaml.NATIVE d) kubectl apply -f barman-backup.yaml.NATIVE e) kubectl apply -f cert-manager.yaml f) kubectl apply -f manifest.yaml g) kubectl apply -f minio-store.yaml h) kubectl apply -f $cluster_name.yaml.PLUGIN i) kubectl apply -f barman-backup.yaml.PLUGIN

This set of commands works fine for the setup 1) (CNPG 1.26.1). However for the setup 2) (CNPG 1.27.0) I have the following message for the step i)

[alexey@wsl2 ~]$ kubectl apply -f barman-backup.yaml.PLUGIN
The Backup "barman-backup" is invalid: spec: Invalid value: "object": BackupSpec is immutable once set

What's wrong with it ?

alexeyshishkin-edb avatar Oct 19 '25 10:10 alexeyshishkin-edb

The error in CNPG 1.27.0 happens because the Backup resource's spec is now strictly immutable: once a Backup is created, you cannot change its spec fields (like switching from native to plugin method) by applying a new manifest with the same name. This immutability is enforced by a validation rule in the CRD and webhook logic, which rejects any update to the spec after creation—covering all fields, including method, pluginConfiguration, and target [source].

This behavior is intentional and aligns with the migration documentation, which implies that when switching backup methods, you must delete the existing Backup resource and then create a new one with the updated spec [migration guide]. This is why your workflow works in 1.26.1 (where the rule was less strictly enforced) but fails in 1.27.0.

To resolve this, delete the old Backup resource (kubectl delete -f barman-backup.yaml.NATIVE or kubectl delete backup barman-backup) before applying the new one with the plugin configuration. This will allow you to migrate cleanly to the plugin-based backup method.

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about plugin-barman-cloud Share Dosu with your team

dosubot[bot] avatar Oct 19 '25 10:10 dosubot[bot]