network filters: add tcp bandwidth limit#42996
network filters: add tcp bandwidth limit#42996AntonKanug wants to merge 4 commits intoenvoyproxy:mainfrom
Conversation
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
185fc45 to
10215ba
Compare
|
/coverage |
|
Coverage for this Pull Request will be rendered here: https://storage.googleapis.com/envoy-cncf-pr/42996/coverage/index.html For comparison, current coverage on https://storage.googleapis.com/envoy-cncf-postsubmit/main/coverage/index.html The coverage results are (re-)rendered each time the CI |
9527d53 to
8b858b4
Compare
15062e0 to
449992c
Compare
CODEOWNERS
Outdated
| /*/extensions/retry/priority/previous_priorities @ravenblackx @mattklein123 | ||
| /*/extensions/retry/host @ravenblackx @mattklein123 | ||
| /*/extensions/filters/network/http_connection_manager @yanavlasov @mattklein123 | ||
| /*/extensions/filters/network/tcp_bandwidth_limit @UNOWNED @UNOWNED |
There was a problem hiding this comment.
@AntonKanug Thanks for your contribution!
We will need owner here as well as maintainer sponsorship.
cc HTTP bandwith_limit owners @nitgoy @mattklein123 @yanavlasov @tonya11en for inputs
There was a problem hiding this comment.
@AntonKanug Did you consider using Dynamic Modules for this use-case instead?
cc @wbpcode as well. I think these use-cases could be easily built on top of Dynamic Modules now and we should have a discussion to come up with a policy on new CPP extensions as they do add some maintenance burden on the maintainers.
There was a problem hiding this comment.
cc @ggreenway (who may be interested to sponsor this extension)
There was a problem hiding this comment.
I can sponsor this filter.
There was a problem hiding this comment.
@AntonKanug please add @yanavlasov and @nezdolik and yourself as code owners. But next time before starting to write the code for new extension you should first find sponsors (among maintainers). Envoy extension policy: https://github.com/envoyproxy/envoy/blob/main/EXTENSION_POLICY.md
|
/wait-any This seems to be pending either finding a maintainer to sponsor or authoring this as a dynamic module. |
|
|
||
| The filter supports the following configuration options: | ||
|
|
||
| * **download_limit_kbps**: The limit for download bandwidth in KiB/s (kibibytes per second). |
There was a problem hiding this comment.
this section is repetitive with what we already have in api proto file (api/envoy/extensions/filters/network/tcp_bandwidth_limit/v3/tcp_bandwidth_limit.proto). Could you move the missing information there?
| : runtime_(runtime), time_source_(time_source), | ||
| has_download_limit_(config.has_download_limit_kbps()), | ||
| has_upload_limit_(config.has_upload_limit_kbps()), | ||
| download_limit_kbps_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, download_limit_kbps, 0)), |
There was a problem hiding this comment.
you could get rid of 2 boolean fields has_download_limit_, has_upload_limit_ and instead initialize relevant fields like this:
download_token_bucket_(config.has_download_limit_kbps() ? std::make_shared<SharedTokenBucketImpl>(
limit_bytes_per_sec, time_source_, static_cast<double>(kiloBytesToBytes(download_limit_kbps_))) : nullptr)
| Buffer::OwnedImpl upload_buffer_; | ||
|
|
||
| // Timers for processing buffered data | ||
| Event::TimerPtr download_timer_; |
There was a problem hiding this comment.
in filter destructor you will need to disable the timers like so (to avoid any race conditions when filter is being destroyed and timer gets invoked on half destroyed object):
if (download_timer_) {
download_timer_->disableTimer();
download_timer_.reset();
}
| Network::WriteFilterCallbacks* write_callbacks_{}; | ||
|
|
||
| // Buffered data waiting for tokens | ||
| Buffer::OwnedImpl download_buffer_; |
There was a problem hiding this comment.
i think we want to use watermark buffer (Buffer::WatermarkBuffer) here?
|
/lgtm api |
yanavlasov
left a comment
There was a problem hiding this comment.
Looks good. Would you be able to also add an integration test, that tests this filter in a complete Envoy setup, please? It does not need to be complicated, maybe just two tests for upload and download.
/wait-any
f6007e1 to
ed3650e
Compare
|
@yanavlasov @nezdolik ready for review, addressed the comments and added integrations tests. precheck is failing but its failing with same error on main as well, tests are passing locally (edit: rebased with the fix) |
Signed-off-by: Anton Kanugalawattage <antondilon@gmail.com>
Signed-off-by: Anton Kanugalawattage <antondilon@gmail.com>
ed3650e to
31e3337
Compare
Fixes #26754
Commit Message: network filters: add tcp bandwidth limit
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features: