forked from envoyproxy/gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ratelimit not working with both headers and cidr matches (envoyp…
…roxy#4377) * fix ratelimit descriptors do not respect both headers and cidr match for one rule Signed-off-by: shawnh2 <[email protected]> * fix gen-check and lint Signed-off-by: shawnh2 <[email protected]> * fix ratelimit e2e test Signed-off-by: shawnh2 <[email protected]> * add more comment and update test case Signed-off-by: shawnh2 <[email protected]> --------- Signed-off-by: shawnh2 <[email protected]> Co-authored-by: Huabing Zhao <[email protected]> (cherry picked from commit 66c0b51) Signed-off-by: Guy Daich <[email protected]>
- Loading branch information
Showing
10 changed files
with
633 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
internal/xds/translator/testdata/in/ratelimit-config/header-and-cidr-matches.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: "first-listener" | ||
address: "0.0.0.0" | ||
port: 10080 | ||
hostnames: | ||
- "*" | ||
path: | ||
mergeSlashes: true | ||
escapedSlashesAction: UnescapeAndRedirect | ||
routes: | ||
- name: "first-route" | ||
traffic: | ||
rateLimit: | ||
global: | ||
rules: | ||
- headerMatches: | ||
- name: "x-user-id" | ||
exact: "one" | ||
- name: "x-user-id" | ||
exact: "two" | ||
- name: "x-org-id" | ||
exact: "three" | ||
cidrMatch: | ||
cidr: 0.0.0.0/0 | ||
ip: 0.0.0.0 | ||
maskLen: 0 | ||
isIPv6: false | ||
distinct: false | ||
limit: | ||
requests: 5 | ||
unit: second | ||
pathMatch: | ||
exact: "foo/bar" | ||
destination: | ||
name: "first-route-dest" | ||
settings: | ||
- endpoints: | ||
- host: "1.2.3.4" | ||
port: 50000 |
88 changes: 88 additions & 0 deletions
88
internal/xds/translator/testdata/in/xds-ir/ratelimit-headers-and-cidr.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
http: | ||
- name: "first-listener" | ||
address: "0.0.0.0" | ||
port: 10080 | ||
hostnames: | ||
- "*" | ||
path: | ||
mergeSlashes: true | ||
escapedSlashesAction: UnescapeAndRedirect | ||
routes: | ||
- name: "first-route" | ||
hostname: "*" | ||
traffic: | ||
rateLimit: | ||
global: | ||
rules: | ||
- headerMatches: | ||
- name: "x-user-id" | ||
exact: "one" | ||
cidrMatch: | ||
cidr: 192.168.0.0/16 | ||
maskLen: 16 | ||
limit: | ||
requests: 5 | ||
unit: second | ||
destination: | ||
name: "first-route-dest" | ||
settings: | ||
- endpoints: | ||
- host: "1.2.3.4" | ||
port: 50000 | ||
- name: "second-route" | ||
hostname: "*" | ||
traffic: | ||
rateLimit: | ||
global: | ||
rules: | ||
- headerMatches: | ||
- name: "x-user-id" | ||
distinct: true | ||
- name: "foobar" | ||
distinct: true | ||
cidrMatch: | ||
cidr: 192.168.0.0/16 | ||
maskLen: 16 | ||
limit: | ||
requests: 5 | ||
unit: second | ||
pathMatch: | ||
exact: "example" | ||
destination: | ||
name: "second-route-dest" | ||
settings: | ||
- endpoints: | ||
- host: "1.2.3.4" | ||
port: 50000 | ||
- name: "third-route" | ||
hostname: "*" | ||
traffic: | ||
rateLimit: | ||
global: | ||
rules: | ||
- headerMatches: | ||
- name: "x-user-id" | ||
exact: "one" | ||
cidrMatch: | ||
cidr: 192.168.0.0/16 | ||
maskLen: 16 | ||
limit: | ||
requests: 5 | ||
unit: second | ||
- headerMatches: | ||
- name: "x-user-id" | ||
exact: "two" | ||
- name: "foobar" | ||
distinct: true | ||
cidrMatch: | ||
cidr: 192.169.0.0/16 | ||
maskLen: 16 | ||
limit: | ||
requests: 10 | ||
unit: second | ||
destination: | ||
name: "third-route-dest" | ||
settings: | ||
- endpoints: | ||
- host: "1.2.3.4" | ||
port: 50000 |
38 changes: 38 additions & 0 deletions
38
internal/xds/translator/testdata/out/ratelimit-config/header-and-cidr-matches.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: first-listener | ||
domain: first-listener | ||
descriptors: | ||
- key: first-route | ||
value: first-route | ||
rate_limit: null | ||
descriptors: | ||
- key: rule-0-match-0 | ||
value: rule-0-match-0 | ||
rate_limit: null | ||
descriptors: | ||
- key: rule-0-match-1 | ||
value: rule-0-match-1 | ||
rate_limit: null | ||
descriptors: | ||
- key: rule-0-match-2 | ||
value: rule-0-match-2 | ||
rate_limit: null | ||
descriptors: | ||
- key: masked_remote_address | ||
value: 0.0.0.0/0 | ||
rate_limit: | ||
requests_per_unit: 5 | ||
unit: SECOND | ||
unlimited: false | ||
name: "" | ||
replaces: [] | ||
descriptors: [] | ||
shadow_mode: false | ||
detailed_metric: false | ||
shadow_mode: false | ||
detailed_metric: false | ||
shadow_mode: false | ||
detailed_metric: false | ||
shadow_mode: false | ||
detailed_metric: false | ||
shadow_mode: false | ||
detailed_metric: false |
Oops, something went wrong.