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

Dial only application servers that serve the requested application #12217

Merged
merged 8 commits into from
Apr 28, 2022

Conversation

gabrielcorado
Copy link
Contributor

Related to #12121.

When the service receives an application request, it checks for servers to which it can forward it. This is done by checking if the server is healthy (by dialing it) and if the application’s public address match. After that, it will cache this server list for future requests. Before this PR, the handler first tries to match healthy applications, meaning that all application servers returned by GetApplicationServers, including the ones that could not serve the request were getting dialed.

This PR changes the order of MatchAll to first match the public address and then dial the servers, limiting the MatchHealthy to servers that can serve the request.

For reviewers, here is a short guide on what was changed:

  • lib/srv/app/session.go: Change on the MatchAll order (described earlier);
  • lib/srv/app/handler_test.go: Contains a test TestMatchApplicationServers that guarantees no additional servers are being dialed. The other changes on this file are the necessary setup for making application requests to the Handler (there is a lot of stuff, feel free to suggest any improvement).
  • lib/srv/app/match.go and lib/srv/app/match_test.go: Additional change to close connections opened on MatchHealthy. This was found while writing the tests.

@gabrielcorado gabrielcorado self-assigned this Apr 25, 2022
@github-actions github-actions bot requested review from atburke and smallinsky April 25, 2022 20:54
Copy link
Contributor

@smallinsky smallinsky left a comment

Choose a reason for hiding this comment

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

Nice fix, LGTM.

@gabrielcorado gabrielcorado enabled auto-merge (squash) April 27, 2022 16:54
@gabrielcorado gabrielcorado merged commit be760bb into master Apr 28, 2022
@gabrielcorado gabrielcorado deleted the gabrielcorado/fix-dialing-all-app-servers branch April 28, 2022 16:09
gabrielcorado added a commit that referenced this pull request Apr 28, 2022
…12217)

* feat(reversetunnel): add a dial counter on fake remote site

* refactor(app): change `MatchHealthy` to close connections

* refactor(app): change `MatchAll` order to not dial all servers

* refactor(app): only close connection when dial succeeds
gabrielcorado added a commit that referenced this pull request Apr 28, 2022
…12217)

* feat(reversetunnel): add a dial counter on fake remote site

* refactor(app): change `MatchHealthy` to close connections

* refactor(app): change `MatchAll` order to not dial all servers

* refactor(app): only close connection when dial succeeds
gabrielcorado added a commit that referenced this pull request Apr 28, 2022
…12217) (#12301)

* feat(reversetunnel): add a dial counter on fake remote site

* refactor(app): change `MatchHealthy` to close connections

* refactor(app): change `MatchAll` order to not dial all servers

* refactor(app): only close connection when dial succeeds
gabrielcorado added a commit that referenced this pull request Apr 28, 2022
…12217) (#12300)

* feat(reversetunnel): add a dial counter on fake remote site

* refactor(app): change `MatchHealthy` to close connections

* refactor(app): change `MatchAll` order to not dial all servers

* refactor(app): only close connection when dial succeeds
@webvictim webvictim mentioned this pull request Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants