From b2ac20b3c3f904b050a929af02d2ceb87c671971 Mon Sep 17 00:00:00 2001 From: Claudio Lorina Date: Tue, 15 Oct 2024 12:40:49 +0200 Subject: [PATCH] fix: prevent the remote ResourceSlice controller to reconcile multiple times The remote ResourceSlice controller reconciled multiple times when the status of the resource was changed. To fix this issue this patch adds the GenerationChangedPredicate, allowing to reconcile only when the specs of the resource changes. --- .../remoteresourceslice_controller.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/liqo-controller-manager/authentication/remoteresourceslice-controller/remoteresourceslice_controller.go b/pkg/liqo-controller-manager/authentication/remoteresourceslice-controller/remoteresourceslice_controller.go index cf506feb5f..eae98501c9 100644 --- a/pkg/liqo-controller-manager/authentication/remoteresourceslice-controller/remoteresourceslice_controller.go +++ b/pkg/liqo-controller-manager/authentication/remoteresourceslice-controller/remoteresourceslice_controller.go @@ -271,7 +271,11 @@ func (r *RemoteResourceSliceReconciler) SetupWithManager(mgr ctrl.Manager) error } return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlResourceSliceRemote). - For(&authv1beta1.ResourceSlice{}, builder.WithPredicates(predicate.And(remoteResSliceFilter, withCSR()))). + For( + &authv1beta1.ResourceSlice{}, + // With GenerationChangedPredicate we prevent to reconcile multiple times when the status of the resource changes + builder.WithPredicates(predicate.And(remoteResSliceFilter, withCSR(), predicate.GenerationChangedPredicate{})), + ). Watches(&authv1beta1.Tenant{}, handler.EnqueueRequestsFromMapFunc(r.resourceSlicesEnquer())). Complete(r) }