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
|
stopCh := cacher.stopCh
|
||||||
cacher.stopWg.Add(1)
|
cacher.stopWg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
defer cacher.stopWg.Done()
|
||||||
wait.Until(
|
wait.Until(
|
||||||
func() {
|
func() {
|
||||||
if !cacher.isStopped() {
|
if !cacher.isStopped() {
|
||||||
cacher.startCaching(stopCh)
|
cacher.startCaching(stopCh)
|
||||||
}
|
}
|
||||||
}, 0, stopCh)
|
}, time.Second, stopCh,
|
||||||
cacher.stopWg.Done()
|
)
|
||||||
}()
|
}()
|
||||||
return cacher
|
return cacher
|
||||||
}
|
}
|
||||||
|
@ -197,12 +198,10 @@ func (c *Cacher) startCaching(stopChannel <-chan struct{}) {
|
||||||
c.terminateAllWatchers()
|
c.terminateAllWatchers()
|
||||||
// Note that since onReplace may be not called due to errors, we explicitly
|
// Note that since onReplace may be not called due to errors, we explicitly
|
||||||
// need to retry it on errors under lock.
|
// need to retry it on errors under lock.
|
||||||
for {
|
// 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 {
|
if err := c.reflector.ListAndWatch(stopChannel); err != nil {
|
||||||
glog.Errorf("unexpected ListAndWatch error: %v", err)
|
glog.Errorf("unexpected ListAndWatch error: %v", err)
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue