mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-08 02:44:20 +00:00
don't stop informer delivery on error
Kubernetes-commit: 2fa93da6d5efd97dbcaad262a9e59073de9c5298
This commit is contained in:
parent
8a8517e82f
commit
1c2a06d4c0
1
tools/cache/BUILD
vendored
1
tools/cache/BUILD
vendored
@ -83,6 +83,7 @@ go_library(
|
|||||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/tools/pager:go_default_library",
|
"//vendor/k8s.io/client-go/tools/pager:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/util/buffer:go_default_library",
|
"//vendor/k8s.io/client-go/util/buffer:go_default_library",
|
||||||
|
"//vendor/k8s.io/client-go/util/retry:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
20
tools/cache/shared_informer.go
vendored
20
tools/cache/shared_informer.go
vendored
@ -26,6 +26,7 @@ import (
|
|||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/client-go/util/buffer"
|
"k8s.io/client-go/util/buffer"
|
||||||
|
"k8s.io/client-go/util/retry"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
@ -540,8 +541,14 @@ func (p *processorListener) pop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *processorListener) run() {
|
func (p *processorListener) run() {
|
||||||
defer utilruntime.HandleCrash()
|
// this call blocks until the channel is closed. When a panic happens during the notification
|
||||||
|
// we will catch it, **the offending item will be skipped!**, and after a short delay (one second)
|
||||||
|
// the next notification will be attempted. This is usually better than the alternative of never
|
||||||
|
// delivering again.
|
||||||
|
stopCh := make(chan struct{})
|
||||||
|
wait.Until(func() {
|
||||||
|
// this gives us a few quick retries before a long pause and then a few more quick retries
|
||||||
|
err := wait.ExponentialBackoff(retry.DefaultRetry, func() (bool, error) {
|
||||||
for next := range p.nextCh {
|
for next := range p.nextCh {
|
||||||
switch notification := next.(type) {
|
switch notification := next.(type) {
|
||||||
case updateNotification:
|
case updateNotification:
|
||||||
@ -554,6 +561,15 @@ func (p *processorListener) run() {
|
|||||||
utilruntime.HandleError(fmt.Errorf("unrecognized notification: %#v", next))
|
utilruntime.HandleError(fmt.Errorf("unrecognized notification: %#v", next))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// the only way to get here is if the p.nextCh is empty and closed
|
||||||
|
return true, nil
|
||||||
|
})
|
||||||
|
|
||||||
|
// the only way to get here is if the p.nextCh is empty and closed
|
||||||
|
if err == nil {
|
||||||
|
close(stopCh)
|
||||||
|
}
|
||||||
|
}, 1*time.Minute, stopCh)
|
||||||
}
|
}
|
||||||
|
|
||||||
// shouldResync deterimines if the listener needs a resync. If the listener's resyncPeriod is 0,
|
// shouldResync deterimines if the listener needs a resync. If the listener's resyncPeriod is 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user