Skip to content

Commit a58e0d6

Browse files
committed
Simplify wait for cache sync
1 parent 9cff5f0 commit a58e0d6

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

pkg/cache/internal/informers_map.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,9 @@ func (ip *specificInformersMap) Get(ctx context.Context, gvk schema.GroupVersion
182182
}
183183

184184
if started && !i.Informer.HasSynced() {
185-
syncReturn := make(chan bool, 1 /* don't leak goroutines on timeout */)
186-
go func() {
187-
syncReturn <- cache.WaitForCacheSync(ctx.Done(), i.Informer.HasSynced)
188-
}()
189-
190-
// Wait for it to sync before returning the Informer so that folks don't read from a stale cache.
191-
select {
192-
case <-ctx.Done():
185+
syncSuccess := cache.WaitForCacheSync(ctx.Done(), i.Informer.HasSynced)
186+
if !syncSuccess {
193187
return started, nil, apierrors.NewTimeoutError(fmt.Sprintf("timeout waiting for %T Informer to sync", obj), 0)
194-
case syncSuccess := <-syncReturn:
195-
if !syncSuccess {
196-
return started, nil, fmt.Errorf("failed waiting for %T Informer to sync", obj)
197-
}
198188
}
199189
}
200190

0 commit comments

Comments
 (0)