Skip to content

⚠️ Config: Disable client-side ratelimiter by default #3119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,19 @@ var (
// If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running
// in cluster and use the cluster provided kubeconfig.
//
// The returned `*rest.Config` has client-side ratelimting disabled as we can rely on API priority and
// fairness. Set its QPS to a value equal or bigger than 0 to re-enable it.
//
// Will log an error and exit if there is an error creating the rest.Config.
GetConfigOrDie = config.GetConfigOrDie

// GetConfig creates a *rest.Config for talking to a Kubernetes apiserver.
// If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running
// in cluster and use the cluster provided kubeconfig.
//
// The returned `*rest.Config` has client-side ratelimting disabled as we can rely on API priority and
// fairness. Set its QPS to a value equal or bigger than 0 to re-enable it.
//
// Config precedence
//
// * --kubeconfig flag pointing at a file
Expand Down
16 changes: 12 additions & 4 deletions pkg/client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func RegisterFlags(fs *flag.FlagSet) {
// If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running
// in cluster and use the cluster provided kubeconfig.
//
// The returned `*rest.Config` has client-side ratelimting disabled as we can rely on API priority and
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth mentioning what the previous default configuration would have been for users who wish to restore/maintain the previous behaviour?

Copy link
Member Author

Choose a reason for hiding this comment

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

IMHO no - We never documented the previous default either and I don't know why it existed

Copy link
Member

Choose a reason for hiding this comment

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

We can mention it in release notes

Copy link
Contributor

Choose a reason for hiding this comment

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

Ack, release notes is fine by me

Copy link
Member

Choose a reason for hiding this comment

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

xref: #3123

// fairness. Set its QPS to a value equal or bigger than 0 to re-enable it.
//
// It also applies saner defaults for QPS and burst based on the Kubernetes
// controller manager defaults (20 QPS, 30 burst)
//
Expand All @@ -81,6 +84,9 @@ func GetConfig() (*rest.Config, error) {
// If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running
// in cluster and use the cluster provided kubeconfig.
//
// The returned `*rest.Config` has client-side ratelimting disabled as we can rely on API priority and
// fairness. Set its QPS to a value equal or bigger than 0 to re-enable it.
//
// It also applies saner defaults for QPS and burst based on the Kubernetes
// controller manager defaults (20 QPS, 30 burst)
//
Expand All @@ -99,10 +105,9 @@ func GetConfigWithContext(context string) (*rest.Config, error) {
return nil, err
}
if cfg.QPS == 0.0 {
cfg.QPS = 20.0
}
if cfg.Burst == 0 {
cfg.Burst = 30
// Disable client-side ratelimer by default, we can rely on
// API priority and fairness
cfg.QPS = -1
}
return cfg, nil
}
Expand Down Expand Up @@ -170,6 +175,9 @@ func loadConfigWithContext(apiServerURL string, loader clientcmd.ClientConfigLoa
// If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running
// in cluster and use the cluster provided kubeconfig.
//
// The returned `*rest.Config` has client-side ratelimting disabled as we can rely on API priority and
// fairness. Set its QPS to a value equal or bigger than 0 to re-enable it.
//
// Will log an error and exit if there is an error creating the rest.Config.
func GetConfigOrDie() *rest.Config {
config, err := GetConfig()
Expand Down
3 changes: 2 additions & 1 deletion pkg/client/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var _ = Describe("Config", func() {
cfg, err := GetConfigWithContext(tc.context)
Expect(err).NotTo(HaveOccurred())
Expect(cfg.Host).To(Equal(tc.wantHost))
Expect(cfg.QPS).To(Equal(float32(-1)))
})
}
}
Expand All @@ -82,8 +83,8 @@ var _ = Describe("Config", func() {
Expect(err).NotTo(HaveOccurred())

cfg, err := GetConfigWithContext("")
Expect(cfg).To(BeNil())
Expect(err).To(HaveOccurred())
Expect(cfg).To(BeNil())
})
})

Expand Down