Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Fix discovery rate limits #112

Merged
merged 3 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cmd/gardener-resource-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: We have seen issues with event reporting for Lease objects now that GRM uses configmapsleases as default leader election resource lock. We decided that we can simply add all Kubernetes APIs to our source scheme here.

utilruntime.Must(resourcesv1alpha1.AddToScheme(scheme))
return scheme
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/cmd/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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{
Expand Down Expand Up @@ -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
)
}

Expand Down