feat: support is_negative_hits in rate limit actions#44059
feat: support is_negative_hits in rate limit actions#44059wbpcode merged 5 commits intoenvoyproxy:mainfrom
Conversation
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
755dce1 to
c7f6a1a
Compare
|
I check the previous issue and also the API. It's weird for me to do it with rate limit filter because the rate limit works with a time window rather than a single concurrency gauge. I guess, in the design, a very large limit refresh time window will be configured to make the rate limit works like a concurrency gauge. But it still weird. Could use use the concurrency filter to do this? |
wbpcode
left a comment
There was a problem hiding this comment.
Then, let's continue. Some comments are added to the API. Thanks for the contribution.
| // An optional hits subtrahend to be appended to the descriptor produced by this rate limit | ||
| // configuration. This is the inverse of ``hits_addend`` and can be used to refill previously | ||
| // consumed rate limit tokens. Only one of ``hits_addend`` or ``hits_subtrahend`` may be specified. | ||
| // | ||
| // .. note:: | ||
| // This is only supported if the rate limit action is configured in the ``typed_per_filter_config`` like | ||
| // :ref:`VirtualHost.typed_per_filter_config<envoy_v3_api_field_config.route.v3.VirtualHost.typed_per_filter_config>` or | ||
| // :ref:`Route.typed_per_filter_config<envoy_v3_api_field_config.route.v3.Route.typed_per_filter_config>`, etc. | ||
| HitsSubtrahend hits_subtrahend = 8; |
There was a problem hiding this comment.
I guess rather then to add a new message for subtrahend, we can add a bool field like negative_hits_addend to indicate it's subtrahend.
Then at least we needn't to handle the one of validation and so on
There was a problem hiding this comment.
Going with is_negative_hits alongside value under existing hits_addend API.
f4b3031 to
a183428
Compare
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
a183428 to
485b270
Compare
|
/retest |
Signed-off-by: code <wbphub@gmail.com>
|
/retest |
<!-- !!!ATTENTION!!! If you are fixing *any* crash or *any* potential security issue, *do not* open a pull request in this repo. Please report the issue via emailing envoy-security@googlegroups.com where the issue will be triaged appropriately. Thank you in advance for helping to keep Envoy secure. !!!ATTENTION!!! For an explanation of how to fill out the fields, please see the relevant section in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md) !!!ATTENTION!!! Please check the [use of generative AI policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41). You may use generative AI only if you fully understand the code. You need to disclose this usage in the PR description to ensure transparency. --> Commit Message: feat: support is_negative_hits in rate limit actions Additional Description: Support `is_negative_hits` for `hits_addend` in rate limit actions that can be used to have an opposite effect. Can be used to refill previously consumed tokens. See issue for usecase. Risk Level: Low (new api) Testing: unit testing Docs Changes: N/A Release Notes: Yes Platform Specific Features: N/A Fixes: envoyproxy#41219 --------- Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com> Signed-off-by: code <wbphub@gmail.com> Co-authored-by: code <wbphub@gmail.com> Signed-off-by: Nick Shipilov <nick.shipilov.n@gmail.com>
<!-- !!!ATTENTION!!! If you are fixing *any* crash or *any* potential security issue, *do not* open a pull request in this repo. Please report the issue via emailing envoy-security@googlegroups.com where the issue will be triaged appropriately. Thank you in advance for helping to keep Envoy secure. !!!ATTENTION!!! For an explanation of how to fill out the fields, please see the relevant section in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md) !!!ATTENTION!!! Please check the [use of generative AI policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41). You may use generative AI only if you fully understand the code. You need to disclose this usage in the PR description to ensure transparency. --> Commit Message: feat: support is_negative_hits in rate limit actions Additional Description: Support `is_negative_hits` for `hits_addend` in rate limit actions that can be used to have an opposite effect. Can be used to refill previously consumed tokens. See issue for usecase. Risk Level: Low (new api) Testing: unit testing Docs Changes: N/A Release Notes: Yes Platform Specific Features: N/A Fixes: envoyproxy#41219 --------- Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com> Signed-off-by: code <wbphub@gmail.com> Co-authored-by: code <wbphub@gmail.com>
Commit Message: feat: support is_negative_hits in rate limit actions
Additional Description: Support
is_negative_hitsforhits_addendin rate limit actions that can be used to have an opposite effect. Can be used to refill previously consumed tokens. See issue for usecase.Risk Level: Low (new api)
Testing: unit testing
Docs Changes: N/A
Release Notes: Yes
Platform Specific Features: N/A
Fixes: #41219