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

Commit

Permalink
Merge pull request #116 from rfranzke/release-v0.21-cherry-pick-112
Browse files Browse the repository at this point in the history
[release-v0.21] Cherry-pick of #112: Fix discovery rate limits
  • Loading branch information
timebertt authored Feb 18, 2021
2 parents 860ab80 + 366cd37 commit 26c114a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
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))
utilruntime.Must(resourcesv1alpha1.AddToScheme(scheme))
return scheme
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/cmd/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,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 Down Expand Up @@ -146,7 +150,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 All @@ -169,9 +173,6 @@ func getTargetRESTConfig(kubeconfigPath string) (*rest.Config, error) {
}

func newCachedClient(cache cache.Cache, config rest.Config, options client.Options) (client.Client, error) {
config.QPS = 100.0
config.Burst = 130

// Create the Client for Write operations.
c, err := client.New(&config, options)
if err != nil {
Expand Down

0 comments on commit 26c114a

Please sign in to comment.