Skip to content
This repository was archived by the owner on Aug 19, 2024. It is now read-only.

Commit 1198e2f

Browse files
authored
fix(RHIDP-2920): switch Secret and ConfigMap watches to WatchMetadata to reduce memory consumption (#396)
Signed-off-by: Pavel Macík <pavel.macik@gmail.com>
1 parent 83b7f91 commit 1198e2f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

controllers/backstage_controller.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,24 @@ func (r *BackstageReconciler) SetupWithManager(mgr ctrl.Manager) error {
354354
return fmt.Errorf("failed to construct the predicate for matching secrets. This should not happen: %w", err)
355355
}
356356

357+
secretMeta := &metav1.PartialObjectMetadata{}
358+
secretMeta.SetGroupVersionKind(schema.GroupVersionKind{
359+
Group: "",
360+
Version: "v1",
361+
Kind: "Secret",
362+
})
363+
364+
configMapMeta := &metav1.PartialObjectMetadata{}
365+
configMapMeta.SetGroupVersionKind(schema.GroupVersionKind{
366+
Group: "",
367+
Version: "v1",
368+
Kind: "ConfigMap",
369+
})
370+
357371
b := ctrl.NewControllerManagedBy(mgr).
358372
For(&bs.Backstage{}).
359-
Watches(
360-
&corev1.Secret{},
373+
WatchesMetadata(
374+
secretMeta,
361375
handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, o client.Object) []reconcile.Request {
362376
return r.requestByLabel(ctx, o)
363377
}),
@@ -367,8 +381,8 @@ func (r *BackstageReconciler) SetupWithManager(mgr ctrl.Manager) error {
367381
//CreateFunc: func(e event.CreateEvent) bool { return true },
368382
}),
369383
).
370-
Watches(
371-
&corev1.ConfigMap{},
384+
WatchesMetadata(
385+
configMapMeta,
372386
handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, o client.Object) []reconcile.Request {
373387
return r.requestByLabel(ctx, o)
374388
}),

0 commit comments

Comments
 (0)