Skip to content

feat: add ShowAdditionalCommandArgs and ListAdditionalCommandArgs#249

Open
davidalmgren95 wants to merge 1 commit into
cloudnative-pg:mainfrom
davidalmgren95:dev/712
Open

feat: add ShowAdditionalCommandArgs and ListAdditionalCommandArgs#249
davidalmgren95 wants to merge 1 commit into
cloudnative-pg:mainfrom
davidalmgren95:dev/712

Conversation

@davidalmgren95
Copy link
Copy Markdown

@davidalmgren95 davidalmgren95 commented May 26, 2026

Summary

An ObjectStore already lets users tack extra command-line flags onto four of the six barman-cloud-* invocations the CNPG plugin shells out to:

barman command existing field
barman-cloud-backup Data.AdditionalCommandArgs
barman-cloud-wal-archive Wal.ArchiveAdditionalCommandArgs
barman-cloud-wal-restore Wal.RestoreAdditionalCommandArgs
barman-cloud-restore Data.RestoreAdditionalCommandArgs (plugin PR #914)

The remaining two — barman-cloud-backup-show (the post-write verification step) and barman-cloud-backup-list (used internally for retention pruning) — had no equivalent, which is the gap reported in cloudnative-pg/plugin-barman-cloud#712.

This is observable in practice on S3-compatible endpoints that strictly require virtual-hosted-style addressing for LIST. On such backends:

  • barman-cloud-backup accepts user-provided --addressing-style=virtual via the existing Data.AdditionalCommandArgs ✅ — base backup completes and lands in the bucket
  • barman-cloud-backup-show runs immediately afterwards with no way to thread the flag through, sends path-style by default, gets PathStyleRequestNotAllowed, exits with status 4
  • The plugin marks the otherwise-successful backup as phase: failed
  • Retention pruning (which goes via barman-cloud-backup-list) is similarly broken — old backups silently never get expired

So user-visible Backup CR status is wrong and retention is silently disabled, even though the actual base-backup data is intact in the bucket.

Changes

  • Add DataBackupConfiguration.ShowAdditionalCommandArgs (for barman-cloud-backup-show)
  • Add DataBackupConfiguration.ListAdditionalCommandArgs (for barman-cloud-backup-list)
  • Add AppendShowAdditionalCommandArgs and AppendListAdditionalCommandArgs helpers, mirroring the existing pattern in this file
  • Thread the new helpers through GetBackupList and GetBackupByName in `pkg/command/backuplist.go`
  • `executeQueryCommand` grows a separate `additionalFlagArgs` parameter so the user-provided flags land alongside the standard options (`--format json`, `--endpoint-url`, cloud provider opts) rather than after the positional `DESTINATION/SERVER/BACKUP_ID` arguments — same shape as where the other Append*AdditionalCommandArgs helpers append in the rest of this library
  • DeepCopy for the two new `[]string` slices
  • Tests mirror the existing `AppendAdditionalCommandArgs` ones

Sister PR

The CRD fields on the consuming side are added in cloudnative-pg/plugin-barman-cloud#924 (filed in parallel; will be linked once open). This library change is the prerequisite for the plugin's CRD generation to pick up the new fields.

Refs: cloudnative-pg/plugin-barman-cloud#712

An ObjectStore lets users tack extra command-line flags onto four of
the six barman-cloud-* invocations the plugin shells out to:

  - barman-cloud-backup       via Data.AdditionalCommandArgs
  - barman-cloud-wal-archive  via Wal.ArchiveAdditionalCommandArgs
  - barman-cloud-wal-restore  via Wal.RestoreAdditionalCommandArgs
  - barman-cloud-restore      via Data.RestoreAdditionalCommandArgs  (PR #914 in the plugin)

The remaining two — barman-cloud-backup-show (the post-write
verification) and barman-cloud-backup-list (retention pruning) — had
no equivalent, which is the gap reported in plugin-barman-cloud #712:
on strictly-vhost S3-compatible endpoints, users need --addressing-style=virtual
on every cloud command, and currently those two reject the user-provided
args, marking otherwise-successful backups as failed and silently breaking
retention pruning.

This adds two new fields on DataBackupConfiguration -
ShowAdditionalCommandArgs and ListAdditionalCommandArgs - plus matching
AppendShowAdditionalCommandArgs and AppendListAdditionalCommandArgs
helpers, mirroring the existing pattern.

executeQueryCommand in pkg/command/backuplist.go grows a separate
additionalFlagArgs parameter so the user-provided flags land alongside
the standard options (--format json, --endpoint-url, cloud provider opts)
rather than after the positional DESTINATION/SERVER/BACKUP_ID arguments;
GetBackupList and GetBackupByName thread the new helpers through.

Tests mirror the existing AppendAdditionalCommandArgs ones.

Refs: cloudnative-pg/plugin-barman-cloud#712
Signed-off-by: David Almgren <dalmgren@coreweave.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant