Skip to content
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

Refactor Upstream API for setting TCP tunneling mode #35510

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

yanavlasov
Copy link
Contributor

@yanavlasov yanavlasov commented Jul 30, 2024

Commit message:
This API was introduced by #32991 and it conflates support for half-close with TCP proxying mode in H/1 codec. This interferes with #34461 which enables support for server half-close in H/2 proxying.

This PR refactors API to separate enabling of the half-close behavior from TCP proxy behavior. Prior to #34461 half-close semativs were only enabled for TCP proxy upstreams, but #34461 introduces other cases as well. This necessitates setting half-close and TCP proxy modes separately. TCP proxy mode is now enabled in the class dedicated to the TCP proxy upstreams.

Risk Level: Low
Testing: Unit Tests (with runtime flag enabled)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

/wait-any

@@ -598,9 +598,6 @@ void UpstreamRequest::onPoolReady(std::unique_ptr<GenericUpstream>&& upstream,
had_upstream_ = true;
// Have the upstream use the account of the downstream.
upstream_->setAccount(parent_.callbacks()->account());
if (enable_half_close_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't look like an API rename, it looks like a refactor.
If we're not using enable half close to call enable half close what's it used for?
should it have a rename?

Copy link
Contributor Author

@yanavlasov yanavlasov Jul 31, 2024

Choose a reason for hiding this comment

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

The enable_half_close_ value is plumbed through the FilterManagerCallbacks::isHalfCloseEnabled() to the filter manager, which determines if local_complete_ is set on encoder end_stream for the upstream filter manager.

The GenericUpstream::enableHalfClose() is setting the TCP proxying mode in H/1 codec which controls how codec behaves when it sees decoder end stream. This code used the half-close flag here to also set the TCP proxying mode, which worked before since the half-close mode was only used in TCP proxy mode.

In #34461 I'm going to enable half-close mode in other cases, so the TCP proxy settings needs to be separate from half-close. So I have moved setting the TCP proxy mode to the dedicated RouterUpstreamRequest class for TCP proxy upstreams.

I have updated PR description accordingly.

@yanavlasov yanavlasov changed the title Rename Upstream API for setting TCP tunneling mode Refactor Upstream API for setting TCP tunneling mode Jul 31, 2024
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

LGTM modulo a class comment explaining why the subclass and when it was used. I'm fine with any maintainer sign-off on the comment so feel free to have someone from EPT review when I'm out tomorrow to improve velocity.

@@ -59,6 +59,20 @@ class TcpConnPool : public GenericConnPool, public Tcp::ConnectionPool::Callback
class HttpUpstream;
class CombinedUpstream;

class RouterUpstreamRequest : public Router::UpstreamRequest {
Copy link
Contributor

Choose a reason for hiding this comment

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

class comment please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Signed-off-by: Yan Avlasov <[email protected]>
Copy link
Contributor

@RyanTheOptimist RyanTheOptimist left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning this up!

@yanavlasov yanavlasov merged commit f58a812 into envoyproxy:main Aug 2, 2024
51 checks passed
@yanavlasov yanavlasov deleted the rename-tcp-tunneling-api branch August 2, 2024 15:13
martinduke pushed a commit to martinduke/envoy that referenced this pull request Aug 8, 2024
This API was introduced by envoyproxy#32991 and it conflates support for
half-close with TCP proxying mode in H/1 codec. This interferes with
envoyproxy#34461 which enables support for server half-close in H/2 proxying.

This PR refactors API to separate enabling of the half-close behavior
from TCP proxy behavior. Prior to envoyproxy#34461 half-close semativs were only
enabled for TCP proxy upstreams, but envoyproxy#34461 introduces other cases as
well. This necessitates setting half-close and TCP proxy modes
separately. TCP proxy mode is now enabled in the class dedicated to the
TCP proxy upstreams.

---------

Signed-off-by: Yan Avlasov <[email protected]>
Signed-off-by: Martin Duke <[email protected]>
asingh-g pushed a commit to asingh-g/envoy that referenced this pull request Aug 20, 2024
This API was introduced by envoyproxy#32991 and it conflates support for
half-close with TCP proxying mode in H/1 codec. This interferes with
envoyproxy#34461 which enables support for server half-close in H/2 proxying.

This PR refactors API to separate enabling of the half-close behavior
from TCP proxy behavior. Prior to envoyproxy#34461 half-close semativs were only
enabled for TCP proxy upstreams, but envoyproxy#34461 introduces other cases as
well. This necessitates setting half-close and TCP proxy modes
separately. TCP proxy mode is now enabled in the class dedicated to the
TCP proxy upstreams.

---------

Signed-off-by: Yan Avlasov <[email protected]>
Signed-off-by: asingh-g <[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.

4 participants