feat: hot-reload management token - #78
Open
cxdy wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds hot-reload support for the management Linode PAT used by latr in daemon/Kubernetes deployments by introducing a per-request TokenProvider (optionally backed by a file with a short TTL cache), avoiding the need to restart when the PAT rotates.
Changes:
- Introduces
TokenProvider+ file-backed token reader with TTL caching (LINODE_TOKEN_FILE,LINODE_TOKEN_CACHE_TTL_SECONDS) and wires it into the Linode client via a customhttp.RoundTripper. - Updates
cmd/latrstartup to select the token provider from env/file and log only the token source (not the token value). - Updates Helm chart values/templates and README to support mounting the PAT as a file for hot-reload.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents token hot-reload env vars and operational behavior. |
| internal/linode/token.go | Adds token provider abstractions and file-backed token caching + env selection logic. |
| internal/linode/token_test.go | Adds tests for static/file providers, TTL parsing, env selection, and per-request auth injection. |
| internal/linode/client.go | Switches client auth to a per-request transport using TokenProvider. |
| internal/linode/client_test.go | Updates unit tests to reflect new client construction and fields. |
| helm/latr/values.yaml | Adds chart values for enabling token file mount and cache TTL configuration. |
| helm/latr/templates/deployment.yaml | Conditionally mounts the token secret as a file and sets env vars accordingly. |
| cmd/latr/main.go | Replaces one-time LINODE_TOKEN load with TokenProviderFromEnv() and NewClientWithTokenProvider(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cxdy
force-pushed
the
feat/linode-token-hot-reload
branch
from
July 23, 2026 08:35
0bdfe6a to
796ac20
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related: linode/linode-blockstorage-csi-driver/pull/592
Currently when running
latrin daemon mode (including k8s), the token is loaded once at startup and that's it. If the token is rotated, latr won't know until it tries to rotate a token and gets a401 Invalid Tokenresponse from Linode API and fails to rotate tokens.This PR allows latr to read the secret from a file, cached by default 60s, so that if the token is replaced there's no need to restart, just start using the new token.