Skip to content

Conversation

@slayer321
Copy link
Contributor

What type of PR is this?

feat: add query parameter match support in ratelimit

What this PR does / why we need it:
It adds the query parameter support for ratelimit
Which issue(s) this PR fixes:

Fixes #6790

Release Notes: Yes/No

@slayer321 slayer321 requested a review from a team as a code owner October 24, 2025 12:42
@slayer321 slayer321 force-pushed the add-query-parameter-local-ratelimit branch from 1acdccd to e635afa Compare October 24, 2025 12:43
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.02%. Comparing base (c5e04ed) to head (47ab711).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/xds/translator/ratelimit.go 38.88% 9 Missing and 2 partials ⚠️
internal/gatewayapi/backendtrafficpolicy.go 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7330      +/-   ##
==========================================
+ Coverage   71.99%   72.02%   +0.03%     
==========================================
  Files         230      230              
  Lines       33379    33440      +61     
==========================================
+ Hits        24032    24086      +54     
- Misses       7596     7604       +8     
+ Partials     1751     1750       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@slayer321 slayer321 force-pushed the add-query-parameter-local-ratelimit branch 3 times, most recently from 522705d to fc46b82 Compare October 24, 2025 14:10
@slayer321 slayer321 marked this pull request as draft October 24, 2025 15:07
@slayer321 slayer321 force-pushed the add-query-parameter-local-ratelimit branch 6 times, most recently from 97b2144 to 0d91c6c Compare October 28, 2025 04:39
@slayer321 slayer321 marked this pull request as ready for review October 28, 2025 05:49
@slayer321 slayer321 force-pushed the add-query-parameter-local-ratelimit branch from 0d91c6c to ae95d00 Compare October 28, 2025 06:21
@slayer321 slayer321 force-pushed the add-query-parameter-local-ratelimit branch from ae95d00 to 47ab711 Compare October 28, 2025 08:15
@arkodg arkodg added this to the v1.6.0-rc.1 Release milestone Oct 28, 2025

// Rate limit on query parameters.
// +optional
QueryParameters *QueryParameters `json:"queryParameters,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

this should look more like []QueryParamMatch like []HeaderMatch fields
also lets use queryParams since that is what upstream uses https://gateway-api.sigs.k8s.io/reference/spec/#httproutematch

@arkodg arkodg modified the milestones: v1.6.0-rc.1 Release, Backlog Oct 29, 2025
DescriptorKey string `json:"descriptorKey,omitempty"`
//
// +kubebuilder:validation:Required
DescriptorKey string `json:"descriptorKey"`
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not exposed, but generated internally

@slayer321
Copy link
Contributor Author

Hey @arkodg, I noticed there are quite a few merge conflicts in my PR. I tried resolving them, but it’s getting a bit messy. Would it be okay if I open a new PR with my changes rebased on top of main?

// Headers is a list of request headers to match. Multiple header values are ANDed together,
// meaning, a request MUST match all the specified headers.
// At least one of headers or sourceCIDR condition must be specified.
// At least one of headers, sourceCIDR, or queryParams condition must be specified.
Copy link
Member

Choose a reason for hiding this comment

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

can we move this to the description for RateLimitSelectCondition and add CEL validation for it?

I recalled I raised simliar question once.

// Name of the query parameter.
Name string `json:"name" yaml:"name"`
// DescriptorKey is the key to use when creating the rate limit descriptor entry.
DescriptorKey string `json:"descriptorKey" yaml:"descriptorKey"`
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not needed

rlActions = append(rlActions, action)
}
}
for _, queryParam := range rule.QueryParamMatches {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldnt this look more like // HeaderMatches logic ?

}
}

for _, queryParam := range rule.QueryParamMatches {
Copy link
Contributor

Choose a reason for hiding this comment

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

shoudnt this look like header matches logic ?

}
// Case when both header and cidr match are not set and the ratelimit

// 3) Query Parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldnt this look like header matches logic ?

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.

Add query parameter match support in Local Ratelimit

3 participants