extensions: add http bandwidth limit filter (#16358)

the filter smoothens the flow of data in both direction up to the specified bandwidth limit.

Risk Level: Low, new filter
Testing: UTs added. Adding more UTs and integration tests.
Docs Changes: Added
Release Notes: Added
Fixes #13604

Signed-off-by: Nitin Goyal <nigoyal@microsoft.com>

Mirrored from https://github.com/envoyproxy/envoy @ a467b0ef41864459f4b4ad76fad7e1efb06b0bf8
pull/624/head
data-plane-api(Azure Pipelines) 4 years ago
parent f250ec448a
commit c8c64e59fa
  1. 1
      BUILD
  2. 6
      STYLE.md
  3. 12
      envoy/extensions/filters/http/bandwidth_limit/v3alpha/BUILD
  4. 70
      envoy/extensions/filters/http/bandwidth_limit/v3alpha/bandwidth_limit.proto
  5. 1
      versioning/BUILD

@ -177,6 +177,7 @@ proto_library(
"//envoy/extensions/filters/http/admission_control/v3alpha:pkg",
"//envoy/extensions/filters/http/aws_lambda/v3:pkg",
"//envoy/extensions/filters/http/aws_request_signing/v3:pkg",
"//envoy/extensions/filters/http/bandwidth_limit/v3alpha:pkg",
"//envoy/extensions/filters/http/buffer/v3:pkg",
"//envoy/extensions/filters/http/cache/v3alpha:pkg",
"//envoy/extensions/filters/http/cdn_loop/v3alpha:pkg",

@ -113,11 +113,11 @@ organization](#package-organization) above.
To add an extension config to the API, the steps below should be followed:
1. If this is still WiP and subject to breaking changes, use `vNalpha` instead of `vN` in steps
below. Refer to the [Cache filter config](envoy/extensions/filter/http/cache/v3alpha/cache.proto)
below. Refer to the [Cache filter config](envoy/extensions/filters/http/cache/v3alpha/cache.proto)
as an example of `v3alpha`, and the
[Buffer filter config](envoy/extensions/filter/http/buffer/v3/buffer.proto) as an example of `v3`.
[Buffer filter config](envoy/extensions/filters/http/buffer/v3/buffer.proto) as an example of `v3`.
1. Place the v3 extension configuration `.proto` in `api/envoy/extensions`, e.g.
`api/envoy/extensions/filter/http/foobar/v3/foobar.proto` together with an initial BUILD file:
`api/envoy/extensions/filters/http/foobar/v3/foobar.proto` together with an initial BUILD file:
```bazel
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")

@ -0,0 +1,12 @@
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py.
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")
licenses(["notice"]) # Apache 2
api_proto_package(
deps = [
"//envoy/config/core/v3:pkg",
"@com_github_cncf_udpa//udpa/annotations:pkg",
],
)

@ -0,0 +1,70 @@
syntax = "proto3";
package envoy.extensions.filters.http.bandwidth_limit.v3alpha;
import "envoy/config/core/v3/base.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/wrappers.proto";
import "udpa/annotations/status.proto";
import "validate/validate.proto";
option java_package = "io.envoyproxy.envoy.extensions.filters.http.bandwidth_limit.v3alpha";
option java_outer_classname = "BandwidthLimitProto";
option java_multiple_files = true;
option (udpa.annotations.file_status).work_in_progress = true;
option (udpa.annotations.file_status).package_version_status = ACTIVE;
// [#protodoc-title: Bandwidth limit]
// Bandwidth limit :ref:`configuration overview <config_http_filters_bandwidth_limit>`.
// [#extension: envoy.filters.http.bandwidth_limit]
// [#next-free-field: 6]
message BandwidthLimit {
// Defines the mode for the bandwidth limit filter.
// Values represent bitmask.
enum EnableMode {
// Filter is disabled.
DISABLED = 0;
// Filter enabled only for incoming traffic.
REQUEST = 1;
// Filter enabled only for outgoing traffic.
RESPONSE = 2;
// Filter enabled for both incoming and outgoing traffic.
REQUEST_AND_RESPONSE = 3;
}
// The human readable prefix to use when emitting stats.
string stat_prefix = 1 [(validate.rules).string = {min_len: 1}];
// The enable mode for the bandwidth limit filter.
// Default is Disabled.
EnableMode enable_mode = 2 [(validate.rules).enum = {defined_only: true}];
// The limit supplied in KiB/s.
//
// .. note::
// It's fine for the limit to be unset for the global configuration since the bandwidth limit
// can be applied at a the virtual host or route level. Thus, the limit must be set for the
// per route configuration otherwise the config will be rejected.
//
// .. note::
// When using per route configuration, the limit becomes unique to that route.
//
google.protobuf.UInt64Value limit_kbps = 3 [(validate.rules).uint64 = {gte: 1}];
// Optional Fill interval in milliseconds for the token refills. Defaults to 50ms.
// It must be at least 20ms to avoid too aggressive refills.
google.protobuf.Duration fill_interval = 4 [(validate.rules).duration = {
lte {seconds: 1}
gte {nanos: 20000000}
}];
// Runtime flag that controls whether the filter is enabled or not. If not specified, defaults
// to enabled.
config.core.v3.RuntimeFeatureFlag runtime_enabled = 5;
}

@ -60,6 +60,7 @@ proto_library(
"//envoy/extensions/filters/http/admission_control/v3alpha:pkg",
"//envoy/extensions/filters/http/aws_lambda/v3:pkg",
"//envoy/extensions/filters/http/aws_request_signing/v3:pkg",
"//envoy/extensions/filters/http/bandwidth_limit/v3alpha:pkg",
"//envoy/extensions/filters/http/buffer/v3:pkg",
"//envoy/extensions/filters/http/cache/v3alpha:pkg",
"//envoy/extensions/filters/http/cdn_loop/v3alpha:pkg",

Loading…
Cancel
Save