Skip to content

Commit

Permalink
Merge pull request #365 from DirectXMan12/bug/sane-qps
Browse files Browse the repository at this point in the history
✨ Default QPS to a saner value in and out of tests
  • Loading branch information
k8s-ci-robot authored Mar 26, 2019
2 parents 8d94f66 + a82afb4 commit e4c40bc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func init() {
// If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running
// in cluster and use the cluster provided kubeconfig.
//
// It also applies saner defaults for QPS and burst based on the Kubernetes
// controller manager defaults (20 QPS, 30 burst)
//
// Config precedence
//
// * --kubeconfig flag pointing at a file
Expand All @@ -58,6 +61,21 @@ func init() {
//
// * $HOME/.kube/config if exists
func GetConfig() (*rest.Config, error) {
cfg, err := loadConfig()
if err != nil {
return nil, err
}

if cfg.QPS == 0.0 {
cfg.QPS = 20.0
cfg.Burst = 30.0
}

return cfg, nil
}

// loadConfig loads a REST Config as per the rules specified in GetConfig
func loadConfig() (*rest.Config, error) {
// If a flag is specified with the config location, use that
if len(kubeconfig) > 0 {
return clientcmd.BuildConfigFromFlags(apiServerURL, kubeconfig)
Expand Down
3 changes: 3 additions & 0 deletions pkg/envtest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func (te *Environment) Start() (*rest.Config, error) {
// Create the *rest.Config for creating new clients
te.Config = &rest.Config{
Host: te.ControlPlane.APIURL().Host,
// gotta go fast during tests -- we don't really care about overwhelming our test API server
QPS: 1000.0,
Burst: 2000.0,
}
}

Expand Down

0 comments on commit e4c40bc

Please sign in to comment.