diff --git a/applicationset/controllers/applicationset_controller.go b/applicationset/controllers/applicationset_controller.go index a2a7ac7ffeee8..fad22fdf55058 100644 --- a/applicationset/controllers/applicationset_controller.go +++ b/applicationset/controllers/applicationset_controller.go @@ -31,7 +31,6 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/kubernetes" - k8scache "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" @@ -626,25 +625,6 @@ func (r *ApplicationSetReconciler) SetupWithManager(mgr ctrl.Manager, enableProg Complete(r) } -func (r *ApplicationSetReconciler) updateCache(ctx context.Context, obj client.Object, logger *log.Entry) { - informer, err := r.Cache.GetInformer(ctx, obj) - if err != nil { - logger.Errorf("failed to get informer: %v", err) - return - } - // The controller runtime abstract away informers creation - // so unfortunately could not find any other way to access informer store. - k8sInformer, ok := informer.(k8scache.SharedInformer) - if !ok { - logger.Error("informer is not a kubernetes informer") - return - } - if err := k8sInformer.GetStore().Update(obj); err != nil { - logger.Errorf("failed to update cache: %v", err) - return - } -} - // createOrUpdateInCluster will create / update application resources in the cluster. // - For new applications, it will call create // - For existing application, it will call update @@ -746,7 +726,6 @@ func (r *ApplicationSetReconciler) createOrUpdateInCluster(ctx context.Context, } continue } - r.updateCache(ctx, found, appLog) if action != controllerutil.OperationResultNone { // Don't pollute etcd with "unchanged Application" events @@ -913,7 +892,6 @@ func (r *ApplicationSetReconciler) removeFinalizerOnInvalidDestination(ctx conte if err := r.Client.Patch(ctx, updated, patch); err != nil { return fmt.Errorf("error updating finalizers: %w", err) } - r.updateCache(ctx, updated, appLog) // Application must have updated list of finalizers updated.DeepCopyInto(app)