-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add route descriptor prefix for ratelimit xds translator (#2234)
* add route descriptor prefix for each xds route under listener Signed-off-by: sh2 <shawnhxh@outlook.com> * simplify route and route rule descriptor keys and values Signed-off-by: sh2 <shawnhxh@outlook.com> --------- Signed-off-by: sh2 <shawnhxh@outlook.com> Co-authored-by: Xunzhuo <bitliu@tencent.com> Co-authored-by: zirain <zirain2009@gmail.com>
- Loading branch information
1 parent
b9e75af
commit 769849e
Showing
17 changed files
with
348 additions
and
139 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
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
44 changes: 44 additions & 0 deletions
44
...tor/testdata/in/ratelimit-config/multiple-masked-remote-address-match-with-same-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,44 @@ | ||
name: "first-listener" | ||
address: "0.0.0.0" | ||
port: 10080 | ||
hostnames: | ||
- "*" | ||
routes: | ||
- name: "first-route" | ||
rateLimit: | ||
global: | ||
rules: | ||
- cidrMatch: | ||
cidr: "192.168.0.10/32" | ||
ipv6: false | ||
maskLen: 32 | ||
limit: | ||
requests: 15 | ||
unit: Hour | ||
pathMatch: | ||
exact: "foo/bar" | ||
destination: | ||
name: "first-route-dest" | ||
settings: | ||
- endpoints: | ||
- host: "1.2.3.4" | ||
port: 50000 | ||
- name: "second-route" | ||
rateLimit: | ||
global: | ||
rules: | ||
- cidrMatch: | ||
cidr: "192.168.0.10/32" | ||
ipv6: false | ||
maskLen: 32 | ||
limit: | ||
requests: 300 | ||
unit: Hour | ||
pathMatch: | ||
exact: "foo/bar" | ||
destination: | ||
name: "second-route-dest" | ||
settings: | ||
- endpoints: | ||
- host: "4.5.6.7" | ||
port: 50001 |
24 changes: 15 additions & 9 deletions
24
internal/xds/translator/testdata/out/ratelimit-config/distinct-match.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 |
---|---|---|
@@ -1,13 +1,19 @@ | ||
domain: first-listener | ||
descriptors: | ||
- key: first-route-key-rule-0-match-0 | ||
value: "" | ||
rate_limit: | ||
requests_per_unit: 5 | ||
unit: SECOND | ||
unlimited: false | ||
name: "" | ||
replaces: [] | ||
descriptors: [] | ||
- key: first-route | ||
value: first-route | ||
rate_limit: null | ||
descriptors: | ||
- key: rule-0-match-0 | ||
value: "" | ||
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 |
28 changes: 18 additions & 10 deletions
28
internal/xds/translator/testdata/out/ratelimit-config/distinct-remote-address-match.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
24 changes: 15 additions & 9 deletions
24
internal/xds/translator/testdata/out/ratelimit-config/empty-header-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 |
---|---|---|
@@ -1,13 +1,19 @@ | ||
domain: first-listener | ||
descriptors: | ||
- key: first-route-key-rule-0-match--1 | ||
value: first-route-value-rule-0-match--1 | ||
rate_limit: | ||
requests_per_unit: 5 | ||
unit: SECOND | ||
unlimited: false | ||
name: "" | ||
replaces: [] | ||
descriptors: [] | ||
- key: first-route | ||
value: first-route | ||
rate_limit: null | ||
descriptors: | ||
- key: rule-0-match--1 | ||
value: rule-0-match--1 | ||
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 |
24 changes: 15 additions & 9 deletions
24
internal/xds/translator/testdata/out/ratelimit-config/masked-remote-address-match.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 |
---|---|---|
@@ -1,13 +1,19 @@ | ||
domain: first-listener | ||
descriptors: | ||
- key: masked_remote_address | ||
value: 192.168.0.0/16 | ||
rate_limit: | ||
requests_per_unit: 5 | ||
unit: SECOND | ||
unlimited: false | ||
name: "" | ||
replaces: [] | ||
descriptors: [] | ||
- key: first-route | ||
value: first-route | ||
rate_limit: null | ||
descriptors: | ||
- key: masked_remote_address | ||
value: 192.168.0.0/16 | ||
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 |
36 changes: 36 additions & 0 deletions
36
...or/testdata/out/ratelimit-config/multiple-masked-remote-address-match-with-same-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,36 @@ | ||
domain: first-listener | ||
descriptors: | ||
- key: first-route | ||
value: first-route | ||
rate_limit: null | ||
descriptors: | ||
- key: masked_remote_address | ||
value: 192.168.0.10/32 | ||
rate_limit: | ||
requests_per_unit: 15 | ||
unit: HOUR | ||
unlimited: false | ||
name: "" | ||
replaces: [] | ||
descriptors: [] | ||
shadow_mode: false | ||
detailed_metric: false | ||
shadow_mode: false | ||
detailed_metric: false | ||
- key: second-route | ||
value: second-route | ||
rate_limit: null | ||
descriptors: | ||
- key: masked_remote_address | ||
value: 192.168.0.10/32 | ||
rate_limit: | ||
requests_per_unit: 300 | ||
unit: HOUR | ||
unlimited: false | ||
name: "" | ||
replaces: [] | ||
descriptors: [] | ||
shadow_mode: false | ||
detailed_metric: false | ||
shadow_mode: false | ||
detailed_metric: false |
Oops, something went wrong.