apiserver: tri-state watch cache capacity: off, default, value

This commit is contained in:
Dr. Stefan Schimanski
2017-05-05 11:21:10 +02:00
parent 1780a527f6
commit b799e62e1a
11 changed files with 68 additions and 62 deletions

View File

@@ -11,10 +11,7 @@ go_library(
name = "go_default_library",
srcs = ["cachesize.go"],
tags = ["automanaged"],
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
],
deps = ["//vendor/github.com/golang/glog:go_default_library"],
)
filegroup(

View File

@@ -23,8 +23,6 @@ import (
"strings"
"github.com/golang/glog"
"k8s.io/apiserver/pkg/registry/generic/registry"
)
type Resource string
@@ -111,11 +109,13 @@ func SetWatchCacheSizes(cacheSizes []string) {
}
}
func GetWatchCacheSizeByResource(resource string) int { // TODO this should use schema.GroupResource for lookups
// GetWatchCacheSizeByResource returns the configured watch cache size for the given resource.
// A nil value means to use a default size, zero means to disable caching.
func GetWatchCacheSizeByResource(resource string) (ret *int) { // TODO this should use schema.GroupResource for lookups
if value, found := watchCacheSizes[Resource(resource)]; found {
return value
return &value
}
return registry.DefaultWatchCacheSize
return nil
}
func maxInt(a, b int) int {

View File

@@ -40,7 +40,7 @@ func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
}
// We explicitly do NOT do any decoration here yet. // TODO determine why we do not want to cache here
opts.Decorator = generic.UndecoratedStorage // TODO use watchCacheSize=-1 to signal UndecoratedStorage
opts.Decorator = generic.UndecoratedStorage
store := &genericregistry.Store{
Copier: api.Scheme,