Skip to content

[Bug]: Backup.status.online incorrectly reports true for cold (online: false) volume snapshot backups #11275

Description

@gbartolini

Is there an existing issue already for this bug?

  • I have searched for an existing issue, and could not find anything. I believe this is a new bug.

I have read the troubleshooting guide

  • I have read the troubleshooting guide and I think this is a new bug.

I am running a supported version of CloudNativePG

  • I have read the troubleshooting guide and I think this is a new bug.

Contact Details

No response

Version

trunk (main)

What version of Kubernetes are you using?

1.36

What is your Kubernetes environment?

Self-managed: kind (evaluation)

How did you install the operator?

YAML manifest

What happened?

When creating a Backup with method: volumeSnapshot and spec.online: false (a cold backup, requiring instance fencing), the resulting Backup.status.online field incorrectly reports true once the backup completes, even though the backup was correctly executed as cold (the instance was fenced, and the VolumeSnapshot's own cnpg.io/onlineBackup annotation correctly shows "false").

Cluster resource

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: pg-vs
spec:
  instances: 3

  plugins:
  - name: barman-cloud.cloudnative-pg.io
    isWALArchiver: true
    parameters:
      barmanObjectName: objectstore-eu
      serverName: pg-vs

  storage:
    storageClass: csi-hostpath-sc
    size: 1Gi

  walStorage:
    storageClass: csi-hostpath-sc
    size: 1Gi

  backup:
    volumeSnapshot:
      className: csi-hostpath-snapclass
---
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
  name: pg-vs-cold-backup
spec:
  method: volumeSnapshot
  online: false
  cluster:
    name: pg-vs

Relevant log output

$ kubectl get -o yaml  backups.postgresql.cnpg.io pg-vs-cold-backup
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
...
spec:
  cluster:
    name: pg-vs
  method: volumeSnapshot
  online: false
status:
  backupId: pg-vs-cold-backup
  backupName: pg-vs-cold-backup
  beginWal: "000000010000000000000005"
  endWal: "000000010000000000000005"
  majorVersion: 18
  method: volumeSnapshot
  online: true
  phase: completed
...

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. self-assigned this
    on Jul 30, 2026
  2. added
    bug 🐛
    triage
    on Jul 30, 2026
  3. dosubot commented on Jul 30, 2026

    @dosubot

    The root cause is in finalizeSnapshotBackupStep — it reads online directly from the cluster-level config and ignores the backup-level spec.online override:

    volumeSnapshotConfig := cluster.Spec.Backup.VolumeSnapshot
    // ...
    backup.Status.Online = ptr.To(volumeSnapshotConfig.GetOnline())

    Since cluster.Spec.Backup.VolumeSnapshot has no explicit online field set, GetOnline() defaults to true [1], regardless of what's in backup.Spec.Online.

    The codebase already has a helper that correctly merges backup-level overrides with cluster-level config — backup.GetVolumeSnapshotConfiguration(...) [2]. The fix would be to use it here instead of the raw cluster config:

    volumeSnapshotConfig := backup.GetVolumeSnapshotConfiguration(cluster.Spec.Backup.VolumeSnapshot)
    backup.Status.Online = ptr.To(volumeSnapshotConfig.GetOnline())

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about cloudnative-pg with Dosu Add Dosu to your team

  4. moved this to Waiting for First Review in CloudNativePG operator developmenton Jul 30, 2026
  5. added this to the 1.30.1 milestone on Jul 30, 2026
  6. removed
    triage
    on Jul 30, 2026
  7. added a commit that references this issue on Jul 31, 2026
    6156d92
  8. moved this from Waiting for First Review to Done in CloudNativePG operator developmenton Jul 31, 2026
  9. added 3 commits that reference this issue on Jul 31, 2026
    3b92c42
    08f84ae
    7ac87f5
  10. added a commit that references this issue on Jul 31, 2026
    b092854
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛

Type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions