mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-27 15:39:39 +00:00
remove unused layer of loop structure in processorListener::run
Also updated the comment inside processorListener::run, to restore accuracy about how long the delay is. Kubernetes-commit: d2ad469abbb1122cbbd772e15767817cd771f9f6
This commit is contained in:
parent
7f990bd4b1
commit
cc22aafc1f
37
tools/cache/shared_informer.go
vendored
37
tools/cache/shared_informer.go
vendored
@ -25,7 +25,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/clock"
|
"k8s.io/apimachinery/pkg/util/clock"
|
||||||
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/retry"
|
|
||||||
"k8s.io/utils/buffer"
|
"k8s.io/utils/buffer"
|
||||||
|
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
@ -700,34 +699,26 @@ func (p *processorListener) pop() {
|
|||||||
|
|
||||||
func (p *processorListener) run() {
|
func (p *processorListener) run() {
|
||||||
// this call blocks until the channel is closed. When a panic happens during the notification
|
// 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 minute)
|
// 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
|
// the next notification will be attempted. This is usually better than the alternative of never
|
||||||
// delivering again.
|
// delivering again.
|
||||||
stopCh := make(chan struct{})
|
stopCh := make(chan struct{})
|
||||||
wait.Until(func() {
|
wait.Until(func() {
|
||||||
// this gives us a few quick retries before a long pause and then a few more quick retries
|
for next := range p.nextCh {
|
||||||
err := wait.ExponentialBackoff(retry.DefaultRetry, func() (bool, error) {
|
switch notification := next.(type) {
|
||||||
for next := range p.nextCh {
|
case updateNotification:
|
||||||
switch notification := next.(type) {
|
p.handler.OnUpdate(notification.oldObj, notification.newObj)
|
||||||
case updateNotification:
|
case addNotification:
|
||||||
p.handler.OnUpdate(notification.oldObj, notification.newObj)
|
p.handler.OnAdd(notification.newObj)
|
||||||
case addNotification:
|
case deleteNotification:
|
||||||
p.handler.OnAdd(notification.newObj)
|
p.handler.OnDelete(notification.oldObj)
|
||||||
case deleteNotification:
|
default:
|
||||||
p.handler.OnDelete(notification.oldObj)
|
utilruntime.HandleError(fmt.Errorf("unrecognized notification: %T", next))
|
||||||
default:
|
|
||||||
utilruntime.HandleError(fmt.Errorf("unrecognized notification: %T", 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)
|
// the only way to get here is if the p.nextCh is empty and closed
|
||||||
|
close(stopCh)
|
||||||
|
}, 1*time.Second, 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