From 885c525d7604722924ce1169edfc90e66be7b0af Mon Sep 17 00:00:00 2001 From: yaqi Date: Thu, 11 Jul 2019 20:34:59 +0800 Subject: [PATCH] execute hack/update-codegen.sh, sync updates Kubernetes-commit: aa71695be1006c843de836104006a724451fa9a0 --- kubernetes/clientset.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kubernetes/clientset.go b/kubernetes/clientset.go index fb889e6d..07a3fc48 100644 --- a/kubernetes/clientset.go +++ b/kubernetes/clientset.go @@ -19,6 +19,8 @@ limitations under the License. package kubernetes import ( + "fmt" + discovery "k8s.io/client-go/discovery" admissionregistrationv1beta1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1" appsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" @@ -331,9 +333,14 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface { } // NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. func NewForConfig(c *rest.Config) (*Clientset, error) { configShallowCopy := *c if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("Burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) } var cs Clientset