Skip to content

Commit 9a65711

Browse files
committed
refactor(queueinformer): prevent > 1 run calls for duplicate informers
1 parent 181aafb commit 9a65711

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

pkg/lib/queueinformer/queueinformer_operator.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,21 @@ func (o *Operator) Run(stopc <-chan struct{}) (ready, done chan struct{}, atLeve
123123
}
124124

125125
o.Log.Info("starting informers...")
126-
for _, queueInformer := range o.queueInformers {
127-
go queueInformer.informer.Run(stopc)
128-
}
126+
{
127+
started := make(map[cache.SharedIndexInformer]struct{})
128+
for _, queueInformer := range o.queueInformers {
129+
if _, ok := started[queueInformer.informer]; !ok {
130+
go queueInformer.informer.Run(stopc)
131+
}
132+
started[queueInformer.informer] = struct{}{}
133+
}
129134

130-
for _, informer := range o.informers {
131-
go informer.Run(stopc)
135+
for _, informer := range o.informers {
136+
if _, ok := started[informer]; !ok {
137+
go informer.Run(stopc)
138+
}
139+
started[informer] = struct{}{}
140+
}
132141
}
133142

134143
o.Log.Info("waiting for caches to sync...")

0 commit comments

Comments
 (0)