Compare commits

..

9 Commits

Author SHA1 Message Date
Leonardo Cecchi
cf5b1ef243
Merge 2d64d34030 into f7f0136520 2026-06-18 16:48:34 +02:00
Armando Ruocco
2d64d34030 test: cover NewFromCluster replica-source derivation
Add config-package tests exercising the parse path the pg_basebackup replica
fix lives in: NewFromCluster must derive ReplicaSourceBarmanObjectName from the
external cluster plugin (while leaving the backup and recovery object stores
empty) and Validate must accept it. Also assert that a replica source backed by
a different plugin is ignored.

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
2026-06-18 16:48:32 +02:00
Armando Ruocco
140b6e528a fix: honor replica-source object store sidecar config for pg_basebackup replicas
The sidecar injected into pg_basebackup replica clusters ignored the
instanceSidecarConfiguration (resources, logLevel, additionalContainerArgs) of
the replica-source ObjectStore: collectSidecarResourcesForPod and
collectAdditionalInstanceArgs only handled the cluster and recovery object
stores. Log-shipping replicas masked this because their recovery and replica
source object stores coincide; pg_basebackup replicas only set
ReplicaSourceBarmanObjectName, so the configuration was silently dropped (the
sidecar ran with no additional args and the default log level).

Handle ReplicaSourceBarmanObjectName in both helpers, documenting the store
precedence (Barman > Recovery > ReplicaSource), and fix the misleading comment
on the recovery branch.

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
2026-06-18 16:48:32 +02:00
Leonardo Cecchi
20e5afeba7 fix: inject barman sidecar in replica clusters bootstrapped with pg_basebackup
Replica clusters that use `pg_basebackup` as the bootstrap method and stream
WAL from an object store were not getting the barman sidecar injected, causing
WAL restore to fail silently. These clusters are now handled correctly.

Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
2026-06-18 16:48:32 +02:00
renovate[bot]
f7f0136520
fix(deps): update k8s.io/utils digest to a95e086 (#968)
Some checks failed
release-please / release-please (push) Failing after 4s
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [k8s.io/utils](https://redirect.github.com/kubernetes/utils) | require
| digest | `ff6756f` → `a95e086` |

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMTkuMCIsInVwZGF0ZWRJblZlciI6IjQzLjIxOS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWF0ZWQiLCJuby1pc3N1ZSJdfQ==-->

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-18 16:24:04 +02:00
renovate[bot]
7190349470
fix(deps): update all non-major go dependencies to 53ffbf0 (#973)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[github.com/cloudnative-pg/barman-cloud](https://redirect.github.com/cloudnative-pg/barman-cloud)
| require | digest | `592f761` → `53ffbf0` |

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/cloudnative-pg/plugin-barman-cloud).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMTkuMCIsInVwZGF0ZWRJblZlciI6IjQzLjIxOS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWF0ZWQiLCJuby1pc3N1ZSJdfQ==-->

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-18 14:09:58 +02:00
renovate[bot]
2fa63c4bc2
fix(deps): update all non-major go dependencies to 592f761 (#972)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[github.com/cloudnative-pg/barman-cloud](https://redirect.github.com/cloudnative-pg/barman-cloud)
| require | digest | `2638188` → `592f761` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the [Dependency
Dashboard](../issues/7) for more information.

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/cloudnative-pg/plugin-barman-cloud).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMTkuMCIsInVwZGF0ZWRJblZlciI6IjQzLjIxOS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWF0ZWQiLCJuby1pc3N1ZSJdfQ==-->

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-18 12:59:59 +02:00
renovate[bot]
007cf8a892
chore(deps): update dependency dagger/dagger to v0.21.7 (#969)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [dagger/dagger](https://redirect.github.com/dagger/dagger) | patch |
`0.21.6` → `0.21.7` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the [Dependency
Dashboard](../issues/7) for more information.

---

### Release Notes

<details>
<summary>dagger/dagger (dagger/dagger)</summary>

###
[`v0.21.7`](https://redirect.github.com/dagger/dagger/blob/HEAD/CHANGELOG.md#v0217---2026-06-17)

[Compare
Source](https://redirect.github.com/dagger/dagger/compare/v0.21.6...v0.21.7)

##### Changed

- Bump default CNI IP address pool size to reduce address exhaustion
under high container concurrency. by
[@&#8203;sipsma](https://redirect.github.com/sipsma) in
[#&#8203;13394](https://redirect.github.com/dagger/dagger/pull/13394)
- Bump Dang to v2.1.1, moving JSON encoding behind the `JSON` namespace
(with a deprecated top-level `toJSON`) and picking up constructor scope
and nullable input fixes. by
[@&#8203;vito](https://redirect.github.com/vito) in
[#&#8203;13482](https://redirect.github.com/dagger/dagger/pull/13482)

##### Fixed

- `.env` file handling so non-matching variables are kept as hidden
expansion context instead of being dropped, allowing later variables to
expand against them. by
[@&#8203;marcosnils](https://redirect.github.com/marcosnils) in
[#&#8203;13490](https://redirect.github.com/dagger/dagger/pull/13490)
- Filesync so syncing a re-included file under a gitignored directory
(e.g. `foo/` ignored with `!foo/bar.txt`) no longer fails with `no such
file or directory`; ignored parent dirs are now created on demand for
visible descendants. by
[@&#8203;grouville](https://redirect.github.com/grouville) in
[#&#8203;13439](https://redirect.github.com/dagger/dagger/pull/13439)
- A concurrent map panic during GC by guarding session client map
iteration, preventing fatal `concurrent map iteration and map write`
crashes. by [@&#8203;sipsma](https://redirect.github.com/sipsma) in
[#&#8203;13474](https://redirect.github.com/dagger/dagger/pull/13474)
- Go SDK codegen so SDK auth config is forwarded to typedef generation,
allowing modules with private transitive Go dependencies to resolve
during codegen. by
[@&#8203;grouville](https://redirect.github.com/grouville) in
[#&#8203;13457](https://redirect.github.com/dagger/dagger/pull/13457)
- Core enum handling to preserve conventional enum member names. by
[@&#8203;shykes](https://redirect.github.com/shykes) in
[#&#8203;13435](https://redirect.github.com/dagger/dagger/pull/13435)
- The Apple `container` driver to honor the privileged option by
granting all capabilities (`--cap-add ALL`), so the engine can
bind-mount `/etc/resolv.conf` on startup with `container` 1.0.0's
reduced default capability set. by
[@&#8203;eunomie](https://redirect.github.com/eunomie) in
[#&#8203;13460](https://redirect.github.com/dagger/dagger/pull/13460)
- Dang directive argument resolution so `@cache` (and other directive)
arguments resolve against the declaring type's file scope, fixing
`FunctionCachePolicy not found in env` errors in multi-file modules. by
[@&#8203;vito](https://redirect.github.com/vito) in
[#&#8203;13455](https://redirect.github.com/dagger/dagger/pull/13455)
- The report-mode heartbeat so it waits for its goroutine to exit before
final render, avoiding interleaved output. by
[@&#8203;kpenfound](https://redirect.github.com/kpenfound) in
[#&#8203;13425](https://redirect.github.com/dagger/dagger/pull/13425)
- Nullable result unwrapping for SDK input so nullable values are passed
correctly into SDK functions. by
[@&#8203;shykes](https://redirect.github.com/shykes) in
[#&#8203;13401](https://redirect.github.com/dagger/dagger/pull/13401)

##### What to do next?

- Read the [documentation](https://docs.dagger.io)
- Join our [Discord server](https://discord.gg/dagger-io)
- Follow us on [Twitter](https://twitter.com/dagger_io)

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/cloudnative-pg/plugin-barman-cloud).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMTkuMCIsInVwZGF0ZWRJblZlciI6IjQzLjIxOS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWF0ZWQiLCJuby1pc3N1ZSJdfQ==-->

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-18 11:50:57 +02:00
renovate[bot]
f4326b50c4
chore(deps): update dependency cert-manager/cert-manager to v1.20.2 (#967)
Some checks failed
release-please / release-please (push) Failing after 5s
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-17 11:34:47 +02:00
11 changed files with 258 additions and 17 deletions

View File

@ -44,7 +44,7 @@ jobs:
- name: Install Dagger
env:
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
DAGGER_VERSION: 0.21.6
DAGGER_VERSION: 0.21.7
run: |
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
- name: Run CI task

View File

@ -31,7 +31,7 @@ jobs:
- name: Install Dagger
env:
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
DAGGER_VERSION: 0.21.6
DAGGER_VERSION: 0.21.7
run: |
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
- name: Create image and manifest

View File

@ -21,7 +21,7 @@ jobs:
- name: Install Dagger
env:
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
DAGGER_VERSION: 0.21.6
DAGGER_VERSION: 0.21.7
run: |
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
- name: Create image and manifest

View File

@ -206,7 +206,7 @@ tasks:
- start-build-network
vars:
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
DAGGER_VERSION: 0.21.6
DAGGER_VERSION: 0.21.7
DAGGER_ENGINE_IMAGE: registry.dagger.io/engine:v{{ .DAGGER_VERSION }}
cmds:
- >

4
go.mod
View File

@ -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.20260616073548-263818883a1c
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260618100956-53ffbf09b567
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
@ -20,7 +20,7 @@ require (
k8s.io/apiextensions-apiserver v0.36.2
k8s.io/apimachinery v0.36.2
k8s.io/client-go v0.36.2
k8s.io/utils v0.0.0-20260507154919-ff6756f316d2
k8s.io/utils v0.0.0-20260617174310-a95e086a2553
sigs.k8s.io/controller-runtime v0.24.1
sigs.k8s.io/kustomize/api v0.21.1
sigs.k8s.io/kustomize/kyaml v0.21.1

8
go.sum
View File

@ -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.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.20260616073548-263818883a1c h1:5ILvYitKJ3+yT+bDGQM+21QOpa/a8ayCdTqtbWpYJtk=
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260616073548-263818883a1c/go.mod h1:vmW7blcg0BECd/9YKqn7NdiF7jz9BlXCWJcGJpzzBCg=
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260618100956-53ffbf09b567 h1:vqyRgqs1qDhOO2ZUEx3X4PKJGRnfwXN5xU5KSdjrnps=
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260618100956-53ffbf09b567/go.mod h1:vmW7blcg0BECd/9YKqn7NdiF7jz9BlXCWJcGJpzzBCg=
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=
@ -326,8 +326,8 @@ k8s.io/kube-openapi v0.0.0-20260502001324-b7f5293f4787 h1:kHv8PETbPIVHfqKBYwTNNS
k8s.io/kube-openapi v0.0.0-20260502001324-b7f5293f4787/go.mod h1:Cyq7UE0QtGe+Zo+/6XFrxiS4Mq0tLyQEONkFzSkfp9o=
k8s.io/streaming v0.36.2 h1:NSKthPPg9UFSKsRauVJUVGH2Dvn8fhKmY4qrMkw/p98=
k8s.io/streaming v0.36.2/go.mod h1:z6fV3D+NVkoeqRMtWwlUZK6U17SY/LqNzOxWL6GyR/s=
k8s.io/utils v0.0.0-20260507154919-ff6756f316d2 h1:wU4tMEhLGgIbLvXQb1cfN+EcM0wf7zC6CPF+C79jroc=
k8s.io/utils v0.0.0-20260507154919-ff6756f316d2/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk=
k8s.io/utils v0.0.0-20260617174310-a95e086a2553 h1:hmGqDecjc8d7HVzWzRFl0QD9bYuYKbBEG7t8xwnVxfI=
k8s.io/utils v0.0.0-20260617174310-a95e086a2553/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0 h1:hSfpvjjTQXQY2Fol2CS0QHMNs/WI1MOSGzCm1KhM5ec=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
sigs.k8s.io/controller-runtime v0.24.1 h1:miPEwrmirImAvgME1L9qebGHrOnGJoVmVdtOU9fRfo4=

View File

@ -20,8 +20,13 @@ SPDX-License-Identifier: Apache-2.0
package config
import (
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/metadata"
)
var _ = Describe("PluginConfiguration.Validate", func() {
@ -45,3 +50,77 @@ var _ = Describe("PluginConfiguration.Validate", func() {
Expect(cfg.Validate()).To(Succeed())
})
})
var _ = Describe("NewFromCluster", func() {
enabled := true
It("derives the replica source object store for a pg_basebackup replica cluster", func() {
cluster := &cnpgv1.Cluster{
ObjectMeta: metav1.ObjectMeta{Name: "cluster-replica", Namespace: "test-ns"},
Spec: cnpgv1.ClusterSpec{
Bootstrap: &cnpgv1.BootstrapConfiguration{
PgBaseBackup: &cnpgv1.BootstrapPgBaseBackup{Source: "source"},
},
ReplicaCluster: &cnpgv1.ReplicaClusterConfiguration{
Enabled: &enabled,
Source: "source",
},
ExternalClusters: []cnpgv1.ExternalCluster{
{
Name: "source",
PluginConfiguration: &cnpgv1.PluginConfiguration{
Name: metadata.PluginName,
Parameters: map[string]string{
"barmanObjectName": "minio-store",
"serverName": "cluster-example",
},
},
},
},
},
}
cfg := NewFromCluster(cluster)
// The replica source object store is derived from the external cluster plugin,
// while the backup/archive and recovery object stores remain empty: this is the
// distinguishing trait of a pg_basebackup replica cluster (a recovery-bootstrapped
// replica would also populate RecoveryBarmanObjectName).
Expect(cfg.ReplicaSourceBarmanObjectName).To(Equal("minio-store"))
Expect(cfg.ReplicaSourceServerName).To(Equal("cluster-example"))
Expect(cfg.BarmanObjectName).To(BeEmpty())
Expect(cfg.RecoveryBarmanObjectName).To(BeEmpty())
// Validate must accept it, otherwise the lifecycle hook skips sidecar injection.
Expect(cfg.Validate()).To(Succeed())
})
It("ignores a replica source backed by a different plugin", func() {
cluster := &cnpgv1.Cluster{
ObjectMeta: metav1.ObjectMeta{Name: "cluster-replica", Namespace: "test-ns"},
Spec: cnpgv1.ClusterSpec{
Bootstrap: &cnpgv1.BootstrapConfiguration{
PgBaseBackup: &cnpgv1.BootstrapPgBaseBackup{Source: "source"},
},
ReplicaCluster: &cnpgv1.ReplicaClusterConfiguration{
Enabled: &enabled,
Source: "source",
},
ExternalClusters: []cnpgv1.ExternalCluster{
{
Name: "source",
PluginConfiguration: &cnpgv1.PluginConfiguration{
Name: "some-other-plugin.cloudnative-pg.io",
Parameters: map[string]string{"barmanObjectName": "minio-store"},
},
},
},
},
}
cfg := NewFromCluster(cluster)
Expect(cfg.ReplicaSourceBarmanObjectName).To(BeEmpty())
Expect(cfg.Validate()).NotTo(Succeed())
})
})

View File

@ -273,8 +273,10 @@ func (impl LifecycleImplementation) collectAdditionalInstanceArgs(
return args
}
// Prefer the cluster object store (backup/archive). If not set, fallback to the recovery object store.
// If neither is configured, no additional args are provided.
// Only one object store provides the sidecar arguments, with precedence:
// BarmanObjectName (backup/archive) > RecoveryBarmanObjectName (recovery
// bootstrap) > ReplicaSourceBarmanObjectName (pg_basebackup replica).
// If none is configured, no additional args are provided.
if len(pluginConfiguration.BarmanObjectName) > 0 {
var barmanObjectStore barmancloudv1.ObjectStore
if err := impl.Client.Get(ctx, pluginConfiguration.GetBarmanObjectKey(), &barmanObjectStore); err != nil {
@ -303,6 +305,20 @@ func (impl LifecycleImplementation) collectAdditionalInstanceArgs(
return args, nil
}
if len(pluginConfiguration.ReplicaSourceBarmanObjectName) > 0 {
key := pluginConfiguration.GetReplicaSourceBarmanObjectKey()
var barmanObjectStore barmancloudv1.ObjectStore
if err := impl.Client.Get(ctx, key, &barmanObjectStore); err != nil {
return nil, fmt.Errorf("while getting replica source barman object store %s: %w", key.String(), err)
}
args := barmanObjectStore.Spec.InstanceSidecarConfiguration.AdditionalContainerArgs
args = append(
args,
collectTypedAdditionalArgs(&barmanObjectStore)...,
)
return args, nil
}
return nil, nil
}

View File

@ -48,6 +48,9 @@ func (impl LifecycleImplementation) collectSidecarResourcesForPod(
ctx context.Context,
configuration *config.PluginConfiguration,
) (corev1.ResourceRequirements, error) {
// Only one object store provides the sidecar resources, with precedence:
// BarmanObjectName (backup/archive) > RecoveryBarmanObjectName (recovery
// bootstrap) > ReplicaSourceBarmanObjectName (pg_basebackup replica).
if len(configuration.BarmanObjectName) > 0 {
// On a replica cluster that also archives, the designated primary
// will use both the replica source object store and the object store
@ -64,10 +67,10 @@ func (impl LifecycleImplementation) collectSidecarResourcesForPod(
}
if len(configuration.RecoveryBarmanObjectName) > 0 {
// On a replica cluster that doesn't archive, the designated primary
// uses only the replica source object store.
// In this case, we use the replica source object store for configuring
// the resources of the sidecar container.
// On a cluster recovering from an object store (including log-shipping
// replica clusters, where the recovery and replica source object stores
// coincide), we use the recovery object store for configuring the
// resources of the sidecar container.
var barmanObjectStore barmancloudv1.ObjectStore
if err := impl.Client.Get(ctx, configuration.GetRecoveryBarmanObjectKey(), &barmanObjectStore); err != nil {
return corev1.ResourceRequirements{}, err
@ -76,5 +79,18 @@ func (impl LifecycleImplementation) collectSidecarResourcesForPod(
return barmanObjectStore.Spec.InstanceSidecarConfiguration.Resources, nil
}
if len(configuration.ReplicaSourceBarmanObjectName) > 0 {
// On a replica cluster bootstrapped via pg_basebackup, the designated
// primary uses only the replica source object store.
// In this case, we use the replica source object store for configuring
// the resources of the sidecar container.
var barmanObjectStore barmancloudv1.ObjectStore
if err := impl.Client.Get(ctx, configuration.GetReplicaSourceBarmanObjectKey(), &barmanObjectStore); err != nil {
return corev1.ResourceRequirements{}, err
}
return barmanObjectStore.Spec.InstanceSidecarConfiguration.Resources, nil
}
return corev1.ResourceRequirements{}, nil
}

View File

@ -28,6 +28,7 @@ import (
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
@ -293,6 +294,24 @@ var _ = Describe("LifecycleImplementation", func() {
Expect(args).To(Equal(recoveryArgs))
})
It("falls back to replica source object store when primary and recovery not set", func(ctx SpecContext) {
ns := "test-ns"
cluster := &cnpgv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "c", Namespace: ns}}
pc := &config.PluginConfiguration{
Cluster: cluster,
ReplicaSourceBarmanObjectName: "replica-source-store",
}
replicaArgs := []string{"--replica-a", "--replica-b"}
cli := buildClientFunc(
makeStoreFunc(ns, pc.ReplicaSourceBarmanObjectName, replicaArgs),
).Build()
impl := LifecycleImplementation{Client: cli}
args, err := impl.collectAdditionalInstanceArgs(ctx, pc)
Expect(err).NotTo(HaveOccurred())
Expect(args).To(Equal(replicaArgs))
})
It("returns nil when neither object name is configured", func(ctx SpecContext) {
ns := "test-ns"
cluster := &cnpgv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "c", Namespace: ns}}
@ -386,6 +405,117 @@ var _ = Describe("LifecycleImplementation", func() {
Expect(err).NotTo(HaveOccurred())
Expect(args).To(Equal([]string{"--log-level=info"}))
})
It("includes --log-level from replica source object store when only replica source set", func(ctx SpecContext) {
ns := "test-ns"
cluster := &cnpgv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "c", Namespace: ns}}
pc := &config.PluginConfiguration{
Cluster: cluster,
ReplicaSourceBarmanObjectName: "replica-source-store",
}
store := &barmancloudv1.ObjectStore{
TypeMeta: metav1.TypeMeta{Kind: "ObjectStore", APIVersion: barmancloudv1.GroupVersion.String()},
ObjectMeta: metav1.ObjectMeta{Name: pc.ReplicaSourceBarmanObjectName, Namespace: ns},
Spec: barmancloudv1.ObjectStoreSpec{
InstanceSidecarConfiguration: barmancloudv1.InstanceSidecarConfiguration{
LogLevel: "warning",
},
},
}
s := runtime.NewScheme()
barmancloudv1.AddKnownTypes(s)
cli := fake.NewClientBuilder().WithScheme(s).WithRuntimeObjects(store).Build()
impl := LifecycleImplementation{Client: cli}
args, err := impl.collectAdditionalInstanceArgs(ctx, pc)
Expect(err).NotTo(HaveOccurred())
Expect(args).To(Equal([]string{"--log-level=warning"}))
})
})
Describe("collectSidecarResourcesForPod", func() {
makeStoreWithResourcesFunc := func(ns, name string, res corev1.ResourceRequirements) *barmancloudv1.ObjectStore {
return &barmancloudv1.ObjectStore{
TypeMeta: metav1.TypeMeta{Kind: "ObjectStore", APIVersion: barmancloudv1.GroupVersion.String()},
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: ns},
Spec: barmancloudv1.ObjectStoreSpec{
InstanceSidecarConfiguration: barmancloudv1.InstanceSidecarConfiguration{
Resources: res,
},
},
}
}
It("uses the cluster object store resources when set", func(ctx SpecContext) {
ns := "test-ns"
cluster := &cnpgv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "c", Namespace: ns}}
pc := &config.PluginConfiguration{Cluster: cluster, BarmanObjectName: "primary-store"}
res := corev1.ResourceRequirements{
Requests: corev1.ResourceList{corev1.ResourceMemory: resource.MustParse("64Mi")},
}
cli := buildClientFunc(makeStoreWithResourcesFunc(ns, pc.BarmanObjectName, res)).Build()
impl := LifecycleImplementation{Client: cli}
got, err := impl.collectSidecarResourcesForPod(ctx, pc)
Expect(err).NotTo(HaveOccurred())
gotMem := got.Requests[corev1.ResourceMemory]
Expect(gotMem.String()).To(Equal("64Mi"))
})
It("uses the recovery object store resources when only recovery is set", func(ctx SpecContext) {
ns := "test-ns"
cluster := &cnpgv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "c", Namespace: ns}}
pc := &config.PluginConfiguration{Cluster: cluster, RecoveryBarmanObjectName: "recovery-store"}
res := corev1.ResourceRequirements{
Requests: corev1.ResourceList{corev1.ResourceMemory: resource.MustParse("128Mi")},
}
cli := buildClientFunc(makeStoreWithResourcesFunc(ns, pc.RecoveryBarmanObjectName, res)).Build()
impl := LifecycleImplementation{Client: cli}
got, err := impl.collectSidecarResourcesForPod(ctx, pc)
Expect(err).NotTo(HaveOccurred())
gotMem := got.Requests[corev1.ResourceMemory]
Expect(gotMem.String()).To(Equal("128Mi"))
})
It("uses the replica source object store resources when only replica source is set", func(ctx SpecContext) {
ns := "test-ns"
cluster := &cnpgv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "c", Namespace: ns}}
pc := &config.PluginConfiguration{Cluster: cluster, ReplicaSourceBarmanObjectName: "replica-source-store"}
res := corev1.ResourceRequirements{
Requests: corev1.ResourceList{corev1.ResourceMemory: resource.MustParse("256Mi")},
}
cli := buildClientFunc(makeStoreWithResourcesFunc(ns, pc.ReplicaSourceBarmanObjectName, res)).Build()
impl := LifecycleImplementation{Client: cli}
got, err := impl.collectSidecarResourcesForPod(ctx, pc)
Expect(err).NotTo(HaveOccurred())
gotMem := got.Requests[corev1.ResourceMemory]
Expect(gotMem.String()).To(Equal("256Mi"))
})
It("returns empty resources when no object store is configured", func(ctx SpecContext) {
ns := "test-ns"
cluster := &cnpgv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "c", Namespace: ns}}
pc := &config.PluginConfiguration{Cluster: cluster}
cli := buildClientFunc().Build()
impl := LifecycleImplementation{Client: cli}
got, err := impl.collectSidecarResourcesForPod(ctx, pc)
Expect(err).NotTo(HaveOccurred())
Expect(got).To(Equal(corev1.ResourceRequirements{}))
})
It("returns an error if the replica source object store cannot be retrieved", func(ctx SpecContext) {
ns := "test-ns"
cluster := &cnpgv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "c", Namespace: ns}}
pc := &config.PluginConfiguration{Cluster: cluster, ReplicaSourceBarmanObjectName: "missing-store"}
cli := buildClientFunc().Build()
impl := LifecycleImplementation{Client: cli}
_, err := impl.collectSidecarResourcesForPod(ctx, pc)
Expect(err).To(HaveOccurred())
})
})
})

View File

@ -58,7 +58,7 @@ func WithIgnoreExistingResources(ignore bool) InstallOption {
// DefaultVersion is the default version of cert-manager to install.
//
// renovate: datasource=github-releases depName=cert-manager/cert-manager
const DefaultVersion = "v1.15.1"
const DefaultVersion = "v1.20.2"
// Install installs cert-manager using kubectl.
func Install(ctx context.Context, cl client.Client, opts ...InstallOption) error {