ratelimit: allow metadata descriptors to be skipped (#24234)

Signed-off-by: Thomas van Noort thomas.vannoort@datadoghq.com

Commit Message: ratelimit: allow metadata descriptors to be skipped
Risk Level: low
Testing: added unit tests
Docs Changes: per the protobuf definitions
Release Notes: N/A
Platform Specific Features: N/A

Additional Description:
The default behaviour was to skip calling the rate limiting service whenever the metadata key was not found and the default value was not set. This was not correctly documented (nor tested) since it mentioned that only the descriptor was skipped whereas the rate limiting service was skipped altogether.

This adds a skip_if_absent field in the same spirit as for the request headers action: if set to true it skips the descriptor but still calls the rate limiting service, otherwise it skips the rate limiting service.

Note that the deprecated dynamic metadata action does not support this field and defaults to false.

Mirrored from https://github.com/envoyproxy/envoy @ 40fb636fb3ba7d502625614ed613d4e97e140b3e
pull/626/head
data-plane-api(Azure Pipelines) 2 years ago
parent d5e21bce6d
commit c5f3a6e900
  1. 9
      envoy/config/route/v3/route_components.proto
  2. 9
      envoy/extensions/filters/http/ratelimit/v3/rate_limit.proto

@ -2011,6 +2011,7 @@ message RateLimit {
// .. code-block:: cpp
//
// ("<descriptor_key>", "<value_queried_from_metadata>")
// [#next-free-field: 6]
message MetaData {
enum Source {
// Query :ref:`dynamic metadata <well_known_dynamic_metadata>`
@ -2028,11 +2029,17 @@ message RateLimit {
type.metadata.v3.MetadataKey metadata_key = 2 [(validate.rules).message = {required: true}];
// An optional value to use if ``metadata_key`` is empty. If not set and
// no value is present under the metadata_key then no descriptor is generated.
// no value is present under the metadata_key then ``skip_if_absent`` is followed to
// skip calling the rate limiting service or skip the descriptor.
string default_value = 3;
// Source of metadata
Source source = 4 [(validate.rules).enum = {defined_only: true}];
// If set to true, Envoy skips the descriptor while calling rate limiting service
// when ``metadata_key`` is empty and ``default_value`` is not set. By default it skips calling the
// rate limiting service in that case.
bool skip_if_absent = 5;
}
// The following descriptor entry is appended to the descriptor:

@ -237,6 +237,7 @@ message RateLimitConfig {
// .. code-block:: cpp
//
// ("<descriptor_key>", "<value_queried_from_metadata>")
// [#next-free-field: 6]
message MetaData {
enum Source {
// Query :ref:`dynamic metadata <well_known_dynamic_metadata>`
@ -254,11 +255,17 @@ message RateLimitConfig {
type.metadata.v3.MetadataKey metadata_key = 2 [(validate.rules).message = {required: true}];
// An optional value to use if ``metadata_key`` is empty. If not set and
// no value is present under the metadata_key then no descriptor is generated.
// no value is present under the metadata_key then ``skip_if_absent`` is followed to
// skip calling the rate limiting service or skip the descriptor.
string default_value = 3;
// Source of metadata
Source source = 4 [(validate.rules).enum = {defined_only: true}];
// If set to true, Envoy skips the descriptor while calling rate limiting service
// when ``metadata_key`` is empty and ``default_value`` is not set. By default it skips calling the
// rate limiting service in that case.
bool skip_if_absent = 5;
}
oneof action_specifier {

Loading…
Cancel
Save