From 534427f5d3134189f49e6811a7642b86cf92c55a Mon Sep 17 00:00:00 2001 From: Alper Rifat Ulucinar Date: Wed, 30 Mar 2022 11:19:41 +0300 Subject: [PATCH 1/2] Bump default burst limit for discovery client to 300 Signed-off-by: Alper Rifat Ulucinar --- .../src/k8s.io/client-go/discovery/discovery_client.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/client-go/discovery/discovery_client.go b/staging/src/k8s.io/client-go/discovery/discovery_client.go index baf87884621..a123aa737ea 100644 --- a/staging/src/k8s.io/client-go/discovery/discovery_client.go +++ b/staging/src/k8s.io/client-go/discovery/discovery_client.go @@ -52,6 +52,9 @@ const ( // defaultTimeout is the maximum amount of time per request when no timeout has been set on a RESTClient. // Defaults to 32s in order to have a distinguishable length of time, relative to other timeouts that exist. defaultTimeout = 32 * time.Second + + // defaultBurst is the default burst to be used with the discovery client's token bucket rate limiter + defaultBurst = 300 ) // DiscoveryInterface holds the methods that discover server-supported API groups, @@ -456,12 +459,14 @@ func setDiscoveryDefaults(config *restclient.Config) error { if config.Timeout == 0 { config.Timeout = defaultTimeout } - if config.Burst == 0 && config.QPS < 100 { + // if a burst limit is not already configured and + // an avg. rate of `defaultBurst` qps is not already configured + if config.Burst == 0 && config.QPS < defaultBurst { // discovery is expected to be bursty, increase the default burst // to accommodate looking up resource info for many API groups. // matches burst set by ConfigFlags#ToDiscoveryClient(). // see https://issue.k8s.io/86149 - config.Burst = 100 + config.Burst = defaultBurst } codec := runtime.NoopEncoder{Decoder: scheme.Codecs.UniversalDecoder()} config.NegotiatedSerializer = serializer.NegotiatedSerializerWrapper(runtime.SerializerInfo{Serializer: codec}) From 45f653e3db6a120d7cafaf2a9262fb3c8a2e22a2 Mon Sep 17 00:00:00 2001 From: Alper Rifat Ulucinar Date: Thu, 14 Jul 2022 09:58:55 +0300 Subject: [PATCH 2/2] Bump discovery burst of default ConfigFlags to 300 Signed-off-by: Alper Rifat Ulucinar --- .../cli-runtime/pkg/genericclioptions/config_flags.go | 6 +++--- staging/src/k8s.io/client-go/discovery/discovery_client.go | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/config_flags.go b/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/config_flags.go index 0d604b9c2fb..19a9c711e85 100644 --- a/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/config_flags.go +++ b/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/config_flags.go @@ -437,9 +437,9 @@ func NewConfigFlags(usePersistentConfig bool) *ConfigFlags { usePersistentConfig: usePersistentConfig, // The more groups you have, the more discovery requests you need to make. - // given 25 groups (our groups + a few custom resources) with one-ish version each, discovery needs to make 50 requests - // double it just so we don't end up here again for a while. This config is only used for discovery. - discoveryBurst: 100, + // with a burst of 300, we will not be rate-limiting for most clusters but + // the safeguard will still be here. This config is only used for discovery. + discoveryBurst: 300, } } diff --git a/staging/src/k8s.io/client-go/discovery/discovery_client.go b/staging/src/k8s.io/client-go/discovery/discovery_client.go index a123aa737ea..ec7ebf05105 100644 --- a/staging/src/k8s.io/client-go/discovery/discovery_client.go +++ b/staging/src/k8s.io/client-go/discovery/discovery_client.go @@ -459,9 +459,8 @@ func setDiscoveryDefaults(config *restclient.Config) error { if config.Timeout == 0 { config.Timeout = defaultTimeout } - // if a burst limit is not already configured and - // an avg. rate of `defaultBurst` qps is not already configured - if config.Burst == 0 && config.QPS < defaultBurst { + // if a burst limit is not already configured + if config.Burst == 0 { // discovery is expected to be bursty, increase the default burst // to accommodate looking up resource info for many API groups. // matches burst set by ConfigFlags#ToDiscoveryClient().