compressor: expose generic compressor filter to users#10553
compressor: expose generic compressor filter to users#10553mattklein123 merged 65 commits intoenvoyproxy:masterfrom
Conversation
Currently the generic HTTP compressor filter isn't exposed to users
even though it's used internally by `envoy.filters.http.gzip` and can be
used by external filter extensions.
Expose the compressor's config API to users. For example the filter
can be configured as follows:
...
filter_chains:
filters:
- name: envoy.http_connection_manager
config:
http_filters:
- name: envoy.filters.http.compressor
config:
disable_on_etag_header: true
content_length: 100
content_type:
- text/html
- application/json
compressor_library:
name: envoy.filters.http.compressor.gzip
config:
memory_level: 3
window_bits: 10
compression_level: best
compression_strategy: rle
...
Multiple compressor filters using different compressor libraries,
e.g. gzip and brotli, can be stacked in one filter chain.
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
|
/cc @junr03, @rebello95, @mattklein123 |
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
| @@ -0,0 +1,62 @@ | |||
| syntax = "proto3"; | |||
There was a problem hiding this comment.
How does this relate to https://github.com/envoyproxy/envoy/blob/master/api/envoy/config/filter/http/gzip/v2/gzip.proto? Which one should service operators configure and when? Is the former deprecated?
There was a problem hiding this comment.
Yes, exactly, the former is deprecated. We need to make that clear as @htuch points out, have text in deprecated.rst, and also make sure the deprecated feature warning/stat is incremented so that operators know thy need to upgrade.
mattklein123
left a comment
There was a problem hiding this comment.
Thanks a ton for working on this. Per @htuch can we nail the deprecation story? Also, please check clang-tidy. It works now and there may be existing and new issues you need to fix. Thank you!
/wait
| @@ -0,0 +1,62 @@ | |||
| syntax = "proto3"; | |||
There was a problem hiding this comment.
Yes, exactly, the former is deprecated. We need to make that clear as @htuch points out, have text in deprecated.rst, and also make sure the deprecated feature warning/stat is incremented so that operators know thy need to upgrade.
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
|
Thank you! I've just marked the old But since it warns users now I wonder if we should revert #10306 and make |
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
htuch
left a comment
There was a problem hiding this comment.
Looks good, a few more API comments..
| // [#next-free-field: 10] | ||
| message Gzip { | ||
| enum CompressionStrategy { | ||
| DEFAULT = 0; |
There was a problem hiding this comment.
Can you comment on what the DEFAULTs are here and below? These should be fixed in the API.
docs/root/configuration/http/http_filters/compressor_filter.rst
Outdated
Show resolved
Hide resolved
mattklein123
left a comment
There was a problem hiding this comment.
Thanks in general this is awesome. Let's nail all of the API comments and then we can do the in-depth review. Thank you!
/wait
| // | ||
| // This field is ignored when used in the context of the deprecated "envoy.filters.http.gzip" | ||
| // filter. | ||
| CompressorLibrary compressor_library = 6; |
There was a problem hiding this comment.
I'm not sure it makes sense to have a default here. Can we require this and then make the gzip config explicit for clarity?
There was a problem hiding this comment.
Sure, this field is required now.
There was a problem hiding this comment.
Can we make it required via annotation?
There was a problem hiding this comment.
Hm... This message is used also in the deprecated envoy.filters.http.gzip filter. I guess there are two options:
- revert gzip: make use of generalized compression filter #10306 completely or partially (drop the
compressorfield from theGzipmessage); - duplicate
compressor.protoforenvoy.filters.http.gzip.
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
mattklein123
left a comment
There was a problem hiding this comment.
In general looks awesome, thanks. Just a few more high level API comments. Thank you!
/wait
| // The name of the compressor library to instantiate for the filter. | ||
| string name = 1 [(validate.rules).string = {min_bytes: 1}]; |
There was a problem hiding this comment.
We can remove this for new extensions as the extension will be looked up via the typed_config.
| // | ||
| // This field is ignored when used in the context of the deprecated "envoy.filters.http.gzip" | ||
| // filter. | ||
| CompressorLibrary compressor_library = 6; |
There was a problem hiding this comment.
Can we make it required via annotation?
Since Envoy::Compressor::ZlibCompressorImpl::CompressionStrategy is simply static_cast'ed to uint64_t the Standard strategy (4) becomes Z_FIXED (4 as well). This basically disables the use of dynamic Huffman codes when the gzip filter is configured to use default values. Make the Standard strategy equal to 0 to translate to Z_DEFAULT_STRATEGY. Contributes to envoyproxy#8448 Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
|
@rojkov awesome work! Seems like you got @htuch's comment resolved. Any thoughts on #10553 (comment)?
The more I think about it, the more I like this option. It would be a pretty unobtrusive way to disambiguate stats trees from different compression filters without affecting the filter interface. |
Agree. I like "stats_prefix" as more explicit, but would prefer it to be optional to keep minimal configs light. Are you ok with that? |
junr03
left a comment
There was a problem hiding this comment.
would prefer it to be optional to keep minimal configs light
That sounds good to me. Include it if present.
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
Done! |
| // Prefix added to the names of stats generated by this filter. It can be used to disambiguate stats | ||
| // trees from different compression filters. For example stats of a compressor filter limited to compress | ||
| // binaries blobs and tweaked accordingly can be prefixed with "bins.". And another compressor filter | ||
| // tweaked co compress text content only can be prefixed with "text.". |
There was a problem hiding this comment.
| // tweaked co compress text content only can be prefixed with "text.". | |
| // tweaked to compress text content only can be prefixed with "text.". |
super small typo. I can fix in my PR.
|
@htuch @mattklein123 can either of you do a final pass to get the api-shepherds approval? |
| message CompressorLibrary { | ||
| // Compressor library specific configuration. See the supported libraries for further | ||
| // documentation. | ||
| google.protobuf.Any typed_config = 1; |
There was a problem hiding this comment.
Can we move this one to the new TypedConfig that will appear in #10908?
There was a problem hiding this comment.
Sure, I've subscribed to that PR.
There was a problem hiding this comment.
I presume it's about TypedExtensionConfig, not TypedConfig?
There was a problem hiding this comment.
@htuch If we are moving all the typed_configs across the project to the new TypedExtenstionConfig message that is being created in #10908, this could be updated then. I'd like to merge this and come back and update when the discussion in #10908 settles, and gets merged. We have been working on this PR for a while, and have a chain of a few other PRs that depend on this one.
There was a problem hiding this comment.
I don't think we can move them all without a deprecation and major version change. The idea is to make all new ones TypedExtensionConfig. Would it satisfy your concern if I submit a quick PR to introduce this independent of #10908?
There was a problem hiding this comment.
I don't think we can move them all without a deprecation and major version change.
Yep, I was suggesting we would be doing the config in this PR as part of the deprecation that all other extensions would have to go through. But I see the want to wait a bit to land the correct thing that would avoid adding more volume to the deprecation cycle. Thanks for #11105, hopefully we can get that in soon, and move this PR along :)
| Compression::Compressor::CompressorFactoryPtr compressor_factory) | ||
| : Common::Compressors::CompressorFilterConfig( | ||
| generic_compressor, | ||
| stats_prefix + "compressor." + generic_compressor.stats_prefix() + |
There was a problem hiding this comment.
now that #11105 merged, we can delete the stats_prefix field, and use generic_compressor.compressor_library().typed_config().name().
mattklein123
left a comment
There was a problem hiding this comment.
Nice, LGTM other than remaining merge and field replacement.
/wait
This reverts commit 4b4cfda. Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
|
Do we really need the I've replaced |
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
|
|
||
| // [#protodoc-title: Compressor Library] | ||
|
|
||
| message CompressorLibrary { |
There was a problem hiding this comment.
I guess the point of this message was to potentially have fields that were common to all compressor extensions. However, if we believe there won't be a case for this, I am happy to delete.
|
@rojkov friendly request to please never force push as it makes reviews more difficult, thank you! |
mattklein123
left a comment
There was a problem hiding this comment.
Thank you! Agreed on the message simplification.
Description:
Currently the generic HTTP compressor filter isn't exposed to users
even though it's used internally by
envoy.filters.http.gzipand can beused by external filter extensions.
Expose the compressor's config API to users. For example the filter
can be configured as follows:
Multiple compressor filters using different compressor libraries,
e.g. gzip and brotli, can be stacked in one filter chain.
Risk Level: Medium
Testing: unit tests, manual testing
Docs Changes: a page for the new compressor filter is added, also comments in
compressor.protowere updated.Release Notes: added a link to compressor's doc to version_history.rst