Skip to content

Commit

Permalink
Use caching when getting controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
jbartosik committed Oct 8, 2020
1 parent 0f669ca commit 8711a1e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ import (
resourceclient "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1"
)

const defaultResyncPeriod time.Duration = 10 * time.Minute
const (
betweenContainerParentRefreshes time.Duration = 10 * time.Minute
containerCacheCleanupLoopPeriod time.Duration = time.Hour
containerCacheRefreshLoopPeriod time.Duration = time.Minute
containerParentRefreshCacheLifetime time.Duration = time.Hour
containerParentRefreshJitter time.Duration = time.Minute
defaultResyncPeriod time.Duration = 10 * time.Minute
)

// ClusterStateFeeder can update state of ClusterState object.
type ClusterStateFeeder interface {
Expand Down Expand Up @@ -109,7 +116,10 @@ func NewClusterStateFeeder(config *rest.Config, clusterState *model.ClusterState
podLister, oomObserver := NewPodListerAndOOMObserver(kubeClient, namespace)
factory := informers.NewSharedInformerFactoryWithOptions(kubeClient, defaultResyncPeriod, informers.WithNamespace(namespace))
dirtectControllerParentGetter := controllerfetcher.NewDirectControllerParentGetter(config, kubeClient, factory)
controllerFetcher := controllerfetcher.NewControllerFetcher(dirtectControllerParentGetter)
cachingControllerParentGetter := controllerfetcher.NewCachingControllerGetter(betweenContainerParentRefreshes, containerParentRefreshJitter, containerParentRefreshCacheLifetime, dirtectControllerParentGetter)
cachingControllerParentGetter.Start(context.TODO(), containerCacheCleanupLoopPeriod, containerCacheRefreshLoopPeriod)
controllerFetcher := controllerfetcher.NewControllerFetcher(cachingControllerParentGetter)

return ClusterStateFeederFactory{
PodLister: podLister,
OOMObserver: oomObserver,
Expand Down

0 comments on commit 8711a1e

Please sign in to comment.