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:
Kubernetes Publisher 2018-02-24 20:46:31 -08:00
commit 9132b13e95
2 changed files with 596 additions and 587 deletions

164
Godeps/Godeps.json generated
View File

@ -248,331 +248,331 @@
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/apps/v1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/apps/v1beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/apps/v1beta2",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/authentication/v1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/authentication/v1beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/authorization/v1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/authorization/v1beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/autoscaling/v1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/batch/v1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/batch/v1beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/batch/v2alpha1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/certificates/v1beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/core/v1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/events/v1beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/extensions/v1beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/networking/v1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/policy/v1beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/rbac/v1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/rbac/v1alpha1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/rbac/v1beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/settings/v1alpha1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/storage/v1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/storage/v1alpha1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/api/storage/v1beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "0406a944760b00b7a75b559f642673d7bb07b48a"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/testing",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "69f93cfab5c1d87f2cbd5e6631af8268b7f5542b"
"Rev": "67f813598630f41e59978aafdcf0af33fe02b117"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",

View File

@ -38,9 +38,22 @@ import (
// TODO: consider merging keyLister with this object, tracking a list of
// "known" keys when Pop() is called. Have to think about how that
// affects error retrying.
// TODO(lavalamp): I believe there is a possible race only when using an
// external known object source that the above TODO would
// fix.
// NOTE: It is possible to misuse this and cause a race when using an
// external known object source.
// 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.
func NewDeltaFIFO(keyFunc KeyFunc, knownObjects KeyListerGetter) *DeltaFIFO {
@ -199,8 +212,6 @@ func (f *DeltaFIFO) Delete(obj interface{}) error {
if err == nil && !exists && !itemsExist {
// Presumably, this was deleted when a relist happened.
// 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
}
}
@ -485,8 +496,6 @@ func (f *DeltaFIFO) Replace(list []interface{}, resourceVersion string) error {
}
// 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()
queuedDeletions := 0
for _, k := range knownKeys {