Skip to content

Conversation

@grzesuav
Copy link

@grzesuav grzesuav commented Oct 19, 2025

fixes ##996

What does this PR do?

  • Adds new functionality
  • Alters existing functionality
  • Fixes a bug
  • Improves documentation or testing

Please briefly describe your changes as well as the motivation behind them:

  • Adds posibility to override default client-go QPS and Burst, both in controller code and helm chart

Code Quality Checklist

  • The documentation is up to date.
  • My code is sufficiently commented and passes continuous integration checks.
  • I have signed my commit (see Contributing Docs).

Testing

  • I leveraged continuous integration testing
    • by depending on existing unit tests or end-to-end tests.
    • by adding new unit tests or end-to-end tests.
  • I manually tested the following steps:
    • x
    • locally.
    • as a canary deployment to a cluster.

@grzesuav grzesuav requested a review from a team as a code owner October 19, 2025 20:17
//go:generate mockery --config .vendor.mockery.yaml

var scheme = runtime.NewScheme()
var (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These client-go rate limiting flags should be moved to the configuration system in config/config.go for consistency. Yhey're defined separately in main.go but
should follow the same pattern as other controller settings - being part of the controllerConfig struct with viper binding support for config files and ConfigMap
overrides.

  1. Add to controllerConfig struct (config/config.go:34-60):
  type controllerConfig struct {
        HealthProbeBindAddr              string                          `json:"healthProbeBindAddr" yaml:"healthProbeBindAddr"`
        MetricsBindAddr                  string                          `json:"metricsBindAddr" yaml:"metricsBindAddr"`
        MetricsSink                      string                          `json:"metricsSink" yaml:"metricsSink"`
        // Add these two fields:
        ClientGoQPS                      float64                         `json:"clientGoQps" yaml:"clientGoQps"`
        ClientGoBurst                    int                             `json:"clientGoBurst" yaml:"clientGoBurst"`
        ExpiredDisruptionGCDelay         time.Duration                   `json:"expiredDisruptionGCDelay" yaml:"expiredDisruptionGCDelay"`
        // ... rest of fields
  }
  1. Add flag binding in New() function (similar to existing patterns around line 139):
  mainFS.Float64Var(&cfg.Controller.ClientGoQPS, "client-go-qps", 20, "Number of queries per second client-go is allowed to make (default 20)")

  if err := viper.BindPFlag("controller.clientGoQps", mainFS.Lookup("client-go-qps")); err != nil {
        return cfg, err
  }

  mainFS.IntVar(&cfg.Controller.ClientGoBurst, "client-go-burst", 30, "Allowed burst queries for client-go (default 30)")

  if err := viper.BindPFlag("controller.clientGoBurst", mainFS.Lookup("client-go-burst")); err != nil {
        return cfg, err
  }
  1. Remove from main.go and use config values:
  // Remove from main.go:
  // clientGoQPS   = flag.Float64("client-go-qps", 20, "...")
  // clientGoBurst = flag.Int("client-go-burst", 30, "...")

  // Use in client initialization:
  // *clientGoQPS -> cfg.Controller.ClientGoQPS
  // *clientGoBurst -> cfg.Controller.ClientGoBurst

This way, these settings can be configured via YAML files, ConfigMaps, and environment variables just like all other controller settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants