Skip to content

Commit 498253f

Browse files
committed
feat: fall back on recovery source object if cluster is not defined
Signed-off-by: Marco Nenciarini <[email protected]>
1 parent 96db07c commit 498253f

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

internal/cnpgi/operator/lifecycle_resources.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ func (impl LifecycleImplementation) collectSidecarResourcesForPod(
3030
configuration *config.PluginConfiguration,
3131
) (corev1.ResourceRequirements, error) {
3232
if len(configuration.BarmanObjectName) > 0 {
33-
// On a replica cluster, the designated primary will use both the
34-
// replica source object store and the object store of the cluster.
35-
// The designed primary role can change without the Pod being
36-
// recreated.
33+
// On a replica cluster that also archives, the designated primary
34+
// will use both the replica source object store and the object store
35+
// of the cluster.
3736
// In this case, we use the cluster object store for configuring
38-
// the resources created by the sidecar.
37+
// the resources of the sidecar container.
3938

4039
var barmanObjectStore barmancloudv1.ObjectStore
4140
if err := impl.Client.Get(ctx, configuration.GetBarmanObjectKey(), &barmanObjectStore); err != nil {
@@ -45,5 +44,18 @@ func (impl LifecycleImplementation) collectSidecarResourcesForPod(
4544
return barmanObjectStore.Spec.InstanceSidecarConfiguration.Resources, nil
4645
}
4746

47+
if len(configuration.RecoveryBarmanObjectName) > 0 {
48+
// On a replica cluster that doesn't archive, the designated primary
49+
// uses only the replica source object store.
50+
// In this case, we use the replica source object store for configuring
51+
// the resources of the sidecar container.
52+
var barmanObjectStore barmancloudv1.ObjectStore
53+
if err := impl.Client.Get(ctx, configuration.GetRecoveryBarmanObjectKey(), &barmanObjectStore); err != nil {
54+
return corev1.ResourceRequirements{}, err
55+
}
56+
57+
return barmanObjectStore.Spec.InstanceSidecarConfiguration.Resources, nil
58+
}
59+
4860
return corev1.ResourceRequirements{}, nil
4961
}

0 commit comments

Comments
 (0)