mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-13 22:23:11 +01:00
feat: update reconcile functions in lifecycle.go to add resources definition for the sidecar
Update reconcile functions in lifecycle.go to add resources definition for the sidecar container. Signed-off-by: MichaluxPL <68371308+MichaluxPL@users.noreply.github.com>
This commit is contained in:
parent
71a188e97e
commit
0cf55b8398
@ -139,6 +139,7 @@ func reconcileJob(
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var barmanObjectStore barmancloudv1.ObjectStore
|
||||||
var job batchv1.Job
|
var job batchv1.Job
|
||||||
if err := decoder.DecodeObjectStrict(
|
if err := decoder.DecodeObjectStrict(
|
||||||
request.GetObjectDefinition(),
|
request.GetObjectDefinition(),
|
||||||
@ -171,6 +172,7 @@ func reconcileJob(
|
|||||||
},
|
},
|
||||||
env,
|
env,
|
||||||
certificates,
|
certificates,
|
||||||
|
barmanObjectStore,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, fmt.Errorf("while reconciling pod spec for job: %w", err)
|
return nil, fmt.Errorf("while reconciling pod spec for job: %w", err)
|
||||||
}
|
}
|
||||||
@ -202,7 +204,13 @@ func (impl LifecycleImplementation) reconcilePod(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return reconcilePod(ctx, cluster, request, pluginConfiguration, env, certificates)
|
var barmanObjectStore barmancloudv1.ObjectStore
|
||||||
|
configuration := config.NewFromCluster(cluster)
|
||||||
|
if err := impl.Client.Get(ctx, configuration.GetBarmanObjectKey(), &barmanObjectStore); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return reconcilePod(ctx, cluster, request, pluginConfiguration, env, certificates, barmanObjectStore)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reconcilePod(
|
func reconcilePod(
|
||||||
@ -212,6 +220,7 @@ func reconcilePod(
|
|||||||
pluginConfiguration *config.PluginConfiguration,
|
pluginConfiguration *config.PluginConfiguration,
|
||||||
env []corev1.EnvVar,
|
env []corev1.EnvVar,
|
||||||
certificates []corev1.VolumeProjection,
|
certificates []corev1.VolumeProjection,
|
||||||
|
barmanObjectStore barmancloudv1.ObjectStore,
|
||||||
) (*lifecycle.OperatorLifecycleResponse, error) {
|
) (*lifecycle.OperatorLifecycleResponse, error) {
|
||||||
pod, err := decoder.DecodePodJSON(request.GetObjectDefinition())
|
pod, err := decoder.DecodePodJSON(request.GetObjectDefinition())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -234,6 +243,7 @@ func reconcilePod(
|
|||||||
},
|
},
|
||||||
env,
|
env,
|
||||||
certificates,
|
certificates,
|
||||||
|
barmanObjectStore,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, fmt.Errorf("while reconciling pod spec for pod: %w", err)
|
return nil, fmt.Errorf("while reconciling pod spec for pod: %w", err)
|
||||||
}
|
}
|
||||||
@ -259,6 +269,7 @@ func reconcilePodSpec(
|
|||||||
sidecarConfig corev1.Container,
|
sidecarConfig corev1.Container,
|
||||||
additionalEnvs []corev1.EnvVar,
|
additionalEnvs []corev1.EnvVar,
|
||||||
certificates []corev1.VolumeProjection,
|
certificates []corev1.VolumeProjection,
|
||||||
|
barmanObjectStore barmancloudv1.ObjectStore,
|
||||||
) error {
|
) error {
|
||||||
envs := []corev1.EnvVar{
|
envs := []corev1.EnvVar{
|
||||||
{
|
{
|
||||||
@ -314,6 +325,7 @@ func reconcilePodSpec(
|
|||||||
Drop: []corev1.Capability{"ALL"},
|
Drop: []corev1.Capability{"ALL"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
sidecarConfig.Resources = barmanObjectStore.Spec.InstanceSidecarConfiguration.Resources
|
||||||
|
|
||||||
// merge the main container envs if they aren't already set
|
// merge the main container envs if they aren't already set
|
||||||
for _, container := range spec.Containers {
|
for _, container := range spec.Containers {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user