Skip to content

Commit 3d80a8c

Browse files
committed
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 <armando.ruocco@enterprisedb.com>
1 parent d4f3d89 commit 3d80a8c

5 files changed

Lines changed: 47 additions & 6 deletions

File tree

config/crd/bases/barmancloud.cnpg.io_objectstores.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,25 @@ spec:
176176
format: int32
177177
minimum: 1
178178
type: integer
179+
restoreAdditionalCommandArgs:
180+
description: |-
181+
Additional arguments that can be appended to the 'barman-cloud-restore'
182+
command-line invocation. These arguments provide flexibility to customize
183+
the data restore process further, according to specific requirements or
184+
configurations.
185+
186+
Example:
187+
In a scenario where specialized restore options are required, such as setting
188+
a specific read timeout or defining custom behavior, users can use this field
189+
to specify additional command arguments.
190+
191+
Note:
192+
It's essential to ensure that the provided arguments are valid and supported
193+
by the 'barman-cloud-restore' command, to avoid potential errors or unintended
194+
behavior during execution.
195+
items:
196+
type: string
197+
type: array
179198
type: object
180199
destinationPath:
181200
description: |-

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ toolchain go1.26.3
77
require (
88
github.com/cert-manager/cert-manager v1.20.2
99
github.com/cloudnative-pg/api v1.29.0
10-
github.com/cloudnative-pg/barman-cloud v0.5.1
10+
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260513095406-dac43abc6cf6
1111
github.com/cloudnative-pg/cloudnative-pg v1.29.0
1212
github.com/cloudnative-pg/cnpg-i v0.5.0
1313
github.com/cloudnative-pg/cnpg-i-machinery v0.4.2
@@ -116,7 +116,7 @@ require (
116116
golang.org/x/net v0.53.0 // indirect
117117
golang.org/x/oauth2 v0.36.0 // indirect
118118
golang.org/x/sync v0.20.0 // indirect
119-
golang.org/x/sys v0.43.0 // indirect
119+
golang.org/x/sys v0.44.0 // indirect
120120
golang.org/x/term v0.42.0 // indirect
121121
golang.org/x/text v0.36.0 // indirect
122122
golang.org/x/time v0.14.0 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
2020
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
2121
github.com/cloudnative-pg/api v1.29.0 h1:mNx6yJ5qi+Xrjs0NYrUy6V4MlXBkVJxGKwvTJZIuTX4=
2222
github.com/cloudnative-pg/api v1.29.0/go.mod h1:bF3HI8UVVcllZ7M8CfBufnb+Us8FyQArhD+4qtX0qhM=
23-
github.com/cloudnative-pg/barman-cloud v0.5.1 h1:vjkXrrxo2DQXHT9u9usqhtaHiPZ/lTfDVs/pIWYTepQ=
24-
github.com/cloudnative-pg/barman-cloud v0.5.1/go.mod h1:XPc5IUFP1y4cZX1sg+Pd8j9V4tmUEVnv3BGCpfQOOg8=
23+
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260513095406-dac43abc6cf6 h1:FxIX5u8Kf1aJQnmW/5eRo+1hx/okApecnIJAmvliaJ8=
24+
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260513095406-dac43abc6cf6/go.mod h1:VrubJGTgO94O2+m4EX68/wlbDmluc6ITL/VjTcMN3H4=
2525
github.com/cloudnative-pg/cloudnative-pg v1.29.0 h1:49Dm8+y4va7RODspJjeaK8uMWP3OGAD0gMsxhjm16Mo=
2626
github.com/cloudnative-pg/cloudnative-pg v1.29.0/go.mod h1:0Sgb/50VyaCnQm3IbWqgnhQG8Kb6mgqo8Jo1J+KtkSI=
2727
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=
275275
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
276276
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
277277
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
278-
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
279-
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
278+
golang.org/x/sys v0.44.0 h1:ildZl3J4uzeKP07r2F++Op7E9B29JRUy+a27EibtBTQ=
279+
golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
280280
golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY=
281281
golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY=
282282
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=

internal/cnpgi/restore/restore.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ func (impl JobHookImpl) restoreDataDir(
181181
if backup.Status.EndpointURL != "" {
182182
options = append(options, "--endpoint-url", backup.Status.EndpointURL)
183183
}
184+
185+
options = barmanConfiguration.Data.AppendRestoreAdditionalCommandArgs(options)
186+
184187
options = append(options, backup.Status.DestinationPath)
185188
options = append(options, backup.Status.ServerName)
186189
options = append(options, backup.Status.BackupID)

manifest.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,25 @@ spec:
175175
format: int32
176176
minimum: 1
177177
type: integer
178+
restoreAdditionalCommandArgs:
179+
description: |-
180+
Additional arguments that can be appended to the 'barman-cloud-restore'
181+
command-line invocation. These arguments provide flexibility to customize
182+
the data restore process further, according to specific requirements or
183+
configurations.
184+
185+
Example:
186+
In a scenario where specialized restore options are required, such as setting
187+
a specific read timeout or defining custom behavior, users can use this field
188+
to specify additional command arguments.
189+
190+
Note:
191+
It's essential to ensure that the provided arguments are valid and supported
192+
by the 'barman-cloud-restore' command, to avoid potential errors or unintended
193+
behavior during execution.
194+
items:
195+
type: string
196+
type: array
178197
type: object
179198
destinationPath:
180199
description: |-

0 commit comments

Comments
 (0)