Skip to content

Support upstream http filters with tcp tunneling - #27183

Merged
alyssawilk merged 88 commits into
envoyproxy:mainfrom
vikaschoudhary16:tcp-proxy-upstream-request
Mar 18, 2024
Merged

alyssawilk merged 88 commits into
envoyproxy:mainfrom
vikaschoudhary16:tcp-proxy-upstream-request

Conversation

@vikaschoudhary16

@vikaschoudhary16 vikaschoudhary16 commented May 4, 2023 •

Copy link
Copy Markdown
Contributor

As suggested in this comment, Router::UpstreamRequest is being initialized and owned by TcpProxy::CombinedUpstream, which is replacement for TcpProxy::HttpUpstream. Eventually TcpProxy::HttpUpstream will be removed.

"Combined" in CombinedUpstream signifies that logic of this class,unlike current TcpProxy::HttpUpstream
, does not depend on H1/H2/H3

Commit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).

🐱

Caused by: #27183 was opened by vikaschoudhary16.

see: more, trace.

Comment thread source/common/tcp_proxy/upstream.h Outdated

@vikaschoudhary16 vikaschoudhary16 May 4, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want to pass nullptr but since onGenericPoolReady() accepts a reference, passing nullptr gives warning. I was not sure if I should change the function signature to accept a pointer because that would require updating so many consumers of the api in other places. For now passing this dummy local_connection_info_provider which eventually gets ignored based on feature flag

@vikaschoudhary16
vikaschoudhary16 force-pushed the tcp-proxy-upstream-request branch 2 times, most recently from 8ca891e to 7dfeaa4 Compare May 4, 2023 14:20
Signed-off-by: Vikas Choudhary <[email protected]>
@yanavlasov

Copy link
Copy Markdown
Contributor

@vikaschoudhary16 please avoid force pushing in the future as it removes comment anchors to source code. It is ok to just keep pushing new commits to the PR.

Conceptually looks good to me. Please also add tests.

@yanavlasov

Copy link
Copy Markdown
Contributor

/wait

@ohadvano

ohadvano commented May 5, 2023 •

Copy link
Copy Markdown
Contributor

Thanks @vikaschoudhary16, it's nice to see that there's more demand for this feature and awesome you were able to make progress with this!

One thing I'm wondering about is - I understand that since TcpProxy is the router itself as well as the downstream filter (kind of HCM + router combined in terms of responsibilities), the HTTP filters that can be applied to tunneled sessions can only be upstream HTTP filters (which is fine). However as far as I can see, there are two occurrences where these filters could be applied in the context:

  1. In the upstream cluster HTTP filters definition
  2. In the downstream tcp_proxy configuration

The difference between these two is that the first will be applied to all tcp_proxies that choose that cluster, so if there are many listeners that are all using the same upstream cluster definition, they will all go through this filter. The second is allowing a more permissive granularity, where only some of the tcp_proxies get that HTTP filter applied to, even if all are targeting the same cluster.

In terms of API, the second could be something like this:

- name: tcp_proxy
  typed_config:
    type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy
    tunneling_config:
      hostname: host.com:443
      upstream_http_filters:
        - f1...

My question is, which approach did you take in this implementation (or both), and if it's one of them, is it currently implemented in a way that could be extended to support the additional approach sometime in the future?

Thanks again for contributing on this, that's awesome.

Signed-off-by: Vikas Choudhary <[email protected]>
@vikaschoudhary16

Copy link
Copy Markdown
Contributor Author

Thanks @vikaschoudhary16, it's nice to see that there's more demand for this feature and awesome you were able to make progress with this!

One thing I'm wondering about is - I understand that since TcpProxy is the router itself as well as the downstream filter (kind of HCM + router combined in terms of responsibilities), the HTTP filters that can be applied to tunneled sessions can only be upstream HTTP filters (which is fine). However as far as I can see, there are two occurrences where these filters could be applied in the context:

  1. In the upstream cluster HTTP filters definition
  2. In the downstream tcp_proxy configuration

The difference between these two is that the first will be applied to all tcp_proxies that choose that cluster, so if there are many listeners that are all using the same upstream cluster definition, they will all go through this filter. The second is allowing a more permissive granularity, where only some of the tcp_proxies get that HTTP filter applied to, even if all are targeting the same cluster.

In terms of API, the second could be something like this:

- name: tcp_proxy
  typed_config:
    type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy
    tunneling_config:
      hostname: host.com:443
      upstream_http_filters:
        - f1...

My question is, which approach did you take in this implementation (or both), and if it's one of them, is it currently implemented in a way that could be extended to support the additional approach sometime in the future?

Thanks again for contributing on this, that's awesome.

