Skip to content

[v11] Ensure that the webclient closes connections#22894

Merged
rosstimothy merged 1 commit intobranch/v11from
tross/backport-22832/v11
Mar 10, 2023
Merged

[v11] Ensure that the webclient closes connections#22894
rosstimothy merged 1 commit intobranch/v11from
tross/backport-22832/v11

Conversation

@rosstimothy
Copy link
Copy Markdown
Contributor

Backport #22832 to branch/v11

@github-actions github-actions Bot added kubernetes-access size/md tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Mar 10, 2023
The `http.Client.Transport` created in `newWebClient` wraps a
chain of `http.RoundTripper` over an underlying `http.Transport`.
Since we cannot guarantee that each `http.RoundTipper` has a
`CloseIdleConnections` method the usage of
`defer clt.CloseIdleConnections()` does not guarantee that the http
connections created during Find/Ping/etc are closed.

To prevent leaking connections implementations of `http.RoundTripper`
have added a `CloseIdleConnections` method added that forwards the
request on to the wrapped interface. The `otelhttp.Transport` does
not implement this method either so care has been taken to wrap it
in a `http.RoundTripper` which will call the root transport in
`enforceCloseIdleConnections`. An upstream issue has been filed
with otelhttp: open-telemetry/opentelemetry-go-contrib#3543
to get the method added to their `Transport` implementation.

This wasn't noticed prior to upgrading to go1.20 becuase prior to
[this](golang/go@4e7e7ae)
commit the `ReadHeaderTimeout` set on the Proxy web api http.Server
would cause the connection to appear idle and get terminated by the
server.

`TestWebClientClosesIdleConnections` was added to capture the leak
in connections as reported in #22757 and prevent any regressions.
@rosstimothy rosstimothy force-pushed the tross/backport-22832/v11 branch from 3fab454 to 6005f5c Compare March 10, 2023 16:08
@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from fspmarshall March 10, 2023 16:27
@rosstimothy rosstimothy enabled auto-merge March 10, 2023 16:28
@rosstimothy rosstimothy added this pull request to the merge queue Mar 10, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 10, 2023
@rosstimothy rosstimothy added this pull request to the merge queue Mar 10, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 10, 2023
@rosstimothy rosstimothy added this pull request to the merge queue Mar 10, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 10, 2023
@rosstimothy rosstimothy added this pull request to the merge queue Mar 10, 2023
Merged via the queue into branch/v11 with commit 7a6f6b2 Mar 10, 2023
@rosstimothy rosstimothy deleted the tross/backport-22832/v11 branch March 10, 2023 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport kubernetes-access size/md tsh tsh - Teleport's command line tool for logging into nodes running Teleport.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants