You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am upgrading a TCP stream to HTTP/2 using the TCP tunneling feature. Is there any way to support applying a L7 filter to the output of the tunneling, without creating another listener?
Currently it seems like the only way to do this, is routing the output of the first listener (that has the tcp_proxy filter) to a second listener where there's the HTTP connection manager filter.
there is no way to do that today. I remember there is another issue about nest filter chain #18035, I thought that can do the thing you asked. cc @kyessenov may know the background.
@kyessenov I tried adding an upstream HTTP filter, for some reason it doesn't hit any of the callbacks. I saw that this feature is in alpha. Does it need to be enabled with some runtime flag?
The feature should be enabled via xDS config. L7 filter needs to be registered as an upstream HTTP filter internally in the code, and not every HTTP filter has been registered. Do you have some trace log to share?
@kyessenov I tried using the buffer filter which is also registered as an upstream filter (modified it by printing some stuff in the filter callbacks and none of them were printed). The trace log does not show anything about the buffer filter. What do you mean enabling it by the xDS config? Can you give me an example? This is possibly what makes it not work..
@kyessenov I tried it exactly as in the example you sent. I added prints in the "buffer" filter constructor and in "decodeHeaders". None of them were printed. It might have something to do with me using the TCP proxy filter with tunneling feature? Looking at its code, seems like it has a custom upstream.
@kyessenov pinging again about this. Would appreciate your advice on how to proceed here, I am trying to understand whether I have configured something incorrectly or can you confirm that this should work even if using the TCP tunneling feature?
You might be right that the upstream filters only work for HCM. @alyssawilk probably knows best. We can treat this issue as a feature request to support other proxies on the downstream for HTTP upstreams with filters.
@alyssawilk would it be possible to support it for tunneled sessions? I can try implementing this myself, but would appreciate hints on where should I start. What bothers me is that it seems like the tcp_proxy uses a custom upstream to manage tunneled sessions
If you're game to write the code I'm game to review but it's going to be a pretty complicated project.
Largely I think we'd want the HttpUpstream class in source/common/tcp_proxy/upstream.* to move towards code sharing or code reuse of UpstreamRequest in source/common/router/upstream_request.*
If I were doing it I'd probably start by prototyping having HttpUpstream implement RouterFilterInterface and own a HttpUpstream (with no filters - just trying to get the data flow working), then possibly split that into a few PRs of cleaning up interfaces and existing code, and the submitting the new functionality as flag guarded feature. Once that's all hanging together, you could add in the complexity of filters and all the e2e tests to make sure resets and buffering work as expected.
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
@alyssawilk@kyessenov as I see it there are two options to support this feature for tunneled session, either supporting upstream filters as per alyssa suggestion, or supporting "http_filters: []" field in tunneling_config, so it would be part of the upstream implementation itself. Is there a preferred way to support this from your perspective?
Sorry I don't understand how adding filters to the tunneling config would help. something still has to instantiate the filters and run the filter chain.
I meant, adding filters to the tunneling config and supporting this by code, meaning that tcp_proxy could also support L7 filters in the filter config, in case tunneling is applied, same as HCM is defined as a L4 filter, but has a config for the L7 filters. I guess this would require a lot more coding to support, but I'm asking which method should be more user-approaching?
I think by default tunneled traffic to a cluster would use the filter chain of the cluster, but there should be some mechanism for override in case originally-L7 traffic ought to have a different filter chain from newly-encapped traffic. I don't have strong feelings about where the override config should live - I leave that up to API shepherds :-)
I think I confused with my answer, let me rephrase.
Putting tcp_proxy aside, for HTTP case there are two places where you could use HTTP filters:
In the downstream filter chain (attached to the HCM filter).
In the upstream filters.
For tcp_proxy with tunneling, however, currently there's no support for HTTP filters, even though on the downstream filters, we have upgraded the stream to HTTP. Therefore, what I tried to suggest is:
Supporting HTTP filters in the tunneling config for tcp_proxy - this way, we can apply L7 filters for tunneled traffic, similar to how HCM is applying L7 filters for HTTP traffic (this needs to be backed by code of course, but I'm trying to layout the user experience)
Supporting upstream filters for tcp_proxy that was upgraded using tunneling config, by the approach you suggested in one of your previous comments here, quoting it here:
If you're game to write the code I'm game to review but it's going to be a pretty complicated project.
Largely I think we'd want the HttpUpstream class in source/common/tcp_proxy/upstream.* to move towards code sharing or code reuse of UpstreamRequest in source/common/router/upstream_request.* If I were doing it I'd probably start by prototyping having HttpUpstream implement RouterFilterInterface and own a HttpUpstream (with no filters - just trying to get the data flow working), then possibly split that into a few PRs of cleaning up interfaces and existing code, and the submitting the new functionality as flag guarded feature. Once that's all hanging together, you could add in the complexity of filters and all the e2e tests to make sure resets and buffering work as expected.
"For tcp_proxy with tunneling, currently there's no support for HTTP filters, even though on the downstream filters, we have upgraded the stream to HTTP. Therefore, what I tried to suggest is:"
For TCP proxy with tunneling, the main processing engine is TCP. We only do L7 upstream. So there's no way to do the moral equivalent of downstream filters, we can only do upstream filters.
We can configure the filter chain based on downstream, or upstream, but they're always going to be upstream filters.
Activity
soulxu commentedon Jan 3, 2023
there is no way to do that today. I remember there is another issue about nest filter chain #18035, I thought that can do the thing you asked. cc @kyessenov may know the background.
kyessenov commentedon Jan 3, 2023
I think upstream HTTP filters would work better here? This is a new feature, but seems like the right fit to avoid another listener.
ohadvano commentedon Jan 5, 2023
@kyessenov I tried adding an upstream HTTP filter, for some reason it doesn't hit any of the callbacks. I saw that this feature is in alpha. Does it need to be enabled with some runtime flag?
kyessenov commentedon Jan 5, 2023
cc @alyssawilk
The feature should be enabled via xDS config. L7 filter needs to be registered as an upstream HTTP filter internally in the code, and not every HTTP filter has been registered. Do you have some trace log to share?
ohadvano commentedon Jan 5, 2023
@kyessenov I tried using the buffer filter which is also registered as an upstream filter (modified it by printing some stuff in the filter callbacks and none of them were printed). The trace log does not show anything about the buffer filter. What do you mean enabling it by the xDS config? Can you give me an example? This is possibly what makes it not work..
kyessenov commentedon Jan 5, 2023
By xDS config I mean the config file that you use to run Envoy, the sample here.
ohadvano commentedon Jan 5, 2023
@kyessenov I tried it exactly as in the example you sent. I added prints in the "buffer" filter constructor and in "decodeHeaders". None of them were printed. It might have something to do with me using the TCP proxy filter with tunneling feature? Looking at its code, seems like it has a custom upstream.
ohadvano commentedon Jan 9, 2023
@kyessenov pinging again about this. Would appreciate your advice on how to proceed here, I am trying to understand whether I have configured something incorrectly or can you confirm that this should work even if using the TCP tunneling feature?
kyessenov commentedon Jan 9, 2023
You might be right that the upstream filters only work for HCM. @alyssawilk probably knows best. We can treat this issue as a feature request to support other proxies on the downstream for HTTP upstreams with filters.
alyssawilk commentedon Jan 9, 2023
yeah I think it's not yet implemented yet for tunneled sessions.
ohadvano commentedon Jan 10, 2023
@alyssawilk would it be possible to support it for tunneled sessions? I can try implementing this myself, but would appreciate hints on where should I start. What bothers me is that it seems like the tcp_proxy uses a custom upstream to manage tunneled sessions
alyssawilk commentedon Jan 10, 2023
If you're game to write the code I'm game to review but it's going to be a pretty complicated project.
Largely I think we'd want the HttpUpstream class in source/common/tcp_proxy/upstream.* to move towards code sharing or code reuse of UpstreamRequest in source/common/router/upstream_request.*
If I were doing it I'd probably start by prototyping having HttpUpstream implement RouterFilterInterface and own a HttpUpstream (with no filters - just trying to get the data flow working), then possibly split that into a few PRs of cleaning up interfaces and existing code, and the submitting the new functionality as flag guarded feature. Once that's all hanging together, you could add in the complexity of filters and all the e2e tests to make sure resets and buffering work as expected.
ohadvano commentedon Jan 10, 2023
This seems like a major change. I don't have enough capacity for this at the moment, but I'll keep this in mind. Thanks :)
github-actions commentedon Feb 10, 2023
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
ohadvano commentedon Feb 10, 2023
@alyssawilk can you please mark this as help-wanted?
ohadvano commentedon Mar 4, 2023
@alyssawilk @kyessenov as I see it there are two options to support this feature for tunneled session, either supporting upstream filters as per alyssa suggestion, or supporting "http_filters: []" field in tunneling_config, so it would be part of the upstream implementation itself. Is there a preferred way to support this from your perspective?
alyssawilk commentedon Mar 6, 2023
Sorry I don't understand how adding filters to the tunneling config would help. something still has to instantiate the filters and run the filter chain.
ohadvano commentedon Mar 6, 2023
I meant, adding filters to the tunneling config and supporting this by code, meaning that tcp_proxy could also support L7 filters in the filter config, in case tunneling is applied, same as HCM is defined as a L4 filter, but has a config for the L7 filters. I guess this would require a lot more coding to support, but I'm asking which method should be more user-approaching?
alyssawilk commentedon Mar 6, 2023
I think by default tunneled traffic to a cluster would use the filter chain of the cluster, but there should be some mechanism for override in case originally-L7 traffic ought to have a different filter chain from newly-encapped traffic. I don't have strong feelings about where the override config should live - I leave that up to API shepherds :-)
ohadvano commentedon Mar 6, 2023
I think I confused with my answer, let me rephrase.
Putting tcp_proxy aside, for HTTP case there are two places where you could use HTTP filters:
For tcp_proxy with tunneling, however, currently there's no support for HTTP filters, even though on the downstream filters, we have upgraded the stream to HTTP. Therefore, what I tried to suggest is:
WDYT?
alyssawilk commentedon Mar 6, 2023
"For tcp_proxy with tunneling, currently there's no support for HTTP filters, even though on the downstream filters, we have upgraded the stream to HTTP. Therefore, what I tried to suggest is:"
For TCP proxy with tunneling, the main processing engine is TCP. We only do L7 upstream. So there's no way to do the moral equivalent of downstream filters, we can only do upstream filters.
We can configure the filter chain based on downstream, or upstream, but they're always going to be upstream filters.