Merge pull request #60715 from aleksandra-malinowska/apiserver-cache-init

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>.

Fix initializing watch cache

When initializing watch cache, set auxiliary fields in `storeElement` object. Fixes #60507.

```release-note
NONE
```

Kubernetes-commit: e2dee6073933c99b63addecfd6397c058b512cd4
This commit is contained in:
Kubernetes Publisher 2018-03-05 08:58:48 -08:00
commit 172cbbd717
4 changed files with 145 additions and 108 deletions

168
Godeps/Godeps.json generated
View File

@ -816,339 +816,339 @@
}, },
{ {
"ImportPath": "k8s.io/api/admission/v1beta1", "ImportPath": "k8s.io/api/admission/v1beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1", "ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/admissionregistration/v1beta1", "ImportPath": "k8s.io/api/admissionregistration/v1beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/apps/v1", "ImportPath": "k8s.io/api/apps/v1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/apps/v1beta1", "ImportPath": "k8s.io/api/apps/v1beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/apps/v1beta2", "ImportPath": "k8s.io/api/apps/v1beta2",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/authentication/v1", "ImportPath": "k8s.io/api/authentication/v1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/authentication/v1beta1", "ImportPath": "k8s.io/api/authentication/v1beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/authorization/v1", "ImportPath": "k8s.io/api/authorization/v1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/authorization/v1beta1", "ImportPath": "k8s.io/api/authorization/v1beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/autoscaling/v1", "ImportPath": "k8s.io/api/autoscaling/v1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/autoscaling/v2beta1", "ImportPath": "k8s.io/api/autoscaling/v2beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/batch/v1", "ImportPath": "k8s.io/api/batch/v1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/batch/v1beta1", "ImportPath": "k8s.io/api/batch/v1beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/batch/v2alpha1", "ImportPath": "k8s.io/api/batch/v2alpha1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/certificates/v1beta1", "ImportPath": "k8s.io/api/certificates/v1beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/core/v1", "ImportPath": "k8s.io/api/core/v1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/events/v1beta1", "ImportPath": "k8s.io/api/events/v1beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/extensions/v1beta1", "ImportPath": "k8s.io/api/extensions/v1beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/networking/v1", "ImportPath": "k8s.io/api/networking/v1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/policy/v1beta1", "ImportPath": "k8s.io/api/policy/v1beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/rbac/v1", "ImportPath": "k8s.io/api/rbac/v1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/rbac/v1alpha1", "ImportPath": "k8s.io/api/rbac/v1alpha1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/rbac/v1beta1", "ImportPath": "k8s.io/api/rbac/v1beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/scheduling/v1alpha1", "ImportPath": "k8s.io/api/scheduling/v1alpha1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/settings/v1alpha1", "ImportPath": "k8s.io/api/settings/v1alpha1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/storage/v1", "ImportPath": "k8s.io/api/storage/v1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/storage/v1alpha1", "ImportPath": "k8s.io/api/storage/v1alpha1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/api/storage/v1beta1", "ImportPath": "k8s.io/api/storage/v1beta1",
"Rev": "860727955743743199a0f053f2292f41d7196604" "Rev": "7ebfdc5e7dfac82cc5c53e1259ad579915950e20"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/equality", "ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/errors", "ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/meta", "ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/resource", "ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/testing", "ImportPath": "k8s.io/apimachinery/pkg/api/testing",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer", "ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip", "ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/validation", "ImportPath": "k8s.io/apimachinery/pkg/api/validation",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/validation/path", "ImportPath": "k8s.io/apimachinery/pkg/api/validation/path",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery", "ImportPath": "k8s.io/apimachinery/pkg/apimachinery",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced", "ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered", "ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/validation", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/validation",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion", "ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams", "ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/fields", "ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/labels", "ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime", "ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema", "ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/selection", "ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/types", "ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/cache", "ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/clock", "ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/diff", "ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/errors", "ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/framer", "ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr", "ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/json", "ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch", "ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/net", "ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/rand", "ImportPath": "k8s.io/apimachinery/pkg/util/rand",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime", "ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/sets", "ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch", "ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/uuid", "ImportPath": "k8s.io/apimachinery/pkg/util/uuid",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/validation", "ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field", "ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/wait", "ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/waitgroup", "ImportPath": "k8s.io/apimachinery/pkg/util/waitgroup",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml", "ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/version", "ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/watch", "ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "4a62c19bf7bf4a3fdb2afb0b347553362d5c7684" "Rev": "e9ff529c66f83aeac6dff90f11ea0c5b7c4d626a"
}, },
{ {
"ImportPath": "k8s.io/client-go/discovery", "ImportPath": "k8s.io/client-go/discovery",

View File

@ -28,7 +28,6 @@ go_test(
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/clock:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/clock:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library", "//vendor/k8s.io/client-go/tools/cache:go_default_library",

View File

@ -377,7 +377,17 @@ func (w *watchCache) Replace(objs []interface{}, resourceVersion string) error {
if err != nil { if err != nil {
return fmt.Errorf("couldn't compute key: %v", err) return fmt.Errorf("couldn't compute key: %v", err)
} }
toReplace = append(toReplace, &storeElement{Key: key, Object: object}) objLabels, objFields, objUninitialized, err := w.getAttrsFunc(object)
if err != nil {
return err
}
toReplace = append(toReplace, &storeElement{
Key: key,
Object: object,
Labels: objLabels,
Fields: objFields,
Uninitialized: objUninitialized,
})
} }
w.Lock() w.Lock()

View File

@ -17,6 +17,7 @@ limitations under the License.
package storage package storage
import ( import (
"fmt"
"strconv" "strconv"
"testing" "testing"
"time" "time"
@ -29,7 +30,6 @@ import (
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/clock"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
@ -41,7 +41,23 @@ func makeTestPod(name string, resourceVersion uint64) *v1.Pod {
Namespace: "ns", Namespace: "ns",
Name: name, Name: name,
ResourceVersion: strconv.FormatUint(resourceVersion, 10), ResourceVersion: strconv.FormatUint(resourceVersion, 10),
Labels: map[string]string{
"k8s-app": "my-app",
},
}, },
Spec: v1.PodSpec{
NodeName: "some-node",
},
}
}
func makeTestStoreElement(pod *v1.Pod) *storeElement {
return &storeElement{
Key: "prefix/ns/" + pod.Name,
Object: pod,
Labels: labels.Set(pod.Labels),
Fields: fields.Set{"spec.nodeName": pod.Spec.NodeName},
Uninitialized: false,
} }
} }
@ -51,7 +67,11 @@ func newTestWatchCache(capacity int) *watchCache {
return NamespaceKeyFunc("prefix", obj) return NamespaceKeyFunc("prefix", obj)
} }
getAttrsFunc := func(obj runtime.Object) (labels.Set, fields.Set, bool, error) { getAttrsFunc := func(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
return nil, nil, false, nil pod, ok := obj.(*v1.Pod)
if !ok {
return nil, nil, false, fmt.Errorf("not a pod!")
}
return labels.Set(pod.Labels), fields.Set{"spec.nodeName": pod.Spec.NodeName}, false, nil
} }
wc := newWatchCache(capacity, keyFunc, getAttrsFunc) wc := newWatchCache(capacity, keyFunc, getAttrsFunc)
wc.clock = clock.NewFakeClock(time.Now()) wc.clock = clock.NewFakeClock(time.Now())
@ -69,8 +89,9 @@ func TestWatchCacheBasic(t *testing.T) {
if item, ok, _ := store.Get(pod1); !ok { if item, ok, _ := store.Get(pod1); !ok {
t.Errorf("didn't find pod") t.Errorf("didn't find pod")
} else { } else {
if !apiequality.Semantic.DeepEqual(&storeElement{Key: "prefix/ns/pod", Object: pod1}, item) { expected := makeTestStoreElement(makeTestPod("pod", 1))
t.Errorf("expected %v, got %v", pod1, item) if !apiequality.Semantic.DeepEqual(expected, item) {
t.Errorf("expected %v, got %v", expected, item)
} }
} }
pod2 := makeTestPod("pod", 2) pod2 := makeTestPod("pod", 2)
@ -80,8 +101,9 @@ func TestWatchCacheBasic(t *testing.T) {
if item, ok, _ := store.Get(pod2); !ok { if item, ok, _ := store.Get(pod2); !ok {
t.Errorf("didn't find pod") t.Errorf("didn't find pod")
} else { } else {
if !apiequality.Semantic.DeepEqual(&storeElement{Key: "prefix/ns/pod", Object: pod2}, item) { expected := makeTestStoreElement(makeTestPod("pod", 2))
t.Errorf("expected %v, got %v", pod1, item) if !apiequality.Semantic.DeepEqual(expected, item) {
t.Errorf("expected %v, got %v", expected, item)
} }
} }
pod3 := makeTestPod("pod", 3) pod3 := makeTestPod("pod", 3)
@ -97,15 +119,18 @@ func TestWatchCacheBasic(t *testing.T) {
store.Add(makeTestPod("pod2", 5)) store.Add(makeTestPod("pod2", 5))
store.Add(makeTestPod("pod3", 6)) store.Add(makeTestPod("pod3", 6))
{ {
podNames := sets.String{} expected := map[string]storeElement{
"prefix/ns/pod1": *makeTestStoreElement(makeTestPod("pod1", 4)),
"prefix/ns/pod2": *makeTestStoreElement(makeTestPod("pod2", 5)),
"prefix/ns/pod3": *makeTestStoreElement(makeTestPod("pod3", 6)),
}
items := make(map[string]storeElement, 0)
for _, item := range store.List() { for _, item := range store.List() {
podNames.Insert(item.(*storeElement).Object.(*v1.Pod).ObjectMeta.Name) elem := item.(*storeElement)
items[elem.Key] = *elem
} }
if !podNames.HasAll("pod1", "pod2", "pod3") { if !apiequality.Semantic.DeepEqual(expected, items) {
t.Errorf("missing pods, found %v", podNames) t.Errorf("expected %v, got %v", expected, items)
}
if len(podNames) != 3 {
t.Errorf("found missing/extra items")
} }
} }
@ -115,15 +140,17 @@ func TestWatchCacheBasic(t *testing.T) {
makeTestPod("pod5", 8), makeTestPod("pod5", 8),
}, "8") }, "8")
{ {
podNames := sets.String{} expected := map[string]storeElement{
"prefix/ns/pod4": *makeTestStoreElement(makeTestPod("pod4", 7)),
"prefix/ns/pod5": *makeTestStoreElement(makeTestPod("pod5", 8)),
}
items := make(map[string]storeElement)
for _, item := range store.List() { for _, item := range store.List() {
podNames.Insert(item.(*storeElement).Object.(*v1.Pod).ObjectMeta.Name) elem := item.(*storeElement)
items[elem.Key] = *elem
} }
if !podNames.HasAll("pod4", "pod5") { if !apiequality.Semantic.DeepEqual(expected, items) {
t.Errorf("missing pods, found %v", podNames) t.Errorf("expected %v, got %v", expected, items)
}
if len(podNames) != 2 {
t.Errorf("found missing/extra items")
} }
} }
} }
@ -288,8 +315,9 @@ func TestWaitUntilFreshAndGet(t *testing.T) {
if !exists { if !exists {
t.Fatalf("no results returned: %#v", obj) t.Fatalf("no results returned: %#v", obj)
} }
if !apiequality.Semantic.DeepEqual(&storeElement{Key: "prefix/ns/bar", Object: makeTestPod("bar", 5)}, obj) { expected := makeTestStoreElement(makeTestPod("bar", 5))
t.Errorf("unexpected element returned: %#v", obj) if !apiequality.Semantic.DeepEqual(expected, obj) {
t.Errorf("expected %v, got %v", expected, obj)
} }
} }