Merge pull request #79077 from yuyulei/remove-ratelimiter

add "burst" validation check to code-generator

Kubernetes-commit: c302da4f429f80b9857261bedc17a62069e5b09e
This commit is contained in:
Kubernetes Publisher
2019-07-11 17:01:20 -07:00

View File

@@ -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