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: active listener and connection handler #15127

Closed
wants to merge 4 commits into from

Conversation

lambdai
Copy link
Contributor

@lambdai lambdai commented Feb 21, 2021

Commit Message:
Refactor ConnectionHandler: separate inferfaces for tcp listener and udp listener.

Additional Description:
Since an active listener doesn't depend on ConnectionImpl, the complexity of writing a functional test of an active tcp listener is greatly reduced.

Also easier to add a new type of listener wrt my ongoing work to add the envoy internal address listener which has a quite different "accept()" flow and findListenerByAddress implementation.

Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
Fixes #15126
[Optional Deprecated:]
[Optional API Considerations:]

Signed-off-by: Yuchen Dai <[email protected]>
Signed-off-by: Yuchen Dai <[email protected]>

add TcpConnectionHandlerHelper

Signed-off-by: Yuchen Dai <[email protected]>

fix udp listeners

Signed-off-by: Yuchen Dai <[email protected]>

remove unused MockConnectionHandler

Signed-off-by: Yuchen Dai <[email protected]>

TcpConnectionHandler and UdpConnectionHandler

Signed-off-by: Yuchen Dai <[email protected]>

lessen requirement of activeTcpListener

Signed-off-by: Yuchen Dai <[email protected]>

add TcpConnectionHandler and ActiveTcpListener doesn't rely on impl of ConnHandler

Signed-off-by: Yuchen Dai <[email protected]>

remove more mock conn handler

Signed-off-by: Yuchen Dai <[email protected]>
@lambdai lambdai changed the title Connlistener refactor: active listener and connection handler Feb 21, 2021
Signed-off-by: Yuchen Dai <[email protected]>
@lambdai lambdai marked this pull request as ready for review February 23, 2021 19:44
Copy link
Contributor Author

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

To reviewers: The major changes are the interface ConnectionHandler, TcpConnectionHandler and UdpConnectionHandler.

The rest are cascading changes to adapt to the new interfaces.

* @param hand_off_restored_destination_connections true if redirection is allowed.
* @param rebalanced true if no more balance is allowed.
*/
virtual void onAcceptWorker(Network::ConnectionSocketPtr&& socket,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted from ConnectionHandlerImpl

/**
* The connection handler from the view of a tcp listener.
*/
class TcpConnectionHandler : public virtual ConnectionHandler {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted from ConnectionHandlerImpl

/**
* Wrapper for an active listener owned by this handler.
*/
class ActiveListenerImplBase : public virtual Network::ConnectionHandler::ActiveListener {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved out of ConnectionHandlerImpl

class ActiveRawUdpListener : public ActiveUdpListenerBase,
public Network::UdpListenerFilterManager,
public Network::UdpReadFilterCallbacks {
class ActiveListenerImplBase : public virtual Network::ConnectionHandler::ActiveListener {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move out of ConnectionHandlerImpl because ActiveListenerImplBase is used by both Active{Tcp,Udp}Listener. And the latter two classes are moved to separate file

@lambdai
Copy link
Contributor Author

lambdai commented Feb 27, 2021

@ggreenway as the current reviewer

I didn't touch connection_handler_test because I want to prove the refactor is logically correct. Right now the PR is now "+1,096 −968" :(

Copy link
Contributor

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

This is difficult to review mostly due to code moving to different files. Can you break this into two PRs (or at least two commits in this PR), one that moves code into the correct classes, and one that moves those changes between files only (only cut/paste + bazel changes)?

@lambdai
Copy link
Contributor Author

lambdai commented Mar 2, 2021

@ggreenway I feel your pain. I will start with extracting the internal classes. That are risk-free but account for the majority of the diff

@lambdai
Copy link
Contributor Author

lambdai commented Mar 2, 2021

/wait

@github-actions
Copy link

github-actions bot commented Apr 2, 2021

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Apr 2, 2021
@lambdai
Copy link
Contributor Author

lambdai commented Apr 2, 2021

Close this one: Landed in split PRs

@lambdai lambdai closed this Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale stalebot believes this issue/PR has not been touched recently waiting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tech debt: connection handler implementation
3 participants