Skip to content

Commit e4c40bc

Browse files
authored
Merge pull request #365 from DirectXMan12/bug/sane-qps
✨ Default QPS to a saner value in and out of tests
2 parents 8d94f66 + a82afb4 commit e4c40bc

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

pkg/client/config/config.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ func init() {
4848
// If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running
4949
// in cluster and use the cluster provided kubeconfig.
5050
//
51+
// It also applies saner defaults for QPS and burst based on the Kubernetes
52+
// controller manager defaults (20 QPS, 30 burst)
53+
//
5154
// Config precedence
5255
//
5356
// * --kubeconfig flag pointing at a file
@@ -58,6 +61,21 @@ func init() {
5861
//
5962
// * $HOME/.kube/config if exists
6063
func GetConfig() (*rest.Config, error) {
64+
cfg, err := loadConfig()
65+
if err != nil {
66+
return nil, err
67+
}
68+
69+
if cfg.QPS == 0.0 {
70+
cfg.QPS = 20.0
71+
cfg.Burst = 30.0
72+
}
73+
74+
return cfg, nil
75+
}
76+
77+
// loadConfig loads a REST Config as per the rules specified in GetConfig
78+
func loadConfig() (*rest.Config, error) {
6179
// If a flag is specified with the config location, use that
6280
if len(kubeconfig) > 0 {
6381
return clientcmd.BuildConfigFromFlags(apiServerURL, kubeconfig)

pkg/envtest/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ func (te *Environment) Start() (*rest.Config, error) {
169169
// Create the *rest.Config for creating new clients
170170
te.Config = &rest.Config{
171171
Host: te.ControlPlane.APIURL().Host,
172+
// gotta go fast during tests -- we don't really care about overwhelming our test API server
173+
QPS: 1000.0,
174+
Burst: 2000.0,
172175
}
173176
}
174177

0 commit comments

Comments
 (0)