mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-15 14:48:16 +00:00
Remove cache.ErrRequeue
cache.ErrRequeue advertised itself as a way to requeue failures on a FIFO, but it suffers the same problems as AddIfNotPresent. If we do requeue an item at the end, we'll move the informer back in time. If we requeue at the beginning we'll simply wedge FIFO. We didn't find examples in the wild, but by removing the error type those impacted will get a compile error and get to decide what action is most appropriate for their failure. Most of the time, proceeding to the next item is best. Kubernetes-commit: 238c32a1d9b2c72d648193fa8642a53a2884975f
This commit is contained in:
committed by
Kubernetes Publisher
parent
d853ccf18c
commit
52af3bdc0f
45
tools/cache/fifo_test.go
vendored
45
tools/cache/fifo_test.go
vendored
@@ -17,7 +17,6 @@ limitations under the License.
|
||||
package cache
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"testing"
|
||||
@@ -116,50 +115,6 @@ func TestFIFO_basic(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFIFO_requeueOnPop(t *testing.T) {
|
||||
f := NewFIFO(testFifoObjectKeyFunc)
|
||||
|
||||
f.Add(mkFifoObj("foo", 10))
|
||||
_, err := f.Pop(func(obj interface{}, isInInitialList bool) error {
|
||||
if obj.(testFifoObject).name != "foo" {
|
||||
t.Fatalf("unexpected object: %#v", obj)
|
||||
}
|
||||
return ErrRequeue{Err: nil}
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if _, ok, err := f.GetByKey("foo"); !ok || err != nil {
|
||||
t.Fatalf("object should have been requeued: %t %v", ok, err)
|
||||
}
|
||||
|
||||
_, err = f.Pop(func(obj interface{}, isInInitialList bool) error {
|
||||
if obj.(testFifoObject).name != "foo" {
|
||||
t.Fatalf("unexpected object: %#v", obj)
|
||||
}
|
||||
return ErrRequeue{Err: fmt.Errorf("test error")}
|
||||
})
|
||||
if err == nil || err.Error() != "test error" {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if _, ok, err := f.GetByKey("foo"); !ok || err != nil {
|
||||
t.Fatalf("object should have been requeued: %t %v", ok, err)
|
||||
}
|
||||
|
||||
_, err = f.Pop(func(obj interface{}, isInInitialList bool) error {
|
||||
if obj.(testFifoObject).name != "foo" {
|
||||
t.Fatalf("unexpected object: %#v", obj)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if _, ok, err := f.GetByKey("foo"); ok || err != nil {
|
||||
t.Fatalf("object should have been removed: %t %v", ok, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFIFO_addUpdate(t *testing.T) {
|
||||
f := NewFIFO(testFifoObjectKeyFunc)
|
||||
f.Add(mkFifoObj("foo", 10))
|
||||
|
Reference in New Issue
Block a user