Skip to content

Commit be26462

Browse files
authored
feat(cluster_resources): increase default client burst and qps (#920)
* feat(collect): add client burst and qps
1 parent 13534bf commit be26462

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

pkg/constants/constants.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package constants
2+
3+
const (
4+
// DEFAULT_CLIENT_QPS indicates the maximum QPS from troubleshoot client.
5+
DEFAULT_CLIENT_QPS = 100
6+
// DEFAULT_CLIENT_QPS is maximum burst for throttle.
7+
DEFAULT_CLIENT_BURST = 100
8+
// DEFAULT_CLIENT_USER_AGENT is an field that specifies the caller of troubleshoot request.
9+
DEFAULT_CLIENT_USER_AGENT = "ReplicatedTroubleshoot"
10+
)

pkg/preflight/collect.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
analyze "github.com/replicatedhq/troubleshoot/pkg/analyze"
1212
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
1313
"github.com/replicatedhq/troubleshoot/pkg/collect"
14+
"github.com/replicatedhq/troubleshoot/pkg/constants"
15+
"github.com/replicatedhq/troubleshoot/pkg/version"
1416
"k8s.io/client-go/kubernetes"
1517
"k8s.io/client-go/rest"
1618
)
@@ -131,6 +133,10 @@ func Collect(opts CollectOpts, p *troubleshootv1beta2.Preflight) (CollectResult,
131133
collectSpecs = collect.EnsureCollectorInList(collectSpecs, troubleshootv1beta2.Collect{ClusterResources: &troubleshootv1beta2.ClusterResources{}})
132134
collectSpecs = collect.EnsureClusterResourcesFirst(collectSpecs)
133135

136+
opts.KubernetesRestConfig.QPS = constants.DEFAULT_CLIENT_QPS
137+
opts.KubernetesRestConfig.Burst = constants.DEFAULT_CLIENT_BURST
138+
opts.KubernetesRestConfig.UserAgent = fmt.Sprintf("%s/%s", constants.DEFAULT_CLIENT_USER_AGENT, version.Version())
139+
134140
k8sClient, err := kubernetes.NewForConfig(opts.KubernetesRestConfig)
135141
if err != nil {
136142
return nil, errors.Wrap(err, "failed to instantiate Kubernetes client")

pkg/supportbundle/collect.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
analyze "github.com/replicatedhq/troubleshoot/pkg/analyze"
1414
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
1515
"github.com/replicatedhq/troubleshoot/pkg/collect"
16+
"github.com/replicatedhq/troubleshoot/pkg/constants"
1617
"github.com/replicatedhq/troubleshoot/pkg/convert"
1718
"github.com/replicatedhq/troubleshoot/pkg/version"
1819
"gopkg.in/yaml.v2"
@@ -77,6 +78,10 @@ func runCollectors(collectors []*troubleshootv1beta2.Collect, additionalRedactor
7778
collectSpecs = collect.EnsureCollectorInList(collectSpecs, troubleshootv1beta2.Collect{ClusterResources: &troubleshootv1beta2.ClusterResources{}})
7879
collectSpecs = collect.EnsureClusterResourcesFirst(collectSpecs)
7980

81+
opts.KubernetesRestConfig.QPS = constants.DEFAULT_CLIENT_QPS
82+
opts.KubernetesRestConfig.Burst = constants.DEFAULT_CLIENT_BURST
83+
opts.KubernetesRestConfig.UserAgent = fmt.Sprintf("%s/%s", constants.DEFAULT_CLIENT_USER_AGENT, version.Version())
84+
8085
k8sClient, err := kubernetes.NewForConfig(opts.KubernetesRestConfig)
8186
if err != nil {
8287
return nil, errors.Wrap(err, "failed to instantiate Kubernetes client")

0 commit comments

Comments
 (0)