Skip to content

Commit f8855da

Browse files
authored
Merge pull request #422 from fluxcd/fix-qps-burst
2 parents ed06a71 + 1410615 commit f8855da

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.17
55
require (
66
github.com/fluxcd/pkg/apis/kustomize v0.3.1
77
github.com/fluxcd/pkg/apis/meta v0.10.2
8-
github.com/fluxcd/pkg/runtime v0.12.3
8+
github.com/fluxcd/pkg/runtime v0.12.5
99
k8s.io/apiextensions-apiserver v0.23.1
1010
k8s.io/apimachinery v0.23.1
1111
sigs.k8s.io/controller-runtime v0.11.0

api/go.sum

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,13 @@ github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMi
121121
github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
122122
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
123123
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
124+
github.com/fluxcd/pkg/apis/acl v0.0.3/go.mod h1:XPts6lRJ9C9fIF9xVWofmQwftvhY25n1ps7W9xw0XLU=
124125
github.com/fluxcd/pkg/apis/kustomize v0.3.1 h1:wmb5D9e1+Rr3/5O3235ERuj+h2VKUArVfYYk68QKP+w=
125126
github.com/fluxcd/pkg/apis/kustomize v0.3.1/go.mod h1:k2HSRd68UwgNmOYBPOd6WbX6a2MH2X/Jeh7e3s3PFPc=
126127
github.com/fluxcd/pkg/apis/meta v0.10.2 h1:pnDBBEvfs4HaKiVAYgz+e/AQ8dLvcgmVfSeBroZ/KKI=
127128
github.com/fluxcd/pkg/apis/meta v0.10.2/go.mod h1:KQ2er9xa6koy7uoPMZjIjNudB5p4tXs+w0GO6fRcy7I=
128-
github.com/fluxcd/pkg/runtime v0.12.3 h1:h21AZ3YG5MAP7DxFF9hfKrP+vFzys2L7CkUbPFjbP/0=
129-
github.com/fluxcd/pkg/runtime v0.12.3/go.mod h1:imJ2xYy/d4PbSinX2IefmZk+iS2c1P5fY0js8mCE4SM=
129+
github.com/fluxcd/pkg/runtime v0.12.5 h1:/8+0UBnSHbO9DVG9IFTjc37lwofsixGbs5WpHso8n5s=
130+
github.com/fluxcd/pkg/runtime v0.12.5/go.mod h1:gspNvhAqodZgSmK1ZhMtvARBf/NGAlxmaZaIOHkJYsc=
130131
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
131132
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
132133
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=

controllers/helmrelease_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ func (r *HelmReleaseReconciler) getRESTClientGetter(ctx context.Context, hr v2.H
495495
if len(kubeConfig) == 0 {
496496
return nil, fmt.Errorf("KubeConfig secret '%s' does not contain a 'value' key", secretName)
497497
}
498-
return kube.NewMemoryRESTClientGetter(kubeConfig, hr.GetReleaseNamespace(), impersonateAccount), nil
498+
return kube.NewMemoryRESTClientGetter(kubeConfig, hr.GetReleaseNamespace(), impersonateAccount, r.Config.QPS, r.Config.Burst), nil
499499
}
500500

501501
if r.DefaultServiceAccount != "" || hr.Spec.ServiceAccountName != "" {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/fluxcd/pkg/apis/acl v0.0.3
1010
github.com/fluxcd/pkg/apis/kustomize v0.3.1
1111
github.com/fluxcd/pkg/apis/meta v0.10.2
12-
github.com/fluxcd/pkg/runtime v0.12.4
12+
github.com/fluxcd/pkg/runtime v0.12.5
1313
github.com/fluxcd/source-controller/api v0.21.1
1414
github.com/go-logr/logr v1.2.2
1515
github.com/hashicorp/go-retryablehttp v0.6.8

go.sum

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,8 @@ github.com/fluxcd/pkg/apis/kustomize v0.3.1 h1:wmb5D9e1+Rr3/5O3235ERuj+h2VKUArVf
319319
github.com/fluxcd/pkg/apis/kustomize v0.3.1/go.mod h1:k2HSRd68UwgNmOYBPOd6WbX6a2MH2X/Jeh7e3s3PFPc=
320320
github.com/fluxcd/pkg/apis/meta v0.10.2 h1:pnDBBEvfs4HaKiVAYgz+e/AQ8dLvcgmVfSeBroZ/KKI=
321321
github.com/fluxcd/pkg/apis/meta v0.10.2/go.mod h1:KQ2er9xa6koy7uoPMZjIjNudB5p4tXs+w0GO6fRcy7I=
322-
github.com/fluxcd/pkg/runtime v0.12.3/go.mod h1:imJ2xYy/d4PbSinX2IefmZk+iS2c1P5fY0js8mCE4SM=
323-
github.com/fluxcd/pkg/runtime v0.12.4 h1:gA27RG/+adN2/7Qe03PB46Iwmye/MusPCpuS4zQ2fW0=
324-
github.com/fluxcd/pkg/runtime v0.12.4/go.mod h1:gspNvhAqodZgSmK1ZhMtvARBf/NGAlxmaZaIOHkJYsc=
322+
github.com/fluxcd/pkg/runtime v0.12.5 h1:/8+0UBnSHbO9DVG9IFTjc37lwofsixGbs5WpHso8n5s=
323+
github.com/fluxcd/pkg/runtime v0.12.5/go.mod h1:gspNvhAqodZgSmK1ZhMtvARBf/NGAlxmaZaIOHkJYsc=
325324
github.com/fluxcd/source-controller/api v0.21.1 h1:7X39YQHmB1vmIBrHxU+YAqxwtdC9Zh+tdtMKREW3xiQ=
326325
github.com/fluxcd/source-controller/api v0.21.1/go.mod h1:Ab2qDmAUz6ZCp8UaHYLYzxyFrC1FQqEqjxiROb/Rdiw=
327326
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=

internal/kube/client.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ func NewInClusterRESTClientGetter(cfg *rest.Config, namespace string) genericcli
3232
flags.BearerToken = &cfg.BearerToken
3333
flags.CAFile = &cfg.CAFile
3434
flags.Namespace = &namespace
35+
flags.WithDiscoveryBurst(cfg.Burst)
36+
flags.WithDiscoveryQPS(cfg.QPS)
3537
if sa := cfg.Impersonate.UserName; sa != "" {
3638
flags.Impersonate = &sa
3739
}
@@ -45,13 +47,17 @@ type MemoryRESTClientGetter struct {
4547
kubeConfig []byte
4648
namespace string
4749
impersonateAccount string
50+
qps float32
51+
burst int
4852
}
4953

50-
func NewMemoryRESTClientGetter(kubeConfig []byte, namespace string, impersonateAccount string) genericclioptions.RESTClientGetter {
54+
func NewMemoryRESTClientGetter(kubeConfig []byte, namespace string, impersonateAccount string, qps float32, burst int) genericclioptions.RESTClientGetter {
5155
return &MemoryRESTClientGetter{
5256
kubeConfig: kubeConfig,
5357
namespace: namespace,
5458
impersonateAccount: impersonateAccount,
59+
qps: qps,
60+
burst: burst,
5561
}
5662
}
5763

@@ -76,10 +82,8 @@ func (c *MemoryRESTClientGetter) ToDiscoveryClient() (discovery.CachedDiscoveryI
7682
config.Impersonate = rest.ImpersonationConfig{UserName: c.impersonateAccount}
7783
}
7884

79-
// The more groups you have, the more discovery requests you need to make.
80-
// given 25 groups (our groups + a few custom resources) with one-ish version each, discovery needs to make 50 requests
81-
// double it just so we don't end up here again for a while. This config is only used for discovery.
82-
config.Burst = 100
85+
config.QPS = c.qps
86+
config.Burst = c.burst
8387

8488
discoveryClient, _ := discovery.NewDiscoveryClientForConfig(config)
8589
return memory.NewMemCacheClient(discoveryClient), nil

0 commit comments

Comments
 (0)