Merge pull request #70801 from Adirio/deltafifo-cleanup

DeltaFIFO cleanup

Kubernetes-commit: 4fb368e5fdd287d0feb9f603360293c8dd8ae816
This commit is contained in:
Kubernetes Publisher 2018-11-14 19:19:57 -08:00
commit 4ed618c609
2 changed files with 58 additions and 66 deletions

104
Godeps/Godeps.json generated
View File

@ -1,7 +1,7 @@
{ {
"ImportPath": "k8s.io/client-go", "ImportPath": "k8s.io/client-go",
"GoVersion": "go1.11", "GoVersion": "go1.11",
"GodepVersion": "v80", "GodepVersion": "v80-k8s-r1",
"Packages": [ "Packages": [
"./..." "./..."
], ],
@ -404,207 +404,207 @@
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting", "ImportPath": "k8s.io/apimachinery/pkg/api/apitesting",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer", "ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip", "ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/equality", "ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/errors", "ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/meta", "ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/resource", "ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion", "ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams", "ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/fields", "ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/labels", "ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime", "ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema", "ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/selection", "ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/types", "ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/cache", "ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/clock", "ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/diff", "ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/errors", "ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/framer", "ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream", "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy", "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr", "ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/json", "ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch", "ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/naming", "ImportPath": "k8s.io/apimachinery/pkg/util/naming",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/net", "ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand", "ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime", "ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/sets", "ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch", "ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/validation", "ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field", "ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/wait", "ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml", "ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/version", "ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/watch", "ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "2a7c9300402896b3c073f2f47df85527c94f83a0" "Rev": "a33c8200050fc0751848276811abf3fc029b3133"
}, },
{ {
"ImportPath": "k8s.io/klog", "ImportPath": "k8s.io/klog",

View File

@ -320,17 +320,15 @@ func (f *DeltaFIFO) queueActionLocked(actionType DeltaType, obj interface{}) err
newDeltas := append(f.items[id], Delta{actionType, obj}) newDeltas := append(f.items[id], Delta{actionType, obj})
newDeltas = dedupDeltas(newDeltas) newDeltas = dedupDeltas(newDeltas)
_, exists := f.items[id]
if len(newDeltas) > 0 { if len(newDeltas) > 0 {
if !exists { if _, exists := f.items[id]; !exists {
f.queue = append(f.queue, id) f.queue = append(f.queue, id)
} }
f.items[id] = newDeltas f.items[id] = newDeltas
f.cond.Broadcast() f.cond.Broadcast()
} else if exists { } else {
// We need to remove this from our map (extra items // We need to remove this from our map (extra items in the queue are
// in the queue are ignored if they are not in the // ignored if they are not in the map).
// map).
delete(f.items, id) delete(f.items, id)
} }
return nil return nil
@ -348,9 +346,6 @@ func (f *DeltaFIFO) List() []interface{} {
func (f *DeltaFIFO) listLocked() []interface{} { func (f *DeltaFIFO) listLocked() []interface{} {
list := make([]interface{}, 0, len(f.items)) list := make([]interface{}, 0, len(f.items))
for _, item := range f.items { for _, item := range f.items {
// Copy item's slice so operations on this slice
// won't interfere with the object we return.
item = copyDeltas(item)
list = append(list, item.Newest().Object) list = append(list, item.Newest().Object)
} }
return list return list
@ -398,10 +393,7 @@ func (f *DeltaFIFO) GetByKey(key string) (item interface{}, exists bool, err err
func (f *DeltaFIFO) IsClosed() bool { func (f *DeltaFIFO) IsClosed() bool {
f.closedLock.Lock() f.closedLock.Lock()
defer f.closedLock.Unlock() defer f.closedLock.Unlock()
if f.closed { return f.closed
return true
}
return false
} }
// Pop blocks until an item is added to the queue, and then returns it. If // Pop blocks until an item is added to the queue, and then returns it. If
@ -432,10 +424,10 @@ func (f *DeltaFIFO) Pop(process PopProcessFunc) (interface{}, error) {
} }
id := f.queue[0] id := f.queue[0]
f.queue = f.queue[1:] f.queue = f.queue[1:]
item, ok := f.items[id]
if f.initialPopulationCount > 0 { if f.initialPopulationCount > 0 {
f.initialPopulationCount-- f.initialPopulationCount--
} }
item, ok := f.items[id]
if !ok { if !ok {
// Item may have been deleted subsequently. // Item may have been deleted subsequently.
continue continue