From a57adb3883a0a49b1da8b7e31b2cf6de80823f03 Mon Sep 17 00:00:00 2001 From: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Date: Thu, 22 Aug 2024 04:16:32 +0000 Subject: [PATCH] fix(appset): informer is not a kubernetes informer (#18905) (#19618) Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> --- .../controllers/applicationset_controller.go | 22 ------------------- 1 file changed, 22 deletions(-) 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)