Skip to content

Commit

Permalink
refactor(queueinformer): prevent > 1 run calls for duplicate informers
Browse files Browse the repository at this point in the history
  • Loading branch information
njhale committed Apr 17, 2019
1 parent 357931e commit 5afe09b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/lib/queueinformer/queueinformer_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,24 @@ func (o *Operator) Run(stopc <-chan struct{}) (ready, done chan struct{}, atLeve
}

o.Log.Info("starting informers...")
started := make(map[cache.SharedIndexInformer]struct{})
for _, queueInformer := range o.queueInformers {
go queueInformer.informer.Run(stopc)
if _, ok := started[queueInformer.informer]; !ok {
go queueInformer.informer.Run(stopc)
}
started[queueInformer.informer] = struct{}{}
}

for _, informer := range o.informers {
go informer.Run(stopc)
if _, ok := started[informer]; !ok {
go informer.Run(stopc)
}
started[informer] = struct{}{}
}

// Zero-out so started will be GC'd since this goroutine will live for a while
started = nil

o.Log.Info("waiting for caches to sync...")
if ok := cache.WaitForCacheSync(stopc, hasSyncedCheckFns...); !ok {
o.Log.Info("failed to wait for caches to sync")
Expand Down

0 comments on commit 5afe09b

Please sign in to comment.