-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upstream: allow extension protocol options to be used with http filters #4165
Conversation
Make sense to me. @zuercher PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I have one minor change and a couple of things to thing about, bit it looks good otherwise.
include/envoy/server/filter_config.h
Outdated
@@ -311,6 +323,16 @@ class NamedHttpFilterConfigFactory { | |||
return nullptr; | |||
} | |||
|
|||
// ProtocolOptionsConsumer | |||
Upstream::ProtocolOptionsConfigConstSharedPtr | |||
createProtocolOptionsConfig(const Protobuf::Message& config) override { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about moving the default implementations (here and from the NamedNetworkFilterConfigFactory) to ProtocolOptionsConsumer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good
class TestNetworkFilterConfigFactory | ||
: public Server::Configuration::NamedNetworkFilterConfigFactory { | ||
public: | ||
TestNetworkFilterConfigFactory(TestFilterConfigFactoryBase& parent) : parent_(parent) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little odd not to use inheritance here, but I guess the alternative is assigning the lambdas to variables in the tests and re-using them.
It's a bit dodgy, but I think you could combine the two factories into a single class as long as you overload all the methods that appear in both. 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch is that i'm not sure how that will work with name()
method that's shared on both, but doesn't come from a common interface. is there a way to express that in c++ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably a bad idea. I'm fine for you to leave this as is.
|
||
if (factory == nullptr) { | ||
throw EnvoyException(fmt::format( | ||
"Didn't find a registered network or http implementation for name: '{}'", name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add "filter" between http and implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Let's think about a better name for ProtocolOptionsConsumer and then I think it's good to go.
include/envoy/server/filter_config.h
Outdated
@@ -181,11 +181,35 @@ class NamedListenerFilterConfigFactory { | |||
virtual std::string name() PURE; | |||
}; | |||
|
|||
class ProtocolOptionsConsumer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this should be called ProtocolOptionsFactory? I'm sure what "consumer" means here.
Regardless, should add at least a brief class comment here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me - will fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about this comment for class doc:
Implemented by filter factories that require more options to process the protocol used by the upstream cluster.
@zuercher fixed 2 of the 3 comments, not sure if there's a good was to fix the suggestion on the the filter test class - see my response. |
BTW I'm going to cancel your running builds for an older commit -- circle ci is running a backlog and I want to get master fix testing asap -- it shouldn't affect your builds for your latest (or any future) commits. Just FYI, in case you get an email. |
ipv6 test failure seems unrelated as it results from the hds_integration_test:
full stack trace from CI logs:
|
The release failure also seems unrelated and stems from rbac:integration_test:
|
yes it seems like that flaky RBAC you mentioned, i'll kick CI to have another go. |
Success! thanks @zuercher ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Thanks for taking this on.
@htuch do you want to have a look?
@yuval-k this seems reasonable, but I'd like to quickly double check on motivation here. Is it the case that your NATS streaming filter makes use of knowledge of the upstream picked cluster? Usually awareness of upstream cluster and host pick is more limited, to the router filter, earlier filters in the pipeline don't have this smarts. You can't action on this information until later in the request, post initial headers for example. Anyway, if you can provide some insight into how this is consume by your HTTP filter I think that would help review. Thanks. |
@htuch yes that's correct. In that sense the NATS filter replaces the router filter (i.e. the NATs filter doesn't let the request continue down the filter chain). The idea is to support a case when some requests are routed to http upstreams, and others are converted to NATS pub. |
@yuval-k how do the cluster defined protocol options fit into that idea? If you're holding the request, you probably don't even have a cluster assignment yet for it, so how can you benefit from the protocol options there? |
The cluster assignment happens in the HCM before the request reaches the NATS filter (which is an http filter, placed before the router filter). |
Right, yeah; we have the cached route entry, which indicates cluster (but no actual upstream host pick yet). Makes sense. |
@@ -1625,14 +1685,27 @@ TEST_F(ClusterInfoImplTest, ExtensionProtocolOptionsForFilterWithOptions) { | |||
envoy.test.filter: { option: "value" } | |||
)EOF"; | |||
|
|||
auto cluster = makeCluster(yaml); | |||
std::vector<std::unique_ptr<StrictDnsClusterImpl>> clusters; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some comment explaining what you're testing here? It's unclear without reading deeply whether we're covering all the permutations of {no filter, network filter, http filter} for a given protocol options slot.
Not sure what happened with the DCO - I merged master to get the RBAC flake fix (did a regular |
That's weird, this branch looks kind of crazy. Do you want to just get it into a sane state and force push? |
sounds good, will do |
Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
faad843
to
b5a1a6d
Compare
@yuval-k make sure you get the clang-6 change as well |
I used latest master from today and cherry picked my commits over it - so it should be good. |
* origin/master: (34 commits) fuzz: fixes oss-fuzz: 9895 (envoyproxy#4189) docs: added developer docs for pprof/tcmalloc testing (envoyproxy#4194) fix sometimes returns response body to HEAD requests (envoyproxy#3985) admin: fix config dump order (envoyproxy#4197) thrift: allow translation between downstream and upstream protocols (envoyproxy#4136) Use local_info.node() instead of bootstrap.node() whenever possible (envoyproxy#4120) upstream: allow extension protocol options to be used with http filters (envoyproxy#4165) [thrift_proxy] Replace local HeaderMap with Http::HeaderMap[Impl] (envoyproxy#4169) docs: improve gRPC-JSON filter doc (envoyproxy#4184) stats: refactoring MetricImpl without strings (envoyproxy#4190) fuzz: coverage profile generation instructions. (envoyproxy#4193) upstream: rebuild cluster when health check config is changed (envoyproxy#4075) build: use clang-6.0. (envoyproxy#4168) thrift_proxy: introduce header transport (envoyproxy#4082) tcp: allow connection pool callers to store protocol state (envoyproxy#4131) configs: match latest API changes (envoyproxy#4185) Fix wrong mock function name. (envoyproxy#4187) Bump yaml-cpp so it builds with Visual Studio 15.8 (envoyproxy#4182) Converting envoy configs to V2 (envoyproxy#2957) Add timestamp to HealthCheckEvent definition (envoyproxy#4119) ... Signed-off-by: Snow Pettersen <snowp@squareup.com>
temporary using my envoy fork until PR envoyproxy/envoy#4165 is merged. also - remove envoy common from workspace.
#4098 Added protocol extensions for clusters and network filters. This PR expands this to http filters as well (this can be used for example in a filter that translates http to a different protocol, like our NATS Streaming filter)
Risk Level: low, ignored by existing protocols
Testing: unit tests
Docs Changes: inline
Release Notes: n/a
Few notes: