Skip to content

[v10] Ensure that the webclient closes connections#22895

Merged
rosstimothy merged 1 commit intobranch/v10from
tross/backport-22832/v10
Mar 10, 2023
Merged

[v10] Ensure that the webclient closes connections#22895
rosstimothy merged 1 commit intobranch/v10from
tross/backport-22832/v10

Conversation

@rosstimothy
Copy link
Copy Markdown
Contributor

Backport #22832 to branch/v10

@rosstimothy rosstimothy force-pushed the tross/backport-22832/v10 branch from 81d41a9 to 5b85d48 Compare March 10, 2023 16:10
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/v10 branch from 5b85d48 to fa83d73 Compare March 10, 2023 16:18
@rosstimothy rosstimothy marked this pull request as ready for review March 10, 2023 16:23
@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
@rosstimothy rosstimothy requested a review from zmb3 March 10, 2023 16:28
@rosstimothy rosstimothy enabled auto-merge March 10, 2023 16:30
@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from fspmarshall March 10, 2023 16:30
@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 no response for 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
@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/v10 with commit 085c2a6 Mar 10, 2023
@rosstimothy rosstimothy deleted the tross/backport-22832/v10 branch March 20, 2023 16:58
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.

3 participants