Merge pull request #12975 from wojtek-t/switch_cacher_for_pods
Switch on Cacher for pods, endpoints and nodes.
This commit is contained in:
@@ -57,8 +57,24 @@ type REST struct {
|
||||
}
|
||||
|
||||
// NewStorage returns a RESTStorage object that will work against pods.
|
||||
func NewStorage(s storage.Interface, k client.ConnectionInfoGetter) PodStorage {
|
||||
func NewStorage(s storage.Interface, useCacher bool, k client.ConnectionInfoGetter) PodStorage {
|
||||
prefix := "/pods"
|
||||
|
||||
storageInterface := s
|
||||
if useCacher {
|
||||
config := storage.CacherConfig{
|
||||
CacheCapacity: 1000,
|
||||
Storage: s,
|
||||
Type: &api.Pod{},
|
||||
ResourcePrefix: prefix,
|
||||
KeyFunc: func(obj runtime.Object) (string, error) {
|
||||
return storage.NamespaceKeyFunc(prefix, obj)
|
||||
},
|
||||
NewListFunc: func() runtime.Object { return &api.PodList{} },
|
||||
}
|
||||
storageInterface = storage.NewCacher(config)
|
||||
}
|
||||
|
||||
store := &etcdgeneric.Etcd{
|
||||
NewFunc: func() runtime.Object { return &api.Pod{} },
|
||||
NewListFunc: func() runtime.Object { return &api.PodList{} },
|
||||
@@ -76,7 +92,7 @@ func NewStorage(s storage.Interface, k client.ConnectionInfoGetter) PodStorage {
|
||||
},
|
||||
EndpointName: "pods",
|
||||
|
||||
Storage: s,
|
||||
Storage: storageInterface,
|
||||
}
|
||||
statusStore := *store
|
||||
|
||||
|
@@ -43,7 +43,7 @@ import (
|
||||
|
||||
func newStorage(t *testing.T) (*REST, *BindingREST, *StatusREST, *tools.FakeEtcdClient) {
|
||||
etcdStorage, fakeClient := registrytest.NewEtcdStorage(t)
|
||||
storage := NewStorage(etcdStorage, nil)
|
||||
storage := NewStorage(etcdStorage, false, nil)
|
||||
return storage.Pod, storage.Binding, storage.Status, fakeClient
|
||||
}
|
||||
|
||||
@@ -989,7 +989,8 @@ func TestEtcdWatchPodsMatch(t *testing.T) {
|
||||
|
||||
pod := &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Name: "foo",
|
||||
Namespace: "default",
|
||||
Labels: map[string]string{
|
||||
"name": "foo",
|
||||
},
|
||||
|
Reference in New Issue
Block a user