mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Merge pull request #8915 from fgrzadkowski/fix_reflector
Reduce number of list requests in watch-based cache
This commit is contained in:
commit
e9ccec4c35
17
pkg/client/cache/reflector.go
vendored
17
pkg/client/cache/reflector.go
vendored
@ -19,8 +19,11 @@ package cache
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
"net"
|
||||||
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
apierrs "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
|
apierrs "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
|
||||||
@ -161,10 +164,22 @@ func (r *Reflector) listAndWatch(stopCh <-chan struct{}) {
|
|||||||
default:
|
default:
|
||||||
glog.Errorf("Failed to watch %v: %v", r.expectedType, err)
|
glog.Errorf("Failed to watch %v: %v", r.expectedType, err)
|
||||||
}
|
}
|
||||||
|
// If this is "connection refused" error, it means that most likely apiserver is not responsive.
|
||||||
|
// It doesn't make sense to re-list all objects because most likely we will be able to restart
|
||||||
|
// watch where we ended.
|
||||||
|
// If that's the case wait and resend watch request.
|
||||||
|
if urlError, ok := err.(*url.Error); ok {
|
||||||
|
if opError, ok := urlError.Err.(*net.OpError); ok {
|
||||||
|
if errno, ok := opError.Err.(syscall.Errno); ok && errno == syscall.ECONNREFUSED {
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := r.watchHandler(w, &resourceVersion, resyncCh, stopCh); err != nil {
|
if err := r.watchHandler(w, &resourceVersion, resyncCh, stopCh); err != nil {
|
||||||
if err != errorResyncRequested {
|
if err != errorResyncRequested && err != errorStopRequested {
|
||||||
glog.Errorf("watch of %v ended with: %v", r.expectedType, err)
|
glog.Errorf("watch of %v ended with: %v", r.expectedType, err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user