mirror of https://github.com/k3s-io/k3s
fix logging every microsecond when etcd goes down
parent
c75e344b47
commit
4e85d42f99
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue