mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-27 15:39:39 +00:00
Replaced repair with returning error, in delta_fifo.go
When dedupDeltas does the impossible and the key is already queued, return an error rather than maintain the data structure invariants. Kubernetes-commit: a39481a4f6cf33f9bf4555adcffa28077863e7a9
This commit is contained in:
parent
a166e2578b
commit
53f29dc721
33
tools/cache/delta_fifo.go
vendored
33
tools/cache/delta_fifo.go
vendored
@ -395,9 +395,9 @@ func (f *DeltaFIFO) queueActionLocked(actionType DeltaType, obj interface{}) err
|
||||
klog.Errorf("Impossible dedupDeltas for id=%q: oldDeltas=%#+v, obj=%#+v; ignoring", id, oldDeltas, obj)
|
||||
return nil
|
||||
}
|
||||
klog.Errorf("Impossible dedupDeltas for id=%q: oldDeltas=%#+v, obj=%#+v; removing from queue", id, oldDeltas, obj)
|
||||
klog.Errorf("Impossible dedupDeltas for id=%q: oldDeltas=%#+v, obj=%#+v; breaking invariant by storing empty Deltas", id, oldDeltas, obj)
|
||||
f.items[id] = newDeltas
|
||||
f.filterQueueLocked()
|
||||
return fmt.Errorf("Impossible dedupDeltas for id=%q: oldDeltas=%#+v, obj=%#+v; broke DeltaFIFO invariant by storing empty Deltas", id, oldDeltas, obj)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -656,35 +656,6 @@ func (f *DeltaFIFO) syncKeyLocked(key string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// A partial repair function. Removes keys from f.queue that
|
||||
// correspond to nothing in f.items. Removes keys from both when the
|
||||
// entry in f.items has zero length. Ensures each key appears at most
|
||||
// once in queue. Must be called with the lock held.
|
||||
func (f *DeltaFIFO) filterQueueLocked() {
|
||||
newQueue := make([]string, 0, len(f.queue))
|
||||
newItems := make(map[string]Deltas, len(f.items))
|
||||
for _, key := range f.queue {
|
||||
if _, exists := newItems[key]; exists {
|
||||
klog.Errorf("Removing duplicate key %q", key)
|
||||
continue
|
||||
}
|
||||
deltas, exists := f.items[key]
|
||||
if !exists {
|
||||
klog.Errorf("Removing key %q because it has no Deltas", key)
|
||||
continue
|
||||
}
|
||||
if len(deltas) == 0 {
|
||||
klog.Errorf("Removing key %q because it has zero-length Deltas", key)
|
||||
continue
|
||||
}
|
||||
newQueue = append(newQueue, key)
|
||||
newItems[key] = deltas
|
||||
}
|
||||
klog.Info("Finished repair of queue")
|
||||
f.queue = newQueue
|
||||
f.items = newItems
|
||||
}
|
||||
|
||||
// A KeyListerGetter is anything that knows how to list its keys and look up by key.
|
||||
type KeyListerGetter interface {
|
||||
KeyLister
|
||||
|
Loading…
Reference in New Issue
Block a user