Skip to content

fix: honour the object store requested by a Backup resource - #1076

Open
ildar-fix wants to merge 2 commits into
cloudnative-pg:mainfrom
ildar-fix:dev/611
Open

fix: honour the object store requested by a Backup resource#1076
ildar-fix wants to merge 2 commits into
cloudnative-pg:mainfrom
ildar-fix:dev/611

Conversation

@ildar-fix

Copy link
Copy Markdown

Closes #611

Problem

The operator relays the parameters of a Backup resource to the plugin in the BackupRequest
(pkg/management/postgres/webserver/plugin_backup.go -> internal/cnpi/plugin/client/backup.go), but
BackupServiceImplementation.Backup builds its configuration from the Cluster alone and never reads
request.Parameters. A Backup asking for a different object store is written to the cluster one, and it ends
up completed with no warning: the only symptom is an archive that stays empty.

What this does

First commit applies the parameters of the Backup on top of the configuration derived from the Cluster, so
that barmanObjectName and serverName select the destination of that single backup. A Backup without
parameters behaves exactly as before.

Second commit adds the additionalBarmanObjectNames cluster level parameter. It is needed to make the first one
usable: the Role bound to the instance service account is built from the object stores the Cluster refers to,
so a Backup naming any other store fails with objectstores.barmancloud.cnpg.io "..." is forbidden. The
parameter is a comma separated list of stores that take part in the RBAC and in the certificates of the
instances, while nothing is routed to them.

# Cluster
plugins:
  - name: barman-cloud.cloudnative-pg.io
    isWALArchiver: true
    parameters:
      barmanObjectName: minio-store
      additionalBarmanObjectNames: archive-store
---
# Backup
spec:
  method: plugin
  cluster:
    name: cluster-example
  pluginConfiguration:
    name: barman-cloud.cloudnative-pg.io
    parameters:
      barmanObjectName: archive-store

The two commits are separate on purpose: if you would rather widen the Role some other way, the first one stands
on its own.

Testing

Unit tests are added to the existing Ginkgo suite in internal/cnpgi/operator/config.

Verified on a stand with CNPG 1.30.0 and an S3 backend: a Backup requesting archive-store lands in that
store while WALs keep going to the cluster store, the cluster store is left untouched, and a cluster
bootstrapped from that pair comes up with all the data. Without the second commit the same Backup fails with
the forbidden error above.

Ildar Gilyazev added 2 commits August 26, 2026 10:32
The operator relays the parameters of a Backup resource to the plugin in
the BackupRequest, but the plugin builds its configuration from the
Cluster alone. A Backup asking for a different object store is therefore
written to the cluster one, and it completes without any warning, so the
mistake surfaces only when the archive turns out to be empty.

Apply the parameters of the Backup on top of the configuration derived
from the Cluster, so that barmanObjectName and serverName select the
destination of that single backup.

Closes cloudnative-pg#611

Assisted-by: Claude Opus 5
Signed-off-by: Ildar Gilyazev <horiganmikle@gmail.com>
The Role bound to the instance service account is built from the object
stores the Cluster refers to, so a Backup naming any other store fails
with a forbidden error on objectstores. The object store selection of a
Backup is therefore unusable on its own.

Add the additionalBarmanObjectNames parameter, a comma separated list of
stores that take part in the RBAC and in the certificates of the
instances while nothing is routed to them, so that a Backup can name one
of them.

Closes cloudnative-pg#611

Assisted-by: Claude Opus 5
Signed-off-by: Ildar Gilyazev <horiganmikle@gmail.com>
@ildar-fix
ildar-fix requested a review from a team as a code owner August 26, 2026 08:01
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working go Pull requests that update go code labels Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backup to different object store

1 participant