From d5e249d8289f9c824d403d6fb390cca0bbc9aa3b Mon Sep 17 00:00:00 2001 From: Armando Ruocco Date: Wed, 13 May 2026 11:54:37 +0200 Subject: [PATCH 1/3] 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 --- .../barmancloud.cnpg.io_objectstores.yaml | 19 +++++++++++++++++++ go.mod | 4 ++-- go.sum | 8 ++++---- internal/cnpgi/restore/restore.go | 3 +++ manifest.yaml | 19 +++++++++++++++++++ 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/config/crd/bases/barmancloud.cnpg.io_objectstores.yaml b/config/crd/bases/barmancloud.cnpg.io_objectstores.yaml index f8688ce0..c5cf9711 100644 --- a/config/crd/bases/barmancloud.cnpg.io_objectstores.yaml +++ b/config/crd/bases/barmancloud.cnpg.io_objectstores.yaml @@ -176,6 +176,25 @@ spec: format: int32 minimum: 1 type: integer + restoreAdditionalCommandArgs: + description: |- + Additional arguments that can be appended to the 'barman-cloud-restore' + command-line invocation. These arguments provide flexibility to customize + the data restore process further, according to specific requirements or + configurations. + + Example: + In a scenario where specialized restore options are required, such as setting + a specific read timeout or defining custom behavior, users can use this field + to specify additional command arguments. + + Note: + It's essential to ensure that the provided arguments are valid and supported + by the 'barman-cloud-restore' command, to avoid potential errors or unintended + behavior during execution. + items: + type: string + type: array type: object destinationPath: description: |- diff --git a/go.mod b/go.mod index 0790477b..3ec151ff 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.26.3 require ( github.com/cert-manager/cert-manager v1.20.2 github.com/cloudnative-pg/api v1.29.0 - github.com/cloudnative-pg/barman-cloud v0.5.1 + github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260513095406-dac43abc6cf6 github.com/cloudnative-pg/cloudnative-pg v1.29.0 github.com/cloudnative-pg/cnpg-i v0.5.0 github.com/cloudnative-pg/cnpg-i-machinery v0.4.2 @@ -116,7 +116,7 @@ require ( golang.org/x/net v0.53.0 // indirect golang.org/x/oauth2 v0.36.0 // indirect golang.org/x/sync v0.20.0 // indirect - golang.org/x/sys v0.43.0 // indirect + golang.org/x/sys v0.44.0 // indirect golang.org/x/term v0.42.0 // indirect golang.org/x/text v0.36.0 // indirect golang.org/x/time v0.14.0 // indirect diff --git a/go.sum b/go.sum index 58101872..c45e6659 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ 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.0 h1:mNx6yJ5qi+Xrjs0NYrUy6V4MlXBkVJxGKwvTJZIuTX4= github.com/cloudnative-pg/api v1.29.0/go.mod h1:bF3HI8UVVcllZ7M8CfBufnb+Us8FyQArhD+4qtX0qhM= -github.com/cloudnative-pg/barman-cloud v0.5.1 h1:vjkXrrxo2DQXHT9u9usqhtaHiPZ/lTfDVs/pIWYTepQ= -github.com/cloudnative-pg/barman-cloud v0.5.1/go.mod h1:XPc5IUFP1y4cZX1sg+Pd8j9V4tmUEVnv3BGCpfQOOg8= +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/cloudnative-pg v1.29.0 h1:49Dm8+y4va7RODspJjeaK8uMWP3OGAD0gMsxhjm16Mo= github.com/cloudnative-pg/cloudnative-pg v1.29.0/go.mod h1:0Sgb/50VyaCnQm3IbWqgnhQG8Kb6mgqo8Jo1J+KtkSI= github.com/cloudnative-pg/cnpg-i v0.5.0 h1:/TOzpNT6cwNgrpftTtrnLKdoHgMwd+88vZgXjlVgXeE= @@ -275,8 +275,8 @@ golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= -golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI= -golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.44.0 h1:ildZl3J4uzeKP07r2F++Op7E9B29JRUy+a27EibtBTQ= +golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY= golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY= golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg= 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) diff --git a/manifest.yaml b/manifest.yaml index 3b99c39b..85115eaa 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -175,6 +175,25 @@ spec: format: int32 minimum: 1 type: integer + restoreAdditionalCommandArgs: + description: |- + Additional arguments that can be appended to the 'barman-cloud-restore' + command-line invocation. These arguments provide flexibility to customize + the data restore process further, according to specific requirements or + configurations. + + Example: + In a scenario where specialized restore options are required, such as setting + a specific read timeout or defining custom behavior, users can use this field + to specify additional command arguments. + + Note: + It's essential to ensure that the provided arguments are valid and supported + by the 'barman-cloud-restore' command, to avoid potential errors or unintended + behavior during execution. + items: + type: string + type: array type: object destinationPath: description: |- From cdfa352d9214fd6eeb4fd629c53c9c98c97a9989 Mon Sep 17 00:00:00 2001 From: Armando Ruocco Date: Wed, 13 May 2026 11:59:55 +0200 Subject: [PATCH 2/3] 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 01f19565bbd7d82ddd505c6c637f2cec43f44bd7 Mon Sep 17 00:00:00 2001 From: Armando Ruocco Date: Wed, 13 May 2026 15:00:12 +0200 Subject: [PATCH 3/3] 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/).