mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-26 15:12:06 +00:00
Merge pull request #59159 from roycaihw/dfifo
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add comments about potential race in delta fifo **What this PR does / why we need it**: **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ``` /sig api-machinery Kubernetes-commit: 0394ffba6de860ece173a9a485d3518d3a8d37f2
This commit is contained in:
commit
9132b13e95
1160
Godeps/Godeps.json
generated
1160
Godeps/Godeps.json
generated
File diff suppressed because it is too large
Load Diff
23
tools/cache/delta_fifo.go
vendored
23
tools/cache/delta_fifo.go
vendored
@ -38,9 +38,22 @@ import (
|
|||||||
// TODO: consider merging keyLister with this object, tracking a list of
|
// TODO: consider merging keyLister with this object, tracking a list of
|
||||||
// "known" keys when Pop() is called. Have to think about how that
|
// "known" keys when Pop() is called. Have to think about how that
|
||||||
// affects error retrying.
|
// affects error retrying.
|
||||||
// TODO(lavalamp): I believe there is a possible race only when using an
|
// NOTE: It is possible to misuse this and cause a race when using an
|
||||||
// external known object source that the above TODO would
|
// external known object source.
|
||||||
// fix.
|
// Whether there is a potential race depends on how the comsumer
|
||||||
|
// modifies knownObjects. In Pop(), process function is called under
|
||||||
|
// lock, so it is safe to update data structures in it that need to be
|
||||||
|
// in sync with the queue (e.g. knownObjects).
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
// In case of sharedIndexInformer being a consumer
|
||||||
|
// (https://github.com/kubernetes/kubernetes/blob/0cdd940f/staging/
|
||||||
|
// src/k8s.io/client-go/tools/cache/shared_informer.go#L192),
|
||||||
|
// there is no race as knownObjects (s.indexer) is modified safely
|
||||||
|
// under DeltaFIFO's lock. The only exceptions are GetStore() and
|
||||||
|
// GetIndexer() methods, which expose ways to modify the underlying
|
||||||
|
// storage. Currently these two methods are used for creating Lister
|
||||||
|
// and internal tests.
|
||||||
//
|
//
|
||||||
// Also see the comment on DeltaFIFO.
|
// Also see the comment on DeltaFIFO.
|
||||||
func NewDeltaFIFO(keyFunc KeyFunc, knownObjects KeyListerGetter) *DeltaFIFO {
|
func NewDeltaFIFO(keyFunc KeyFunc, knownObjects KeyListerGetter) *DeltaFIFO {
|
||||||
@ -199,8 +212,6 @@ func (f *DeltaFIFO) Delete(obj interface{}) error {
|
|||||||
if err == nil && !exists && !itemsExist {
|
if err == nil && !exists && !itemsExist {
|
||||||
// Presumably, this was deleted when a relist happened.
|
// Presumably, this was deleted when a relist happened.
|
||||||
// Don't provide a second report of the same deletion.
|
// Don't provide a second report of the same deletion.
|
||||||
// TODO(lavalamp): This may be racy-- we aren't properly locked
|
|
||||||
// with knownObjects.
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -485,8 +496,6 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Detect deletions not already in the queue.
|
// Detect deletions not already in the queue.
|
||||||
// TODO(lavalamp): This may be racy-- we aren't properly locked
|
|
||||||
// with knownObjects. Unproven.
|
|
||||||
knownKeys := f.knownObjects.ListKeys()
|
knownKeys := f.knownObjects.ListKeys()
|
||||||
queuedDeletions := 0
|
queuedDeletions := 0
|
||||||
for _, k := range knownKeys {
|
for _, k := range knownKeys {
|
||||||
|
Loading…
Reference in New Issue
Block a user