Skip to content

feat: add query parameter match support in ratelimit#7330

Merged
cnvergence merged 14 commits intoenvoyproxy:mainfrom
slayer321:add-query-parameter-local-ratelimit
Jan 29, 2026
Merged

feat: add query parameter match support in ratelimit#7330
cnvergence merged 14 commits intoenvoyproxy:mainfrom
slayer321:add-query-parameter-local-ratelimit

Conversation

@slayer321
Copy link
Copy Markdown
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
Copy Markdown

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 74.04580% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.67%. Comparing base (c9e3d5f) to head (1639b7c).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/xds/translator/ratelimit.go 68.75% 10 Missing and 5 partials ⚠️
internal/xds/translator/local_ratelimit.go 70.73% 10 Missing and 2 partials ⚠️
internal/gatewayapi/backendtrafficpolicy.go 82.92% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7330      +/-   ##
==========================================
+ Coverage   73.65%   73.67%   +0.01%     
==========================================
  Files         239      239              
  Lines       36311    36439     +128     
==========================================
+ Hits        26745    26845     +100     
- Misses       7671     7692      +21     
- Partials     1895     1902       +7     

☔ 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 2 times, most recently 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

// 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
Copy Markdown
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

@@ -304,6 +304,22 @@ func buildRouteLocalRateLimits(local *ir.LocalRateLimit) (
rlActions = append(rlActions, action)
}
}
for _, queryParam := range rule.QueryParamMatches {
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.

shouldnt this look more like // HeaderMatches logic ?

@@ -336,6 +336,18 @@ func buildRouteRateLimits(route *ir.HTTPRoute) (rateLimits []*routev3.RateLimit,
}
}

for _, queryParam := range rule.QueryParamMatches {
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.

shoudnt this look like header matches logic ?

@@ -682,9 +695,26 @@ func buildRateLimitServiceDescriptors(route *ir.HTTPRoute) []*rlsconfv3.RateLimi
cur = pbDesc
}
}
// Case when both header and cidr match are not set and the ratelimit

// 3) Query Parameters
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.

shouldnt this look like header matches logic ?

@slayer321
Copy link
Copy Markdown
Contributor Author

Hey @arkodg , I see there are some new review comment . I had this query #7330 (comment)

can i do this ? .. Create a new PR and close this one. Will incorporate all the changes that you have mentioned in the new PR.

@arkodg
Copy link
Copy Markdown
Contributor

arkodg commented Nov 24, 2025

Hey can you please use this PR to keep all the conversations in one place and to reduce reviewer burden ( to review incremental diff vs entire diff )

@slayer321 slayer321 force-pushed the add-query-parameter-local-ratelimit branch from b71cc08 to 64a302a Compare November 28, 2025 06:59
zirain
zirain previously approved these changes Jan 21, 2026
// For Distinct match type, leave this empty and use the MatchType field instead.
//
// +optional
StringMatch `json:",inline"`
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.

why is StringMatch used here instead of just Value

there is already MatchType being defined in the same struct

Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing Jan 26, 2026

Choose a reason for hiding this comment

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

Hi @slayer321 please go ahead and use a simple Value string here.
My previous comment https://github.com/envoyproxy/gateway/pull/7330/changes#r2644961055 can be ignored.

}
}

// 5) Query Parameters
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.

@zirain this logic looks a little different than headerMatches logic, is it okay ?

Comment on lines +47 to +48
descriptorKey: user
descriptorValue: user
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.

why this's different with headerValueMatch?

@arkodg
Copy link
Copy Markdown
Contributor

arkodg commented Jan 28, 2026

@slayer321 we are trying to release rc in the next 2 days, can you address the newer comments soon so we can try and get this in

@slayer321 slayer321 force-pushed the add-query-parameter-local-ratelimit branch from f50986a to 115804a Compare January 28, 2026 11:53
@slayer321
Copy link
Copy Markdown
Contributor Author

@arkodg I have addressed the review comments.. can you please take a look

Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
… embedded struct

Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
…yParameterValueMatch

Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
Signed-off-by: sachin maurya <sachin.maurya7666@gmail.com>
@zirain zirain force-pushed the add-query-parameter-local-ratelimit branch from 752ec28 to 5e59ae4 Compare January 29, 2026 07:34
Copy link
Copy Markdown
Member

@zirain zirain left a comment

Choose a reason for hiding this comment

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

LGTM, it would be better to have a gatwayapi layer test case.

Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing left a comment

Choose a reason for hiding this comment

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

LGTM thanks!

@cnvergence
Copy link
Copy Markdown
Member

/retest

@cnvergence cnvergence merged commit b328011 into envoyproxy:main Jan 29, 2026
60 of 62 checks passed
SadmiB pushed a commit to SadmiB/gateway that referenced this pull request Jan 30, 2026
Signed-off-by: Sadmi Bouhafs <sadmibouhafs@gmail.com>
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

6 participants