Skip to content

Commit

Permalink
Resource syncer should remove itself from SharedInformer when stopped
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Pantelis <[email protected]>
  • Loading branch information
tpantelis committed May 29, 2024
1 parent 216f2c6 commit 67baef6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/syncer/resource_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ type ResourceSyncerConfig struct {
type resourceSyncer struct {
workQueue workqueue.Interface
hasSynced func() bool
unregHandler func()
informer cache.Controller
store cache.Store
config ResourceSyncerConfig
Expand Down Expand Up @@ -261,6 +262,10 @@ func NewResourceSyncerWithSharedInformer(config *ResourceSyncerConfig, informer

syncer.hasSynced = reg.HasSynced

syncer.unregHandler = func() {
_ = informer.RemoveEventHandler(reg)
}

return syncer, nil
}

Expand Down Expand Up @@ -349,6 +354,10 @@ func (r *resourceSyncer) Start(stopCh <-chan struct{}) error {
prometheus.Unregister(r.syncCounter)
}

if r.unregHandler != nil {
r.unregHandler()
}

r.stopped <- struct{}{}
r.log.V(log.LIBDEBUG).Infof("Syncer %q stopped", r.config.Name)
}()
Expand Down

0 comments on commit 67baef6

Please sign in to comment.