Updating a FilterFunc on an Informer?

9 views
Skip to first unread message

Greg Allen

unread,
Sep 29, 2025, 10:20:55 PMSep 29
to Operator Framework
I have an informer that is created by this code:

        _, err := informer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{
                FilterFunc: predicate,
                Handler: cache.ResourceEventHandlerFuncs{
                        AddFunc: func(obj interface{}) {
                                log.Info("Resource added", "gvr", gvr.String())
                                r.sendCloudEvent(ctx, obj, "add", gvr, kindSelector.Kind)
                        },
                        UpdateFunc: func(oldObj, newObj interface{}) {
                                log.Info("Resource updated", "gvr", gvr.String())
                                r.sendCloudEvent(ctx, newObj, "update", gvr, kindSelector.Kind)
                        },
                        DeleteFunc: func(obj interface{}) {
                                log.Info("Resource deleted", "gvr", gvr.String())
                                r.sendCloudEvent(ctx, obj, "delete", gvr, kindSelector.Kind)
                        },
                },
        })


I create it and it works fine.  But things change, and I want to update the FilterFunc with a new predicate. Is this possible?

If not, I assume I'll have to create a new informer with the new predicate.  But if I do that, how do I make sure I don't miss any events between the stopping of the existing watch and the creation of the new watch?

Thanks!
Reply all
Reply to author
Forward
0 new messages