Skip to content

Commit c0bb4c9

Browse files
MichaluxPLleonardoce
authored andcommitted
Update reconcile functions in lifecycle.go to add resources definition for the sidecar container
Update reconcile functions in lifecycle.go to add resources definition for the sidecar container. Signed-off-by: MichaluxPL <[email protected]>
1 parent 14db0f6 commit c0bb4c9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

internal/cnpgi/operator/lifecycle.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ func reconcileJob(
139139
return nil, nil
140140
}
141141

142+
var barmanObjectStore barmancloudv1.ObjectStore
142143
var job batchv1.Job
143144
if err := decoder.DecodeObjectStrict(
144145
request.GetObjectDefinition(),
@@ -171,6 +172,7 @@ func reconcileJob(
171172
},
172173
env,
173174
certificates,
175+
barmanObjectStore,
174176
); err != nil {
175177
return nil, fmt.Errorf("while reconciling pod spec for job: %w", err)
176178
}
@@ -202,7 +204,13 @@ func (impl LifecycleImplementation) reconcilePod(
202204
return nil, err
203205
}
204206

205-
return reconcilePod(ctx, cluster, request, pluginConfiguration, env, certificates)
207+
var barmanObjectStore barmancloudv1.ObjectStore
208+
configuration := config.NewFromCluster(cluster)
209+
if err := impl.Client.Get(ctx, configuration.GetBarmanObjectKey(), &barmanObjectStore); err != nil {
210+
return nil, err
211+
}
212+
213+
return reconcilePod(ctx, cluster, request, pluginConfiguration, env, certificates, barmanObjectStore)
206214
}
207215

208216
func reconcilePod(
@@ -212,6 +220,7 @@ func reconcilePod(
212220
pluginConfiguration *config.PluginConfiguration,
213221
env []corev1.EnvVar,
214222
certificates []corev1.VolumeProjection,
223+
barmanObjectStore barmancloudv1.ObjectStore,
215224
) (*lifecycle.OperatorLifecycleResponse, error) {
216225
pod, err := decoder.DecodePodJSON(request.GetObjectDefinition())
217226
if err != nil {
@@ -233,6 +242,7 @@ func reconcilePod(
233242
},
234243
env,
235244
certificates,
245+
barmanObjectStore,
236246
); err != nil {
237247
return nil, fmt.Errorf("while reconciling pod spec for pod: %w", err)
238248
}
@@ -258,6 +268,7 @@ func reconcilePodSpec(
258268
sidecarConfig corev1.Container,
259269
additionalEnvs []corev1.EnvVar,
260270
certificates []corev1.VolumeProjection,
271+
barmanObjectStore barmancloudv1.ObjectStore,
261272
) error {
262273
envs := []corev1.EnvVar{
263274
{
@@ -313,6 +324,7 @@ func reconcilePodSpec(
313324
Drop: []corev1.Capability{"ALL"},
314325
},
315326
}
327+
sidecarConfig.Resources = barmanObjectStore.Spec.InstanceSidecarConfiguration.Resources
316328

317329
// merge the main container envs if they aren't already set
318330
for _, container := range spec.Containers {

0 commit comments

Comments
 (0)