Merge pull request #87393 from MikeSpreitzer/remove-unused-loop

remove unused layer of loop structure in processorListener::run
This commit is contained in:
Kubernetes Prow Robot 2020-01-24 19:21:28 -08:00 committed by GitHub
commit 94ea2be3cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 24 deletions

View File

@ -88,7 +88,6 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
"//staging/src/k8s.io/client-go/rest:go_default_library", "//staging/src/k8s.io/client-go/rest:go_default_library",
"//staging/src/k8s.io/client-go/tools/pager:go_default_library", "//staging/src/k8s.io/client-go/tools/pager:go_default_library",
"//staging/src/k8s.io/client-go/util/retry:go_default_library",
"//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/utils/buffer:go_default_library", "//vendor/k8s.io/utils/buffer:go_default_library",
"//vendor/k8s.io/utils/trace:go_default_library", "//vendor/k8s.io/utils/trace:go_default_library",

View File

@ -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,