fix logging every microsecond when etcd goes down

pull/6/head
Daniel Smith 2016-02-09 00:11:27 -08:00
parent c75e344b47
commit 4e85d42f99
1 changed files with 7 additions and 8 deletions

View File

@ -171,13 +171,14 @@ func NewCacherFromConfig(config CacherConfig) *Cacher {
stopCh := cacher.stopCh
cacher.stopWg.Add(1)
go func() {
defer cacher.stopWg.Done()
wait.Until(
func() {
if !cacher.isStopped() {
cacher.startCaching(stopCh)
}
}, 0, stopCh)
cacher.stopWg.Done()
}, time.Second, stopCh,
)
}()
return cacher
}
@ -197,12 +198,10 @@ func (c *Cacher) startCaching(stopChannel <-chan struct{}) {
c.terminateAllWatchers()
// Note that since onReplace may be not called due to errors, we explicitly
// need to retry it on errors under lock.
for {
if err := c.reflector.ListAndWatch(stopChannel); err != nil {
glog.Errorf("unexpected ListAndWatch error: %v", err)
} else {
break
}
// Also note that startCaching is called in a loop, so there's no need
// to have another loop here.
if err := c.reflector.ListAndWatch(stopChannel); err != nil {
glog.Errorf("unexpected ListAndWatch error: %v", err)
}
}