feat: fall back on recovery source object if cluster is not defined

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
This commit is contained in:
Marco Nenciarini 2025-05-08 15:05:56 +02:00
parent 293c9e901f
commit eae195b5d3

View File

@ -30,12 +30,11 @@ func (impl LifecycleImplementation) collectSidecarResourcesForPod(
configuration *config.PluginConfiguration, configuration *config.PluginConfiguration,
) (corev1.ResourceRequirements, error) { ) (corev1.ResourceRequirements, error) {
if len(configuration.BarmanObjectName) > 0 { if len(configuration.BarmanObjectName) > 0 {
// On a replica cluster, the designated primary will use both the // On a replica cluster that also archives, the designated primary
// replica source object store and the object store of the cluster. // will use both the replica source object store and the object store
// The designed primary role can change without the Pod being // of the cluster.
// recreated.
// In this case, we use the cluster object store for configuring // In this case, we use the cluster object store for configuring
// the resources created by the sidecar. // the resources of the sidecar container.
var barmanObjectStore barmancloudv1.ObjectStore var barmanObjectStore barmancloudv1.ObjectStore
if err := impl.Client.Get(ctx, configuration.GetBarmanObjectKey(), &barmanObjectStore); err != nil { if err := impl.Client.Get(ctx, configuration.GetBarmanObjectKey(), &barmanObjectStore); err != nil {
@ -45,5 +44,18 @@ func (impl LifecycleImplementation) collectSidecarResourcesForPod(
return barmanObjectStore.Spec.InstanceSidecarConfiguration.Resources, nil return barmanObjectStore.Spec.InstanceSidecarConfiguration.Resources, nil
} }
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.
var barmanObjectStore barmancloudv1.ObjectStore
if err := impl.Client.Get(ctx, configuration.GetRecoveryBarmanObjectKey(), &barmanObjectStore); err != nil {
return corev1.ResourceRequirements{}, err
}
return barmanObjectStore.Spec.InstanceSidecarConfiguration.Resources, nil
}
return corev1.ResourceRequirements{}, nil return corev1.ResourceRequirements{}, nil
} }