Skip to content

Commit

Permalink
Fix checking informer syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerun committed May 12, 2020
1 parent a6b5fa7 commit 474176d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion source/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ func NewServiceSource(kubeClient kubernetes.Interface, namespace, annotationFilt

// wait for the local cache to be populated.
err = poll(time.Second, 60*time.Second, func() (bool, error) {
return serviceInformer.Informer().HasSynced(), nil
return serviceInformer.Informer().HasSynced() &&
endpointsInformer.Informer().HasSynced() &&
podInformer.Informer().HasSynced() &&
nodeInformer.Informer().HasSynced(), nil
})
if err != nil {
return nil, fmt.Errorf("failed to sync cache: %v", err)
Expand Down
14 changes: 13 additions & 1 deletion source/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,20 @@ func matchLabelSelector(selector labels.Selector, srcAnnotations map[string]stri

func poll(interval time.Duration, timeout time.Duration, condition wait.ConditionFunc) error {
if config.FAST_POLL {
time.Sleep(5 * time.Millisecond)

ok, err := condition()

if err != nil {
return err
}

if ok {
return nil
}

interval = 50 * time.Millisecond
timeout = 5 * time.Second
timeout = 10 * time.Second
}

return wait.Poll(interval, timeout, condition)
Expand Down

0 comments on commit 474176d

Please sign in to comment.