mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-19 01:27:10 +00:00
Fixed a harmless bug where initialPopulationCount should be based on the key length not list size in DeltaFIFO#Replace()
Kubernetes-commit: bc39672c0638426979feef95baeff39d170161eb
This commit is contained in:
parent
50c086135a
commit
1d175299a2
4
tools/cache/delta_fifo.go
vendored
4
tools/cache/delta_fifo.go
vendored
@ -572,7 +572,7 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
|
|||||||
f.populated = true
|
f.populated = true
|
||||||
// While there shouldn't be any queued deletions in the initial
|
// While there shouldn't be any queued deletions in the initial
|
||||||
// population of the queue, it's better to be on the safe side.
|
// population of the queue, it's better to be on the safe side.
|
||||||
f.initialPopulationCount = len(list) + queuedDeletions
|
f.initialPopulationCount = keys.Len() + queuedDeletions
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -602,7 +602,7 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
|
|||||||
|
|
||||||
if !f.populated {
|
if !f.populated {
|
||||||
f.populated = true
|
f.populated = true
|
||||||
f.initialPopulationCount = len(list) + queuedDeletions
|
f.initialPopulationCount = keys.Len() + queuedDeletions
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
9
tools/cache/delta_fifo_test.go
vendored
9
tools/cache/delta_fifo_test.go
vendored
@ -633,6 +633,15 @@ func TestDeltaFIFO_HasSynced(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedSynced: true,
|
expectedSynced: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// This test case won't happen in practice since a Reflector, the only producer for delta_fifo today, always passes a complete snapshot consistent in time;
|
||||||
|
// there cannot be duplicate keys in the list or apiserver is broken.
|
||||||
|
actions: []func(f *DeltaFIFO){
|
||||||
|
func(f *DeltaFIFO) { f.Replace([]interface{}{mkFifoObj("a", 1), mkFifoObj("a", 2)}, "0") },
|
||||||
|
func(f *DeltaFIFO) { Pop(f) },
|
||||||
|
},
|
||||||
|
expectedSynced: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user