Skip to content

Commit

Permalink
Merge pull request #6159 from linxiulei/managedFields
Browse files Browse the repository at this point in the history
Trim managedFields in shared informer factory
  • Loading branch information
k8s-ci-robot authored Sep 29, 2023
2 parents d3467cf + 74d1f7f commit 8166f5e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (

"github.com/spf13/pflag"

"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/server/mux"
"k8s.io/apiserver/pkg/server/routes"
Expand Down Expand Up @@ -444,7 +445,15 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter
kubeClientConfig.Burst = autoscalingOptions.KubeClientBurst
kubeClientConfig.QPS = float32(autoscalingOptions.KubeClientQPS)
kubeClient := createKubeClient(kubeClientConfig)
informerFactory := informers.NewSharedInformerFactory(kubeClient, 0)

// Informer transform to trim ManagedFields for memory efficiency.
trim := func(obj interface{}) (interface{}, error) {
if accessor, err := meta.Accessor(obj); err == nil {
accessor.SetManagedFields(nil)
}
return obj, nil
}
informerFactory := informers.NewSharedInformerFactoryWithOptions(kubeClient, 0, informers.WithTransform(trim))

eventsKubeClient := createKubeClient(getKubeConfig())

Expand Down

0 comments on commit 8166f5e

Please sign in to comment.