Merge pull request #12975 from wojtek-t/switch_cacher_for_pods

Switch on Cacher for pods, endpoints and nodes.
This commit is contained in:
Jerzy Szczepkowski
2015-08-21 10:28:38 +02:00
10 changed files with 151 additions and 21 deletions

View File

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

View File

@@ -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",
},