Commit 1df0dfda authored by Robert Bailey's avatar Robert Bailey

Merge pull request #25122 from nowprovision/reflector-loop-missing-errorhandler-fix

Handle possible error in client reflector run loops
parents 71ab966f 89e5e81b
...@@ -200,14 +200,22 @@ func extractStackCreator() (string, int, bool) { ...@@ -200,14 +200,22 @@ func extractStackCreator() (string, int, bool) {
// Run starts a goroutine and returns immediately. // Run starts a goroutine and returns immediately.
func (r *Reflector) Run() { func (r *Reflector) Run() {
glog.V(3).Infof("Starting reflector %v (%s) from %s", r.expectedType, r.resyncPeriod, r.name) glog.V(3).Infof("Starting reflector %v (%s) from %s", r.expectedType, r.resyncPeriod, r.name)
go wait.Until(func() { r.ListAndWatch(wait.NeverStop) }, r.period, wait.NeverStop) go wait.Until(func() {
if err := r.ListAndWatch(wait.NeverStop); err != nil {
utilruntime.HandleError(err)
}
}, r.period, wait.NeverStop)
} }
// RunUntil starts a watch and handles watch events. Will restart the watch if it is closed. // RunUntil starts a watch and handles watch events. Will restart the watch if it is closed.
// RunUntil starts a goroutine and returns immediately. It will exit when stopCh is closed. // RunUntil starts a goroutine and returns immediately. It will exit when stopCh is closed.
func (r *Reflector) RunUntil(stopCh <-chan struct{}) { func (r *Reflector) RunUntil(stopCh <-chan struct{}) {
glog.V(3).Infof("Starting reflector %v (%s) from %s", r.expectedType, r.resyncPeriod, r.name) glog.V(3).Infof("Starting reflector %v (%s) from %s", r.expectedType, r.resyncPeriod, r.name)
go wait.Until(func() { r.ListAndWatch(stopCh) }, r.period, stopCh) go wait.Until(func() {
if err := r.ListAndWatch(stopCh); err != nil {
utilruntime.HandleError(err)
}
}, r.period, stopCh)
} }
var ( var (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment