Skip to content

Disabling client-go rate-limiting if AP&F is enabled - #8757

Merged
cert-manager-prow[bot] merged 2 commits into
cert-manager:masterfrom
hjoshi123:feat/disable-client-go-qps
May 15, 2026
Merged

cert-manager-prow[bot] merged 2 commits into
cert-manager:masterfrom
hjoshi123:feat/disable-client-go-qps

Conversation

@hjoshi123

Copy link
Copy Markdown
Collaborator

Pull Request Motivation

This PR aims to disable client side QPS and bursting if server side AP&F is enabled. AP&F or API Priority and Fairness handles server side overloading logic and is enabled by default since v1.20 and is v1 since v1.29. Here's more on this. The way we do this is we hit the server's ping endpoint and check if the flow control header is returned. If it's returned then we know its enabled (we don't care about the value of it).

This PR also takes care of setting QPS to -1 through controller config which was previously disabled because of validation logic.

Fixes #6890

Kind

/kind feature

Release Note

disabled client side rate-limiting if AP&F is enabled.

@cert-manager-prow cert-manager-prow Bot added kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 28, 2026
@hjoshi123
hjoshi123 force-pushed the feat/disable-client-go-qps branch from 8c32537 to 89865e3 Compare April 28, 2026 15:28
@erikgb
erikgb requested a review from Copilot April 30, 2026 21:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates cert-manager’s controller startup to detect whether Kubernetes API Priority & Fairness (AP&F) is enabled and, when it is, disable client-side QPS/burst rate limiting; it also loosens controller config validation to permit disabling rate limiting via -1.

Changes:

  • Add an AP&F detection probe (HEAD /livez/ping) and set rest.Config{QPS,Burst} = -1 when AP&F is detected.
  • Add unit tests for AP&F detection behavior.
  • Update controller configuration validation to allow kubernetesAPIQPS/kubernetesAPIBurst values down to -1.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.

File Description
pkg/controller/context.go Adds AP&F detection and conditionally disables client-side rate limiting; introduces helper functions for probing.
pkg/controller/context_test.go Adds tests covering AP&F detection scenarios and an invalid-host case.
internal/apis/config/controller/validation/validation.go Adjusts validation logic to allow -1 for QPS/burst.
internal/apis/config/controller/validation/validation_test.go Updates validation tests to reflect the new validation behavior/messages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/controller/context.go Resolved
Comment thread pkg/controller/context.go Resolved
Comment thread pkg/controller/context.go Resolved
Comment thread pkg/controller/context.go Resolved
Comment thread pkg/controller/context.go Resolved
Comment thread pkg/controller/context_test.go Resolved
@hjoshi123
hjoshi123 force-pushed the feat/disable-client-go-qps branch from 89865e3 to 9027060 Compare May 1, 2026 04:27
@hjoshi123

Copy link
Copy Markdown
Collaborator Author

/test pull-cert-manager-master-make-verify

@hjoshi123
hjoshi123 force-pushed the feat/disable-client-go-qps branch from 9027060 to 2d160a2 Compare May 1, 2026 13:55
@hjoshi123

Copy link
Copy Markdown
Collaborator Author

/test pull-cert-manager-master-make-verify

@hjoshi123
hjoshi123 requested a review from erikgb May 4, 2026 02:07

@SgtCoDFish SgtCoDFish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(Minor comments)

@hjoshi123
hjoshi123 force-pushed the feat/disable-client-go-qps branch from 2d160a2 to 8cd2ed9 Compare May 8, 2026 16:03
@hjoshi123
hjoshi123 requested a review from SgtCoDFish May 8, 2026 16:04
@erikgb
erikgb requested a review from Copilot May 14, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

internal/apis/config/controller/validation/validation.go:58

  • The validation change now explicitly allows kubernetesAPIQPS/kubernetesAPIBurst to be -1 (disable client-side rate limiting), but validation_test.go only covers values less than -1 being rejected. Please add a positive test case asserting that QPS=-1 and Burst=-1 is accepted (no validation errors), so this new supported configuration is exercised.
	if cfg.KubernetesAPIBurst < -1 {
		allErrors = append(allErrors, field.Invalid(fldPath.Child("kubernetesAPIBurst"), cfg.KubernetesAPIBurst, "must be greater than or equal to -1"))
	}

	if cfg.KubernetesAPIQPS < -1 {
		allErrors = append(allErrors, field.Invalid(fldPath.Child("kubernetesAPIQPS"), cfg.KubernetesAPIQPS, "must be greater than or equal to -1"))
	}

	if float32(cfg.KubernetesAPIBurst) < cfg.KubernetesAPIQPS {
		allErrors = append(allErrors, field.Invalid(fldPath.Child("kubernetesAPIBurst"), cfg.KubernetesAPIBurst, "must be higher or equal to kubernetesAPIQPS"))
	}

Comment thread pkg/controller/context.go Resolved
Comment thread pkg/controller/context.go Resolved
Comment thread pkg/controller/context.go Resolved
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Signed-off-by: Hemant Joshi <[email protected]>
@hjoshi123

Copy link
Copy Markdown
Collaborator Author

/label tide/merge-method-squash