From e72de7f6a9f3fd78414620b8c443756c97784693 Mon Sep 17 00:00:00 2001 From: Tim Ebert Date: Thu, 18 Feb 2021 09:10:41 +0100 Subject: [PATCH 1/3] Fix discovery rate limits --- pkg/cmd/target.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/target.go b/pkg/cmd/target.go index 99d0a938..f56e750e 100644 --- a/pkg/cmd/target.go +++ b/pkg/cmd/target.go @@ -79,6 +79,10 @@ func (o *TargetClientOptions) Complete() error { return fmt.Errorf("unable to create REST config for target cluster: %w", err) } + // TODO: make this configurable + restConfig.QPS = 100.0 + restConfig.Burst = 130 + restMapper, err := getTargetRESTMapper(restConfig) if err != nil { return fmt.Errorf("unable to create REST mapper for target cluster: %w", err) @@ -91,10 +95,6 @@ func (o *TargetClientOptions) Complete() error { targetClient client.Client ) - // TODO: make this configurable - restConfig.QPS = 100.0 - restConfig.Burst = 130 - if o.disableCache { // create direct client for target cluster targetClient, err = client.New(restConfig, client.Options{ @@ -157,7 +157,7 @@ func getTargetRESTMapper(config *rest.Config) (meta.RESTMapper, error) { return apiutil.NewDynamicRESTMapper( config, apiutil.WithLazyDiscovery, - apiutil.WithLimiter(rate.NewLimiter(rate.Every(10*time.Second), 1)), // rediscover at maximum every 10s + apiutil.WithLimiter(rate.NewLimiter(rate.Every(1*time.Minute), 1)), // rediscover at maximum every minute ) } From bc95e47609c35a336286c2a1ff3b5bcfc1e330fd Mon Sep 17 00:00:00 2001 From: Tim Ebert Date: Thu, 18 Feb 2021 09:13:24 +0100 Subject: [PATCH 2/3] Add entire k8s scheme --- pkg/cmd/source.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/source.go b/pkg/cmd/source.go index 523e4bdd..720599ee 100644 --- a/pkg/cmd/source.go +++ b/pkg/cmd/source.go @@ -19,10 +19,10 @@ import ( "time" "github.com/spf13/pflag" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/client-go/kubernetes" + kubernetesscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "sigs.k8s.io/controller-runtime/pkg/client/config" @@ -90,7 +90,7 @@ func (o *SourceClientOptions) Completed() *SourceClientConfig { func getSourceScheme() *runtime.Scheme { scheme := runtime.NewScheme() - utilruntime.Must(corev1.AddToScheme(scheme)) + utilruntime.Must(kubernetesscheme.AddToScheme(scheme)) utilruntime.Must(resourcesv1alpha1.AddToScheme(scheme)) return scheme } From 54a459700132a0818c2c847c6ea942ef953ba39c Mon Sep 17 00:00:00 2001 From: Tim Ebert Date: Thu, 18 Feb 2021 09:14:46 +0100 Subject: [PATCH 3/3] Dedup API server warnings --- cmd/gardener-resource-manager/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/gardener-resource-manager/main.go b/cmd/gardener-resource-manager/main.go index 23a90fa3..ab86f13a 100644 --- a/cmd/gardener-resource-manager/main.go +++ b/cmd/gardener-resource-manager/main.go @@ -17,6 +17,8 @@ package main import ( "os" + "k8s.io/client-go/rest" + "github.com/gardener/gardener-resource-manager/cmd/gardener-resource-manager/app" "github.com/gardener/gardener-resource-manager/pkg/log" @@ -25,6 +27,13 @@ import ( ) func main() { + rest.SetDefaultWarningHandler( + rest.NewWarningWriter(os.Stderr, rest.WarningWriterOptions{ + // only print a given warning the first time we receive it + Deduplicate: true, + }), + ) + runtimelog.SetLogger(log.ZapLogger(false)) ctx := signals.SetupSignalHandler()