Hi, I took first approach i.e upstream cluster and no api change. Though I think it should be possible to extend it and let filters, if specified, in the tunneling config override the upstream cluster filters.

@ohadvano

ohadvano commented May 5, 2023

Copy link
Copy Markdown
Contributor

Hi, I took first approach i.e upstream cluster and no api change. Though I think it should be possible to extend it and let filters, if specified, in the tunneling config override the upstream cluster filters.

Thanks, how about a use case where I want them to be combined? Let's say there's some upstream HTTP filter that I want to be applied to all flows, so I put it in the upstream cluster config, and on some of the tcp_proxies I want to add another HTTP filter. Would it be supportable? I could try to extend this feature sometime after you merge this, I think I'll have capacity for this next month, I just wanted to make sure if this implementation could be the base for this.

@vikaschoudhary16
vikaschoudhary16 marked this pull request as draft May 8, 2023 10:40
@alyssawilk alyssawilk assigned ggreenway and unassigned alyssawilk May 8, 2023

@alyssawilk alyssawilk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, I think this is largely the way I'd start. I'd get things working e2e with the tcp proxy integration test as a next step.

Comment thread source/common/tcp_proxy/upstream.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in the new path we can merge the HTTP1 and HTTP2 upstreams, as the upstream codec filter should take care of per codec logic. so maybe have a new HttpUpstream which handles both and it can call newStream when created?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and newStream definition will be noop(i.e do nothing and return) in Http1Upstream and Http2Upstream?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added new HttpUpstream

@ggreenway ggreenway assigned alyssawilk and unassigned ggreenway May 9, 2023
@vikaschoudhary16

vikaschoudhary16 commented May 9, 2023 •

Copy link
Copy Markdown
Contributor Author

I'd get things working e2e with the tcp proxy integration test as a next step.

  1. tcp_proxy_test.cc are working with feature disabled.
  2. access logging related few tests are failing in tcp_proxy_test.cc when feature is enabled. Looking into those. tcp_proxy_test.cc are working with feature enabled.
  3. upstream_test.cc tests are working with feature disabled.
  4. WIP to enable feature and add more required tests in the upstream_test.cc

Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
alyssawilk
alyssawilk previously approved these changes Mar 13, 2024

@alyssawilk alyssawilk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only two remaining comments are nits - if you prefer I'm happy to merge as is (so sorry about review delay!) and you can fix in your next follow-up.

Along with addressing the TODOs I think we're going to want to to add a BUNCH of e2e tests testing filter state but those can all be follow-up as well.

{Http::Headers::get().Host, config_.host(downstream_info_)},
});

if (config_.usePost()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move definition of scheme here?

Comment thread source/common/tcp_proxy/upstream.cc Outdated
return false;
}
return true;
default:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please no default: if we need to have a return outside the switch for GCC that's fine

@vikaschoudhary16

Copy link
Copy Markdown
Contributor Author

My only two remaining comments are nits - if you prefer I'm happy to merge as is (so sorry about review delay!) and you can fix in your next follow-up.

Along with addressing the TODOs I think we're going to want to to add a BUNCH of e2e tests testing filter state but those can all be follow-up as well.

Hey, thanks for taking a look.
Anyways I will be working on follow-up PRs to add e2e tests and address TODOs, so I would address these two nits also in follow-up if you are ok.

@vikaschoudhary16

Copy link
Copy Markdown
Contributor Author

ah, will have to rebase so will address nits as well

Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
@vikaschoudhary16
vikaschoudhary16 force-pushed the tcp-proxy-upstream-request branch from 7f57b0d to 617a647 Compare March 16, 2024 10:19
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
@vikaschoudhary16
vikaschoudhary16 requested a review from lizan as a code owner March 17, 2024 03:51
Signed-off-by: Vikas Choudhary <[email protected]>
Signed-off-by: Vikas Choudhary <[email protected]>
@alyssawilk
alyssawilk merged commit 50e9108 into envoyproxy:main Mar 18, 2024
alyssawilk added a commit to alyssawilk/envoy that referenced this pull request Mar 19, 2024
alyssawilk added a commit that referenced this pull request Mar 19, 2024
vikaschoudhary16 added a commit to vikaschoudhary16/envoy that referenced this pull request Mar 19, 2024
antoniovleonti pushed a commit to antoniovleonti/envoy that referenced this pull request Mar 20, 2024
ggreenway pushed a commit that referenced this pull request Mar 25, 2024
)" (#32980)" (#32991)

Revert "Revert "Support upstream http filters with tcp tunneling (#27183)" (#32980)"

Enable upstream_http_filters_with_tcp_proxy only in tcpproxy integration
tests

Signed-off-by: Vikas Choudhary <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants