Cache the result of TeleportProcess.GetRotation
#50235
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Each "full" resource heartbeat (i.e. an "announce" or a fallback using the
UpsertFooServer
rpc directly) includes the rotation state of the agent, which is read from process storage every time. When Teleport is running in Kubernetes, as part of theteleport-kube-agent
, the state in process storage is actually in a Kubernetes secret, which is read from the cluster's API server with a concurrency limit of 1. This causes severe slowdowns, to the point of making the agent unusable (and reporting unhealthy and unready), when a large amount of dynamic resources, such as apps, are changed - potentially as a result of changes in the automatic discovery settings, for example. This PR adds a TTL cache for theGetRotation
call, making sure the cache is invalidated whenever the process writes a new state as part of a CA rotation.changelog: improved the performance of Teleport agents serving a large number of resources in Kubernetes