Skip to content

feat: Add ConnectOptions.with_auto_token_refresh() - #21

Merged
jopemachine merged 1 commit into
mainfrom
feat/auto-token-refresh
Nov 11, 2026
Merged

jopemachine merged 1 commit into
mainfrom
feat/auto-token-refresh

Conversation

@jopemachine

Copy link
Copy Markdown
Member

Summary

  • Expose etcd-client's with_auto_token_refresh() as ConnectOptions.with_auto_token_refresh(enabled). When a request is rejected because the authentication token expired, the client authenticates again with the user set by with_user() and resends the request.
  • Without it, the token obtained at connect is the only one the client ever sends. etcd drops a token that has not been used for --auth-token-ttl (300 seconds by default), and from then on every request fails with etcdserver: invalid auth token.

Backend.AI 26.10.0a6 requires an etcd user (BA-8963) and keeps one connection open for the life of each process, so components on a staging cluster with etcd auth enabled started failing with invalid auth token a few minutes after start. Backend.AI needs a release with this option to turn it on.

Test plan

  • tests/test_auth.py: on an etcd with auth enabled and --auth-token-ttl 1, a request after the token expired fails with invalid auth token without the option and succeeds with it
  • tests/test_auth.py, tests/test_tls.py, cargo clippy, ruff check, mypy

🤖 Generated with Claude Code

etcd drops an authentication token that has not been used for
`--auth-token-ttl` (300 seconds by default). The Rust client gets a token
once at connect and keeps sending it, so once it expires every request
fails with `invalid auth token` until the client reconnects.

Expose `etcd-client`'s `with_auto_token_refresh()`, which authenticates
again and resends the request when the token is rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jopemachine
jopemachine marked this pull request as ready for review November 11, 2026 02:32
@jopemachine
jopemachine merged commit 1673464 into main Nov 11, 2026
17 checks passed
@jopemachine
jopemachine deleted the feat/auto-token-refresh branch November 11, 2026 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant