Repository navigation
http: adding an option to preserve hop by hop headers - #17110
Conversation
Signed-off-by: Alyssa Wilk <[email protected]>
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Signed-off-by: Alyssa Wilk <[email protected]>
adisuissa
left a comment
There was a problem hiding this comment.
Got a question about this.
/wait-any
| // By default, Envoy removes hop by hop headers. For envoy-mobile | ||
| // they should be passed up to the caller. This should not be used by server | ||
| // side Envoy as it expects hop by hop headers to be cleared. | ||
| bool preserve_hop_by_hop_response_headers = 48; |
There was a problem hiding this comment.
Thinking out loud here, are there going to be more mobile-only fields? If so, should this be part of a sub message that makes it clear that this is only for envoy-mobile instances?
This way we can also reject a config that has this sub-message in non-envoy-mobile instances.
There was a problem hiding this comment.
Also for consideration, can we make HCM aware of, in some general sense, the fact that it's linked into a client and not another hop? I think to reject and validate this field on Envoy-proper, we would need this kind of awareness anyway.
Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: Alyssa Wilk <[email protected]>
|
@mattklein123 @goaway will need unit tests but WDYT of this vs explicit control knob? |
Signed-off-by: Alyssa Wilk <[email protected]>
mattklein123
left a comment
There was a problem hiding this comment.
Yup this is exactly what I had in mind. Thank you!
| const envoy::extensions::filters::network::http_connection_manager::v3:: | ||
| EnvoyMobileHttpConnectionManager& mobile_config, | ||
| Server::Configuration::FactoryContext& context) { | ||
| const envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager& | ||
| proto_config = mobile_config.config(); | ||
|
|
||
| Utility::Singletons singletons = Utility::createSingletons(context); | ||
|
|
||
| auto filter_config = Utility::createConfig( | ||
| proto_config, context, *singletons.date_provider_, *singletons.route_config_provider_manager_, | ||
| *singletons.scoped_routes_config_provider_manager_, *singletons.http_tracer_manager_, | ||
| *singletons.filter_config_provider_manager_); | ||
|
|
||
| // This lambda captures the shared_ptrs created above, thus preserving the | ||
| // reference count. | ||
| // Keep in mind the lambda capture list **doesn't** determine the destruction order, but it's fine | ||
| // as these captured objects are also global singletons. | ||
| return [singletons, filter_config, &context](Network::FilterManager& filter_manager) -> void { | ||
| auto hcm = new Http::ConnectionManagerImpl( | ||
| *filter_config, context.drainDecision(), context.api().randomGenerator(), | ||
| context.httpContext(), context.runtime(), context.localInfo(), context.clusterManager(), | ||
| context.overloadManager(), context.dispatcher().timeSource()); | ||
| hcm->setClearHopByHopResponseHeaders(false); | ||
| filter_manager.addReadFilter(Network::ReadFilterSharedPtr{hcm}); | ||
| }; |
There was a problem hiding this comment.
nit: I think you can probably share this code in a utility function with above.
Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: Alyssa Wilk <[email protected]>
|
I think macos failure is spurious, PTAL! |
Signed-off-by: Alyssa Wilk <[email protected]>
|
@snowp any requests here? I think I addressed all @mattklein123's comments |
snowp
left a comment
There was a problem hiding this comment.
Just a few small comments, otherwise this LG!
| if (clear_hop_by_hop) { | ||
| response_headers.removeConnection(); | ||
| response_headers.removeUpgrade(); | ||
| } | ||
| } | ||
|
|
||
| response_headers.removeTransferEncoding(); | ||
|
|
||
| if (request_headers != nullptr && | ||
| (config.alwaysSetRequestIdInResponse() || request_headers->EnvoyForceTrace())) { | ||
| config.requestIDExtension()->setInResponse(response_headers, *request_headers); | ||
| } | ||
| response_headers.removeKeepAlive(); | ||
| response_headers.removeProxyConnection(); | ||
|
|
||
| if (clear_hop_by_hop) { | ||
| response_headers.removeTransferEncoding(); | ||
| response_headers.removeKeepAlive(); | ||
| response_headers.removeProxyConnection(); | ||
| } |
There was a problem hiding this comment.
Any reason to not do this within one if block?
There was a problem hiding this comment.
I prefer having the upgrade / not-upgrade logic colocated ratehr than having the hop by hop code colocated
| filter_manager.addReadFilter(Network::ReadFilterSharedPtr{new Http::ConnectionManagerImpl( | ||
| return [singletons, filter_config, &context, | ||
| clear_hop_by_hop_headers](Network::FilterManager& filter_manager) -> void { | ||
| auto hcm = new Http::ConnectionManagerImpl( |
There was a problem hiding this comment.
We could make the shared readfiltersharedptr but then would need to cast it back for the call to setClearHopByHopResponseHeaders (which isn't in the interface). I chose raw pointer and making shared at addReadFilter but lmk if you prefer casts.
There was a problem hiding this comment.
Can't you just make a shared_ptr<Http::ConnectionManagerImpl> and then implicit casting will handle the upcast?
There was a problem hiding this comment.
good call, on it!
Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: Alyssa Wilk <[email protected]>
|
ugh, so this doesn't work as advertised, because Envoy mobile sets up its config via ApiListener, and ApiListener is hard-coded to only read v3::HttpConnectionManager I assume I'll need to do a follow-up to allow it to also parse EnvoyMobileHttpConnectionManager, but I'm also 1600+ diff patches into the envoy-mobile change to move from HttpConnectionManager to EnvoyMobileHttpConnectionManager and if anyone is willing to revisit a knob in the base HCM I'd love to not add more scut work here.... |
I'm really surprised it's this much of a diff? In general I think it's worth doing this work as I think we are going to need more options passed through that we don't necessarily want to be Envoy proxy side visible. |
|
It's mostly whitespace: they have many hard-coded configs, and along with adding the new type becasue no-proto-subclass one has to add config: and add 2 spaces to all the HCM config. I've already done it so no skin off my back if we continue but it's a lot of churn I didn't anticipate. |
#17110 the EnvoyMobileHttpConnectionManager but it turns out it's instantiated either as a standard network filter (needs a name) or as an API listener (which only accepted HttpConnectionManager) Fixing both issues. Risk Level: low Testing: unit tests Docs Changes: n/a Release Notes: n/a Part of envoyproxy/envoy-mobile#1540 Signed-off-by: Alyssa Wilk <[email protected]>
Risk Level: low (config guarded code) Testing: new unit tests Docs Changes: n/a Release Notes: intentionally not added Platform Specific Features: n/a Part of envoyproxy/envoy-mobile#1540 Signed-off-by: Alyssa Wilk <[email protected]>
…xy#17407) envoyproxy#17110 the EnvoyMobileHttpConnectionManager but it turns out it's instantiated either as a standard network filter (needs a name) or as an API listener (which only accepted HttpConnectionManager) Fixing both issues. Risk Level: low Testing: unit tests Docs Changes: n/a Release Notes: n/a Part of envoyproxy/envoy-mobile#1540 Signed-off-by: Alyssa Wilk <[email protected]>
Risk Level: low (config guarded code)
Testing: new unit tests
Docs Changes: n/a
Release Notes: intentionally not added
Platform Specific Features: n/a
Part of envoyproxy/envoy-mobile#1540