From ddb2154fae8862c3fe6abfd3297d64e34f54868c Mon Sep 17 00:00:00 2001 From: Armando Ruocco Date: Wed, 13 May 2026 11:54:37 +0200 Subject: [PATCH 1/4] feat: pass additionalCommandArgs to barman-cloud-restore Add support for the new `spec.configuration.data.restoreAdditionalCommandArgs` field so operators can append flags (e.g. `--read-timeout`) to barman-cloud-restore invocations, mirroring the existing `wal.restoreAdditionalCommandArgs` behavior. The new field is consumed by `restoreDataDir` and applied after the cloud provider options and `--endpoint-url` but before the positional arguments, so the upstream append/dedup logic can filter attempts to override official options. Depends on the corresponding upstream `barman-cloud` change in PR #242, which introduces `DataBackupConfiguration.RestoreAdditionalCommandArgs` and `AppendRestoreAdditionalCommandArgs`. go.mod pins that dependency to the PR HEAD commit via a pseudo-version; bump it to a tagged release once barman-cloud cuts one containing #242. Closes #821 Signed-off-by: Armando Ruocco --- go.mod | 2 +- go.sum | 6 ++++-- internal/cnpgi/restore/restore.go | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 73f68519..0775552e 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.26.3 require ( github.com/cert-manager/cert-manager v1.20.2 github.com/cloudnative-pg/api v1.29.1 - github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260529020047-bb683bf8d82a + github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260603073812-213211ec5e6f github.com/cloudnative-pg/cloudnative-pg v1.29.1 github.com/cloudnative-pg/cnpg-i v0.5.0 github.com/cloudnative-pg/cnpg-i-machinery v0.4.2 diff --git a/go.sum b/go.sum index 26e26fbb..462cd036 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,10 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cloudnative-pg/api v1.29.1 h1:FWr8S7EQeOfdhYXyr2cof8wUXLARZiiQt5Qa6ltED7w= github.com/cloudnative-pg/api v1.29.1/go.mod h1:QtWF3yzSvIfORMHaSkPAk/o3bhCJwEHJgN3riyRiz3o= -github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260529020047-bb683bf8d82a h1:u2Ykj9oCJlJw/xxiCXjG+svTmpaHMcaW6kGNdHdertk= -github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260529020047-bb683bf8d82a/go.mod h1:DACs5rdlMIQ7mUOpJVBRTrbf+d7OGyMOLsFUEMJ2JV8= +github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260513095406-dac43abc6cf6 h1:FxIX5u8Kf1aJQnmW/5eRo+1hx/okApecnIJAmvliaJ8= +github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260513095406-dac43abc6cf6/go.mod h1:VrubJGTgO94O2+m4EX68/wlbDmluc6ITL/VjTcMN3H4= +github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260603073812-213211ec5e6f h1:37XPQQ7PY1tffCXS4QuRK7eSDIzn6oeF8h3cIteN2SE= +github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260603073812-213211ec5e6f/go.mod h1:jCaMsQwJJ0f/49TIdSad1Ayjv52IoJXMZBhozqilY/g= github.com/cloudnative-pg/cloudnative-pg v1.29.1 h1:ZNEt1TMlnQKXI1kho2UqQuqdfvIvjGln4kN7C1lsmGA= github.com/cloudnative-pg/cloudnative-pg v1.29.1/go.mod h1:Sbgx9jVmkle4/gR2U5JHrzDd74sRPOBHDtPkvncg5v8= github.com/cloudnative-pg/cnpg-i v0.5.0 h1:/TOzpNT6cwNgrpftTtrnLKdoHgMwd+88vZgXjlVgXeE= diff --git a/internal/cnpgi/restore/restore.go b/internal/cnpgi/restore/restore.go index 0aad1e55..f286565e 100644 --- a/internal/cnpgi/restore/restore.go +++ b/internal/cnpgi/restore/restore.go @@ -181,6 +181,9 @@ func (impl JobHookImpl) restoreDataDir( if backup.Status.EndpointURL != "" { options = append(options, "--endpoint-url", backup.Status.EndpointURL) } + + options = barmanConfiguration.Data.AppendRestoreAdditionalCommandArgs(options) + options = append(options, backup.Status.DestinationPath) options = append(options, backup.Status.ServerName) options = append(options, backup.Status.BackupID) From e9dc671b0e360dfde0dda9dc38182411254a5a37 Mon Sep 17 00:00:00 2001 From: Armando Ruocco Date: Wed, 13 May 2026 11:59:55 +0200 Subject: [PATCH 2/4] docs: document data.restoreAdditionalCommandArgs Extend the "Extra Options" section in `misc.md` to cover `barman-cloud-restore` alongside backup and WAL archiving, and add a usage example for `.spec.configuration.data.restoreAdditionalCommandArgs`. Refs #821 Signed-off-by: Armando Ruocco --- web/docs/misc.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/web/docs/misc.md b/web/docs/misc.md index 0f03b284..77eb97a9 100644 --- a/web/docs/misc.md +++ b/web/docs/misc.md @@ -32,13 +32,14 @@ spec: [...] ``` -## Extra Options for Backup and WAL Archiving +## Extra Options for Backup, WAL Archiving, and Restore -You can pass additional command-line arguments to `barman-cloud-backup` and -`barman-cloud-wal-archive` using the `additionalCommandArgs` field in the -`ObjectStore` configuration. +You can pass additional command-line arguments to the underlying +`barman-cloud-*` commands using the corresponding fields in the `ObjectStore` +configuration. - `.spec.configuration.data.additionalCommandArgs`: for `barman-cloud-backup` +- `.spec.configuration.data.restoreAdditionalCommandArgs`: for `barman-cloud-restore` - `.spec.configuration.wal.archiveAdditionalCommandArgs`: for `barman-cloud-wal-archive` Each field accepts a list of string arguments. If an argument is already @@ -58,6 +59,19 @@ spec: - "--read-timeout=60" ``` +### Example: Extra Restore Options + +```yaml +kind: ObjectStore +metadata: + name: my-store +spec: + configuration: + data: + restoreAdditionalCommandArgs: + - "--read-timeout=900" +``` + ### Example: Extra WAL Archive Options ```yaml From bbb2c0a15b1c025aca2957bef51259bdc74f1609 Mon Sep 17 00:00:00 2001 From: Armando Ruocco Date: Wed, 13 May 2026 15:00:12 +0200 Subject: [PATCH 3/4] docs: document wal.restoreAdditionalCommandArgs The 'Extra Options' section enumerated every additionalCommandArgs knob except wal.restoreAdditionalCommandArgs, which already existed in the API. Add the missing bullet and example so the list is complete. Signed-off-by: Armando Ruocco --- web/docs/misc.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web/docs/misc.md b/web/docs/misc.md index 77eb97a9..1875961a 100644 --- a/web/docs/misc.md +++ b/web/docs/misc.md @@ -41,6 +41,7 @@ configuration. - `.spec.configuration.data.additionalCommandArgs`: for `barman-cloud-backup` - `.spec.configuration.data.restoreAdditionalCommandArgs`: for `barman-cloud-restore` - `.spec.configuration.wal.archiveAdditionalCommandArgs`: for `barman-cloud-wal-archive` +- `.spec.configuration.wal.restoreAdditionalCommandArgs`: for `barman-cloud-wal-restore` Each field accepts a list of string arguments. If an argument is already configured elsewhere in the plugin, the duplicate will be ignored. @@ -86,6 +87,19 @@ spec: - "--read-timeout=60" ``` +### Example: Extra WAL Restore Options + +```yaml +kind: ObjectStore +metadata: + name: my-store +spec: + configuration: + wal: + restoreAdditionalCommandArgs: + - "--read-timeout=60" +``` + For a complete list of supported options, refer to the [official Barman Cloud documentation](https://docs.pgbarman.org/release/latest/). From 80dda8288ac54dccde18e10a2ddbc185815eb93e Mon Sep 17 00:00:00 2001 From: Leonardo Cecchi Date: Wed, 3 Jun 2026 11:49:14 +0200 Subject: [PATCH 4/4] chore: review Signed-off-by: Leonardo Cecchi --- web/docs/misc.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/docs/misc.md b/web/docs/misc.md index 1875961a..e6594df0 100644 --- a/web/docs/misc.md +++ b/web/docs/misc.md @@ -43,8 +43,9 @@ configuration. - `.spec.configuration.wal.archiveAdditionalCommandArgs`: for `barman-cloud-wal-archive` - `.spec.configuration.wal.restoreAdditionalCommandArgs`: for `barman-cloud-wal-restore` -Each field accepts a list of string arguments. If an argument is already -configured elsewhere in the plugin, the duplicate will be ignored. +Each field accepts a list of string arguments. If an argument conflicts with +one already set by the plugin, the user-provided value will be ignored. These +fields are intended to pass options the plugin does not configure automatically. ### Example: Extra Backup Options