mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-04 00:24:59 +00:00
Remove Queue.AddIfNotPresent
Logically a cache.Queue.AddIfNotPresent means that the informer can move back in time since an older item is placed after newer items. The alternative of placing errors at the head of the queue leads to indefinite memory growth and repeated failures on retry. Luckily this behavior was behind RetryOnError, which was always set to false and impossible for normal users to set to true. By removing the function and setting, impacted users (none found in a github search) will get a compile failure. Kubernetes-commit: 8e77ac000131019d5aa49c19aa1f477f6dac4d59
This commit is contained in:
committed by
Kubernetes Publisher
parent
f29637f7f2
commit
d853ccf18c
22
tools/cache/fifo.go
vendored
22
tools/cache/fifo.go
vendored
@@ -64,11 +64,6 @@ type Queue interface {
|
||||
// Pop.
|
||||
Pop(PopProcessFunc) (interface{}, error)
|
||||
|
||||
// AddIfNotPresent puts the given accumulator into the Queue (in
|
||||
// association with the accumulator's key) if and only if that key
|
||||
// is not already associated with a non-empty accumulator.
|
||||
AddIfNotPresent(interface{}) error
|
||||
|
||||
// HasSynced returns true if the first batch of keys have all been
|
||||
// popped. The first batch of keys are those of the first Replace
|
||||
// operation if that happened before any Add, AddIfNotPresent,
|
||||
@@ -177,23 +172,6 @@ func (f *FIFO) Add(obj interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddIfNotPresent inserts an item, and puts it in the queue. If the item is already
|
||||
// present in the set, it is neither enqueued nor added to the set.
|
||||
//
|
||||
// This is useful in a single producer/consumer scenario so that the consumer can
|
||||
// safely retry items without contending with the producer and potentially enqueueing
|
||||
// stale items.
|
||||
func (f *FIFO) AddIfNotPresent(obj interface{}) error {
|
||||
id, err := f.keyFunc(obj)
|
||||
if err != nil {
|
||||
return KeyError{obj, err}
|
||||
}
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
f.addIfNotPresent(id, obj)
|
||||
return nil
|
||||
}
|
||||
|
||||
// addIfNotPresent assumes the fifo lock is already held and adds the provided
|
||||
// item to the queue under id if it does not already exist.
|
||||
func (f *FIFO) addIfNotPresent(id string, obj interface{}) {
|
||||
|
Reference in New Issue
Block a user