mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	use cache size to signal undecorated storage
This commit is contained in:
		@@ -39,6 +39,7 @@ func NewHeuristicWatchCacheSizes(expectedRAMCapacityMB int) map[schema.GroupReso
 | 
			
		||||
	watchCacheSizes[schema.GroupResource{Resource: "nodes"}] = maxInt(5*clusterSize, 1000)
 | 
			
		||||
	watchCacheSizes[schema.GroupResource{Resource: "pods"}] = maxInt(50*clusterSize, 1000)
 | 
			
		||||
	watchCacheSizes[schema.GroupResource{Resource: "services"}] = maxInt(5*clusterSize, 1000)
 | 
			
		||||
	watchCacheSizes[schema.GroupResource{Resource: "events"}] = 0
 | 
			
		||||
	watchCacheSizes[schema.GroupResource{Resource: "apiservices", Group: "apiregistration.k8s.io"}] = maxInt(5*clusterSize, 1000)
 | 
			
		||||
	return watchCacheSizes
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -40,10 +40,6 @@ func NewREST(optsGetter generic.RESTOptionsGetter, ttl uint64) *REST {
 | 
			
		||||
		panic(err) // TODO: Propagate error up
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// We explicitly do NOT do any decoration here - switching on Cacher
 | 
			
		||||
	// for events will lead to too high memory consumption.
 | 
			
		||||
	opts.Decorator = generic.UndecoratedStorage // TODO use watchCacheSize=-1 to signal UndecoratedStorage
 | 
			
		||||
 | 
			
		||||
	store := &genericregistry.Store{
 | 
			
		||||
		NewFunc:       func() runtime.Object { return &api.Event{} },
 | 
			
		||||
		NewListFunc:   func() runtime.Object { return &api.EventList{} },
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,7 @@ func StorageWithCacher(capacity int) generic.StorageDecorator {
 | 
			
		||||
		triggerFunc storage.TriggerPublisherFunc) (storage.Interface, factory.DestroyFunc) {
 | 
			
		||||
 | 
			
		||||
		s, d := generic.NewRawStorage(storageConfig)
 | 
			
		||||
		if capacity == 0 {
 | 
			
		||||
		if capacity <= 0 {
 | 
			
		||||
			klog.V(5).Infof("Storage caching is disabled for %T", objectType)
 | 
			
		||||
			return s, d
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -229,6 +229,7 @@ func (f *SimpleRestOptionsFactory) GetRESTOptions(resource schema.GroupResource)
 | 
			
		||||
		if !ok {
 | 
			
		||||
			cacheSize = f.Options.DefaultWatchCacheSize
 | 
			
		||||
		}
 | 
			
		||||
		// depending on cache size this might return an undecorated storage
 | 
			
		||||
		ret.Decorator = genericregistry.StorageWithCacher(cacheSize)
 | 
			
		||||
	}
 | 
			
		||||
	return ret, nil
 | 
			
		||||
@@ -262,6 +263,7 @@ func (f *StorageFactoryRestOptionsFactory) GetRESTOptions(resource schema.GroupR
 | 
			
		||||
		if !ok {
 | 
			
		||||
			cacheSize = f.Options.DefaultWatchCacheSize
 | 
			
		||||
		}
 | 
			
		||||
		// depending on cache size this might return an undecorated storage
 | 
			
		||||
		ret.Decorator = genericregistry.StorageWithCacher(cacheSize)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -285,7 +287,6 @@ func ParseWatchCacheSizes(cacheSizes []string) (map[schema.GroupResource]int, er
 | 
			
		||||
		if size < 0 {
 | 
			
		||||
			return nil, fmt.Errorf("watch cache size cannot be negative: %s", c)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		watchCacheSizes[schema.ParseGroupResource(tokens[0])] = size
 | 
			
		||||
	}
 | 
			
		||||
	return watchCacheSizes, nil
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user