Skip to content

Fix some gRPC-tunneled connections#40632

Merged
espadolini merged 2 commits intomasterfrom
espadolini/proxy-peering-leak
Apr 18, 2024
Merged

Fix some gRPC-tunneled connections#40632
espadolini merged 2 commits intomasterfrom
espadolini/proxy-peering-leak

Conversation

@espadolini
Copy link
Copy Markdown
Contributor

@espadolini espadolini commented Apr 17, 2024

This PR mainly fixes a goroutine leak in the proxy peering client, where gRPC client streams used to tunnel connections were not correctly released in certain situations, for example when using app access across a proxy peering connection. The only practical way to shut down a client gRPC stream that unblocks reads and writes is to cancel its context, which was previously just a context associated with the proxy peering connection. With this PR, the proxy peering connections (and the proxy "sshgrpc" auth connections) now use a dedicated context that gets canceled on close.

As part of the fix, connection tracking for the proxy peering client was refactored as it was inherently vulnerable to a (controlled) panic as part of sync.WaitGroup if a new outbound connection was attempted at the wrong time during a proxy shutdown.

gRPC-tunneled auth dialing was also improved, as some minor refactors were necessary to fit the necessary changes to streamutils.

changelog: Fixed a resource leak in the Teleport proxy server when using proxy peering

@espadolini
Copy link
Copy Markdown
Contributor Author

cc @dboslee

@github-actions github-actions Bot requested review from fheinecke and tigrato April 17, 2024 19:13
@gravitational gravitational deleted a comment from github-actions Bot Apr 17, 2024
Copy link
Copy Markdown
Contributor

@rosstimothy rosstimothy left a comment

Choose a reason for hiding this comment

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

LGTM. Tested and verified that connectivity still works and graceful shutdown behaves as expected. 🚀

@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from fheinecke April 18, 2024 14:42
@espadolini espadolini enabled auto-merge April 18, 2024 16:10
@espadolini espadolini added this pull request to the merge queue Apr 18, 2024
Merged via the queue into master with commit e96f103 Apr 18, 2024
@espadolini espadolini deleted the espadolini/proxy-peering-leak branch April 18, 2024 16:28
@public-teleport-github-review-bot
Copy link
Copy Markdown

@espadolini See the table below for backport results.

Branch Result
branch/v13 Failed
branch/v14 Failed
branch/v15 Create PR

espadolini added a commit that referenced this pull request Apr 18, 2024
* Fix some gRPC-tunneled connections

* Fix tests checking the return value of dial()
espadolini added a commit that referenced this pull request Apr 18, 2024
* Fix some gRPC-tunneled connections

* Fix tests checking the return value of dial()
github-merge-queue Bot pushed a commit that referenced this pull request Apr 19, 2024
* Fix some gRPC-tunneled connections (#40632)

* Fix some gRPC-tunneled connections

* Fix tests checking the return value of dial()

* go 1.21 compatibility
github-merge-queue Bot pushed a commit that referenced this pull request Apr 19, 2024
* Fix some gRPC-tunneled connections (#40632)

* Fix some gRPC-tunneled connections

* Fix tests checking the return value of dial()

* go 1.21 compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants