router: new methods for stream filter callback to get route per filter config#21525
Conversation
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
|
It would be hard that let every filter handle the IMO, it would be better that using It means that the HTTP filter should get route config by the way as following code. How?First, we need make the Second, we can add method Third, update Fouth, upate every filter to use new |
|
cc @mattklein123 Could you take a quick look to this simple proposal? |
|
Looks reasonable to me. One question I have is whether we have to expose the custom name method. The filter manager should have that info, and only share it with the callbacks implementation, without adding another public method. |
Thanks for you comment. But in the current implementation, the filter instance is added to filter chain by the callback as following. So when we create the filter chain, it's hard to make the custom name available directly without change the callback or add new another public method. |
As long as you are working in this area, can you please fix all debug lines like this one: envoy/source/common/http/filter_manager.cc Lines 507 to 509 in dbfdab2 To print out the name instead of the pointer address of the filter? This will make debugging multiple filters so much easier. I actually started to do this at one point but gave up because it would require a new public method which I think this solves. |
👌 I will update all these log line. |
…re-work-for-custom-route-config
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
…an work correctly Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
…re-work-for-custom-route-config
|
This is outdated. Inherited relationships before this PR of HTTP stream filter. graph TD
BA(StreamFilterBase)
SD(StreamDecoderFilter)
SE(StreamEncoderFilter)
SF(StreamFilter)
PD(PassthroughDecoderFilter)
PE(PassthroughEncoderFilter)
PF(PassthroughFilter)
BA --> SD
BA --> SE
SD --virtual--> PD
SD --virtual--> SF
SE --virtual--> SF
SE --virtual--> PE
PD --> PF
SF --> PF
PE --> PF
Inherited relationships after this PR of HTTP stream filter: graph TD
BA(StreamFilterBase)
SD(StreamDecoderFilter)
SE(StreamEncoderFilter)
SF(StreamFilter)
PD(PassthroughDecoderFilter)
PE(PassthroughEncoderFilter)
PF(PassthroughFilter)
BA --virtual--> SD
BA --virtual--> SE
SD --> PD
SD --> SF
SE --> SF
SE --> PE
SF --> PF
|
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
| // Struct of canonical filter name and HTTP stream filter factory callback. | ||
| struct NamedHttpFilterFactoryCb { | ||
| // Canonical filter name. | ||
| std::string name; |
There was a problem hiding this comment.
Is it possible to put this name to the FilterConfigProvider also?
There was a problem hiding this comment.
+1 to merge this in some way. I'm not familiar with this code but it seems like there is a bunch of duplication with the FilterFactoryContext also? Can this be shared somehow?
There was a problem hiding this comment.
I have just tried to add a method to expose this name in the FilterConfigProvider. But it just make the code more complex and no better than current implementation.
Because it's supported to used different type filters by the ECDS, so the canonical filter name of current provider may be changed when the filter config is updateing by the ECDS. We must make the canonical filter name thread local and update it just as we update factory function in the FilterConfigProvider.
So it's hard to used FilterFactoryContext to store these name in the FilterConfigProvider.
There was a problem hiding this comment.
message ExtensionConfigSource {
ConfigSource config_source = 1 [(validate.rules).any = {required: true}];
// Optional default configuration to use as the initial configuration if
// there is a failure to receive the initial extension configuration or if
// `apply_default_config_without_warming` flag is set.
google.protobuf.Any default_config = 2;
// Use the default config as the initial configuration without warming and
// waiting for the first discovery response. Requires the default configuration
// to be supplied.
bool apply_default_config_without_warming = 3;
// **Here the repeated type_urls make the filter type can be changed by the ECDS. A ratelimit filter can be**
// **updated to ext_authz.**
// A set of permitted extension type URLs. Extension configuration updates are rejected
// if they do not match any type URL in the set.
repeated string type_urls = 4 [(validate.rules).repeated = {min_items: 1}];
}
IMO, it would be better to add some restrictions here. For example, only multiple version APIs of same type filter can be used here.
There was a problem hiding this comment.
IMO, it would be better to add some restrictions here. For example, only multiple version APIs of same type filter can be used here.
I guess even though there can be multiple extension type URLs, they should pointed to the same factory, or they should point to the same canonical filter name?
envoy/source/extensions/filters/network/http_connection_manager/config.cc
Lines 674 to 682 in 154a7a8
Then you can get factory->name(), and pass that to the dynamic filter config provider.
envoy/source/extensions/filters/network/http_connection_manager/config.cc
Lines 684 to 686 in 154a7a8
@adisuissa probably knows the usecase of multiple extension type urls.
There was a problem hiding this comment.
I guess even though there can be multiple extension type URLs, they should pointed to the same factory, or they should point to the same canonical filter name?
It seems that there is no any restriction for now. It would be great if we can add this restriction. But it would be a break change.
So, I think we can keep this PR's implemantation and after this restriction is shipped someday, we can update the implemantation with a new minor patch.
There was a problem hiding this comment.
Yea, it seems like this is the best we have now. Thanks!
There was a problem hiding this comment.
@kyessenov Can probably shed some light on multiple extensions type-urls
soulxu
left a comment
There was a problem hiding this comment.
I like this way. Just one more comment about whether we can put the all the name to the FilterConfigProvider. Then we needn't that NamedHttpFilterFactoryCb wrapper.
It's ok for me. But I am just not sure if we need to expose this canonical name for every type extension. Until for now, the canonical name is only used by the HTTP filters to get route config. And we keep it for the backwards compatibility. So I am not sure if it's worth it to update the APIs of But I'm not against this either. I can update it if the community wishes to do so. cc @mattklein123 cc @soulxu |
Since I saw the FilterConfigProvider already holds the custom name,https://github.com/envoyproxy/envoy/pull/21525/files#diff-9ffd7a166e0bd6afee8cbe95c75544a26060e9d2bc814ba3309fa4c04d8860ecR738 |
custom name is used by the ECDS, but canonical name is unnecessary for most of extention config providers. Any way, it ok for me to udpate it or not. So waiting for some more suggessions from matt. |
|
/retest |
|
Retrying Azure Pipelines: |
mattklein123
left a comment
There was a problem hiding this comment.
Thanks in general this LGTM. Flushing some small comments. Thank you!
/wait
| // Struct of canonical filter name and HTTP stream filter factory callback. | ||
| struct NamedHttpFilterFactoryCb { | ||
| // Canonical filter name. | ||
| std::string name; |
There was a problem hiding this comment.
+1 to merge this in some way. I'm not familiar with this code but it seems like there is a bunch of duplication with the FilterFactoryContext also? Can this be shared somehow?
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
|
/retest |
|
Retrying Azure Pipelines: |
mattklein123
left a comment
There was a problem hiding this comment.
Thanks LGTM with one question.
/wait-any
envoy/http/filter.h
Outdated
| // Canonical filter name. This is used to indicate type of filter. For example, | ||
| // "envoy.filters.http.buffer" for the HTTP buffer filter. | ||
| std::string filter_name; |
There was a problem hiding this comment.
I thought we don't use this anymore? Should this actually be the type URL? cc @kyessenov @phlax as this also relates to #21707 I think?
There was a problem hiding this comment.
It's still necessary for now. Because this name will be used to search the per filter config, as a fallback of config name. 🤔
If we deprecate the fallback policy and used the config name only someday, we can remove this name.
There was a problem hiding this comment.
I think the phrasing needs to be better.
DEPRECATED: Filter extension qualified name. Used as a fallback for `config_name`. E.g. ...
This is needed to support extension names in per_filter_config I think, so we can't change it to anything but what it was (which was extension qualified name).
Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
|
/retest |
|
Retrying Azure Pipelines: |
…r config (envoyproxy#21525) Signed-off-by: wbpcode <wangbaiping@corp.netease.com> Signed-off-by: Amila Senadheera <amila.15@cse.mrt.ac.lk>
Commit Message: router: new methods for stream filter callback to get route per filter config
Additional Description:
The final goal is to support searching for route level filter config from
typed_per_filter_configby the custom filter config name or even dynamic value from request.Check #12274 and #21466 for complete context.
Regardless of which policy is uesed to select the route config searching key, there is some pre-work need to be addresed for the implementation.
This initial commit is used as a quick example for discussions.
Risk Level: Low.
Testing: Waiting.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.