Skip to content

[v15] Cache remote clients in Connect#39012

Merged
gzdunek merged 5 commits intobranch/v15from
gzdunek/backport-38201
Mar 7, 2024
Merged

[v15] Cache remote clients in Connect#39012
gzdunek merged 5 commits intobranch/v15from
gzdunek/backport-38201

Conversation

@gzdunek
Copy link
Copy Markdown
Contributor

@gzdunek gzdunek commented Mar 6, 2024

Backport #38201 to branch/v15

Changelog: Significantly reduced latency of network calls in Teleport Connect.

gzdunek and others added 2 commits March 6, 2024 11:26
* Add remote client cache

* Add an integration test

* Close all clients when stopping the service

* Move RemoteClientCache to the place where it is used

* Do not check client cert in `Get`

* Fix code style issues

* Prevent potential race condition when removing a cached client

* Test concurrent calls to `Get`

* Add TODO

* `remoteclientcache` -> `clientcache`

* Reduce the `err` scope

* Move `Config` closer to `New` and docs

* Fix lint

* Improve logging and error handling

* Add missing comments

* `Close` -> `Clear`

* Improve the test

* Remove mentions about "remote" client

* Pass `cfg` directly to `Cache`

* `InvalidateForRootCluster` -> `ClearForRootCluster`

* Add docs for the interface

* `ClearForRootCluster` -> `ClearForRoot`

* Add config validation

* Log multiple fields at once

* Improve setting logger

* Use cached remote clients in Connect (#38202)

* Replace all simple `c.clusterClient.ConnectToProxy()` calls

* Use cached proxy client to create gateways

* Use cached proxy client to assume roles

* Invalidate clients when logging in and out

* Gracefully handle expired cert error returned by the server

* Drop `GetRootClusterURI` in headless auth watcher since URIs are already root URIs

* Simplify error check

* Make `auth.ClientI` parameter naming more consistent, use `root` prefix when needed

* Reduce error scope where possible

* Clear cached clients before passwordless login

* Use `fakeClientCache` without pointers

* Move separate `proxyClient` parameter to `CreateGatewayParams` in the gateways code

* Replace checking error string with `client.ErrClientCredentialsHaveExpired`

(cherry picked from commit 39f9951)
Copy link
Copy Markdown
Member

@ravicious ravicious left a comment

Choose a reason for hiding this comment

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

Let's not sell ourselves short, the changelog can say "Significantly reduced latency of network calls in Teleport Connect" for sure. ;)

Also, I think all PRs related to caching could be included in a single backport, couldn't they?

@gzdunek
Copy link
Copy Markdown
Contributor Author

gzdunek commented Mar 6, 2024

Let's not sell ourselves short, the changelog can say "Significantly reduced latency of network calls in Teleport Connect" for sure. ;)

Done! :D

Also, I think all PRs related to caching could be included in a single backport, couldn't they?

All PRs are already included, #38202 has been merged into #38201 before merging to master.

Or you mean #38955?

@ravicious
Copy link
Copy Markdown
Member

Oh I forgot that #38955 is not yet merged. It probably doesn't make sense to wait for #38955 before backporting.

It's good that #38202 and #38201 are already included here.

@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from rosstimothy March 6, 2024 13:57
@gzdunek gzdunek enabled auto-merge March 6, 2024 16:42
gzdunek added 2 commits March 6, 2024 19:27
* Make calls to the auth server concurrently

* Enhance the comment about preferences upsert

* Summarize how `userpreferences.Update` works

(cherry picked from commit ddc45a4)
@gzdunek
Copy link
Copy Markdown
Contributor Author

gzdunek commented Mar 7, 2024

Added #38955.

@gzdunek gzdunek added this pull request to the merge queue Mar 7, 2024
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 7, 2024
@gzdunek gzdunek added this pull request to the merge queue Mar 7, 2024
Merged via the queue into branch/v15 with commit 83ca4f6 Mar 7, 2024
@gzdunek gzdunek deleted the gzdunek/backport-38201 branch March 7, 2024 09:10
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.

4 participants