config: refactor filter registration#1083
Conversation
|
Seems reasonable at design level. To simplify review, could you split out the mechanical rename of scope/stats and any other trivials into a separate PR? |
|
Yes I will split it. Right now I'm just trying to clean up some stuff and see a coverage report. |
e37f4db to
01c5941
Compare
For LDS, we need to plumb a stats scope through to all of the filter factory creation functions. This commit takes the opportunity to no longer pass the full server and instead passes a new FactoryContext interface which will allow us to more easily alter what is seen by filters in the future. Though this is a breaking change, since we are still in the 1.4.0 release cycle I will not be deprecating the new network/http filter registration functions that were added during this cycle.
01c5941 to
d5508d9
Compare
|
Sorry it's ready to go modulo fixing the example config repo. Will do that in the morning. The rest is ready to review. |
|
|
||
| envoy_cc_library( | ||
| name = "filter_config_interface", | ||
| hdrs = ["filter_config.h"], |
There was a problem hiding this comment.
This should have deps for all the included header interfaces.
| /** | ||
| * @return Upstream::ClusterManager& singleton for use by the entire server. | ||
| */ | ||
| virtual Upstream::ClusterManager& clusterManager() PURE; |
There was a problem hiding this comment.
I assume all of these are needed for existing filter and there is no further way to minimize the exposed surface.
There was a problem hiding this comment.
yes, minimized as much as possible.
include/envoy/server/filter_config.h
Outdated
| /** | ||
| * This lambda is used to wrap the creation of a network filter chain for new connections as they | ||
| * come in. Filter factories create the lambda at configuration initialization time, and then they | ||
| * are used at runtime. This maps JSON -> runtime configuration. |
There was a problem hiding this comment.
It's a bit unclear from this type signature that this is what is happening. All you get is a Network::FilterManager, whereas when I look at how this is used later, it's capturing JSON config in the lambda in some examples. I think maybe this should be made clearer.
include/envoy/server/filter_config.h
Outdated
| enum class NetworkFilterType { Read, Write, Both }; | ||
|
|
||
| /** | ||
| * This lambda is used to wrap the creation of a network filter chain for new connections as they |
There was a problem hiding this comment.
Nit: Since this is std::function, it's not necessarily a lambda.
| * of general error or a Json::Exception if the json configuration is erroneous. The returned | ||
| * callback should always be initialized. | ||
| * @param config supplies the general json configuration for the filter | ||
| * @param context supplies the filter's context. |
include/envoy/server/filter_config.h
Outdated
|
|
||
| /** | ||
| * Returns the identifying name for a particular implementation of a network filter produced by | ||
| * the factory. |
| /** | ||
| * Create a particular network filter factory implementation. If the implementation is unable to | ||
| * produce a factory with the provided parameters, it should throw an EnvoyException in the case | ||
| * of general error or a Json::Exception if the json configuration is erroneous. The returned |
There was a problem hiding this comment.
What if the factory lambda captures some JSON config and then finds an issue at runtime instantiation?
include/envoy/server/filter_config.h
Outdated
| * Create a particular http filter factory implementation. If the implementation is unable to | ||
| * produce a factory with the provided parameters, it should throw an EnvoyException in the case of | ||
| * general error or a Json::Exception if the json configuration is erroneous. The returned | ||
| * callback should always be initialized. |
There was a problem hiding this comment.
Same comments as for the network filters above.
| // Now see if there is a factory that will accept the config. | ||
| auto search_it = namedFilterConfigFactories().find(string_name); | ||
| if (search_it != namedFilterConfigFactories().end()) { | ||
| if (search_it != namedFilterConfigFactories().end() && search_it->second->type() == type) { |
There was a problem hiding this comment.
Are there tests covering a found filter with wrong type?
There was a problem hiding this comment.
Probably not. Will add.
|
Note that re: the comments about the function documentation, I just copied that, but will go ahead and clean up the text to make it more clear. |
|
@htuch updated per comments |
include/envoy/server/filter_config.h
Outdated
| * callback should always be initialized. | ||
| * @param config supplies the general json configuration for the filter | ||
| * @param context supplies the filter's context. | ||
| * @return NetworkFilterFactoryCb fixfix |
include/envoy/server/filter_config.h
Outdated
| * @param config supplies the general json configuration for the filter | ||
| * @param stat_prefix prefix for stat logging | ||
| * @param context supplies the filter's context. | ||
| * @return HttpFilterFactoryCb fixfix |
* updates required for envoyproxy/envoy#1083 * update envoy
Cleanups from #1083. Rename some variables and repoint to filter example master. No logic changes.
Cleanups from #1083. Rename some variables and repoint to filter example master. No logic changes.
Regression from #1083. The listener config needs two scopes. One for listener named stats, and one for global named stats that need to be reaped during LDS processing.
Regression from #1083. The listener config needs two scopes. One for listener named stats, and one for global named stats that need to be reaped during LDS processing.
Signed-off-by: Jose Nino <jnino@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: Jose Nino <jnino@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
**Description** This decouples Server struct from the tracer implementation. **Related Issues/PRs (if applicable)** Preparation for #1083 Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
**Description** This consolidates all the copy-pasted processors that existed per endpoint we support into one generic processor. This was made possible thanks to the series of refactoring that we landed in the past few weeks primarily for dynamic module work #90. Notably, now in order to add an endpoint, majority of the new code will be in translator (where also have shared generic interface) as well as the type definition. No longer it requires the huge copy paste of processors. **Related Issues/PRs (if applicable)** Resolves #1083 Blocker for #1429 #1584 #1592 #1594 --------- Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> Co-authored-by: Ignasi Barrera <ignasi@tetrate.io>
For LDS, we need to plumb a stats scope through to all of the filter
factory creation functions. This commit takes the opportunity to no
longer pass the full server and instead passes a new FactoryContext
interface which will allow us to more easily alter what is seen by
filters in the future. While making the same breaking change, I
took the opportunity to encode the type of filter into the registration
which removes a ton of boilerplate from various places. (We have
decided to remove the ability to explicitly configure filter type in the
v2 API).
Though this is a breaking change, since we
are still in the 1.4.0 release cycle I will not be deprecating
the new network/http filter registration functions that were
added during this cycle.
This commit also improves some related coverage and gets us up to
around 98.2%. I will do a follow up change with some other easy
coverage wins that I notice.