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

Commit

Permalink
fix(RHIDP-2920): switch Secret and ConfigMap watches to WatchMetadata…
Browse files Browse the repository at this point in the history
… to reduce memory consumption (#396)

Signed-off-by: Pavel Macík <[email protected]>
  • Loading branch information
pmacik authored Jul 5, 2024
1 parent 83b7f91 commit 1198e2f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions controllers/backstage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,24 @@ func (r *BackstageReconciler) SetupWithManager(mgr ctrl.Manager) error {
return fmt.Errorf("failed to construct the predicate for matching secrets. This should not happen: %w", err)
}

secretMeta := &metav1.PartialObjectMetadata{}
secretMeta.SetGroupVersionKind(schema.GroupVersionKind{
Group: "",
Version: "v1",
Kind: "Secret",
})

configMapMeta := &metav1.PartialObjectMetadata{}
configMapMeta.SetGroupVersionKind(schema.GroupVersionKind{
Group: "",
Version: "v1",
Kind: "ConfigMap",
})

b := ctrl.NewControllerManagedBy(mgr).
For(&bs.Backstage{}).
Watches(
&corev1.Secret{},
WatchesMetadata(
secretMeta,
handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, o client.Object) []reconcile.Request {
return r.requestByLabel(ctx, o)
}),
Expand All @@ -367,8 +381,8 @@ func (r *BackstageReconciler) SetupWithManager(mgr ctrl.Manager) error {
//CreateFunc: func(e event.CreateEvent) bool { return true },
}),
).
Watches(
&corev1.ConfigMap{},
WatchesMetadata(
configMapMeta,
handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, o client.Object) []reconcile.Request {
return r.requestByLabel(ctx, o)
}),
Expand Down

0 comments on commit 1198e2f

Please sign in to comment.