feat: add query parameter match support in ratelimit#7330
feat: add query parameter match support in ratelimit#7330cnvergence merged 14 commits intoenvoyproxy:mainfrom
Conversation
1acdccd to
e635afa
Compare
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
522705d to
fc46b82
Compare
97b2144 to
0d91c6c
Compare
ae95d00 to
47ab711
Compare
api/v1alpha1/ratelimit_types.go
Outdated
|
|
||
| // Rate limit on query parameters. | ||
| // +optional | ||
| QueryParameters *QueryParameters `json:"queryParameters,omitempty"` |
There was a problem hiding this comment.
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
api/v1alpha1/ratelimit_types.go
Outdated
| DescriptorKey string `json:"descriptorKey,omitempty"` | ||
| // | ||
| // +kubebuilder:validation:Required | ||
| DescriptorKey string `json:"descriptorKey"` |
There was a problem hiding this comment.
this is not exposed, but generated internally
|
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? |
internal/ir/xds.go
Outdated
| // 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"` |
| @@ -304,6 +304,22 @@ func buildRouteLocalRateLimits(local *ir.LocalRateLimit) ( | |||
| rlActions = append(rlActions, action) | |||
| } | |||
| } | |||
| for _, queryParam := range rule.QueryParamMatches { | |||
There was a problem hiding this comment.
shouldnt this look more like // HeaderMatches logic ?
internal/xds/translator/ratelimit.go
Outdated
| @@ -336,6 +336,18 @@ func buildRouteRateLimits(route *ir.HTTPRoute) (rateLimits []*routev3.RateLimit, | |||
| } | |||
| } | |||
|
|
|||
| for _, queryParam := range rule.QueryParamMatches { | |||
There was a problem hiding this comment.
shoudnt this look like header matches logic ?
internal/xds/translator/ratelimit.go
Outdated
| @@ -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 | |||
There was a problem hiding this comment.
shouldnt this look like header matches logic ?
|
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. |
|
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 ) |
b71cc08 to
64a302a
Compare
api/v1alpha1/ratelimit_types.go
Outdated
| // For Distinct match type, leave this empty and use the MatchType field instead. | ||
| // | ||
| // +optional | ||
| StringMatch `json:",inline"` |
There was a problem hiding this comment.
why is StringMatch used here instead of just Value
there is already MatchType being defined in the same struct
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
@zirain this logic looks a little different than headerMatches logic, is it okay ?
| descriptorKey: user | ||
| descriptorValue: user |
There was a problem hiding this comment.
why this's different with headerValueMatch?
internal/xds/translator/testdata/in/xds-ir/local-ratelimit-query-parameters.yaml
Show resolved
Hide resolved
|
@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 |
f50986a to
115804a
Compare
|
@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>
752ec28 to
5e59ae4
Compare
zirain
left a comment
There was a problem hiding this comment.
LGTM, it would be better to have a gatwayapi layer test case.
|
/retest |
Signed-off-by: Sadmi Bouhafs <sadmibouhafs@gmail.com>
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