Skip to content

fix(BA-9010): refresh the etcd auth token when it expires - #16940

Merged
HyeockJinKim merged 4 commits into
mainfrom
fix/BA-9010-etcd-token-refresh
Nov 11, 2026
Merged

HyeockJinKim merged 4 commits into
mainfrom
fix/BA-9010-etcd-token-refresh

Conversation

@jopemachine

@jopemachine jopemachine commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

  • etcd drops an authentication token that has not been used for --auth-token-ttl (300 seconds by default). AsyncEtcd authenticated once at connect and kept sending that token for the life of the process, so requests failed with etcdserver: invalid auth token a few minutes after start. _should_retry does not retry it, so a manager GQL request that reads manager/status from etcd returned 500.
  • Turn on ConnectOptions.with_auto_token_refresh(True) whenever a user is configured. A request rejected with an expired token authenticates again with the same user and is resent once. common/lock.py builds its lock client from the same AsyncEtcd.etcd, so it gets the option too.
  • Bump etcd-client-py to ~=0.6.1, the first release with the option (feat: Add ConnectOptions.with_auto_token_refresh() etcd-client-py#21).

Observed on the staging latest stack (26.10.0a6, etcd 3.5.17), repeating every few minutes on two managers and a storage-proxy:

etcd_client.GRPCStatusError: {'code': 16, 'details': b'', 'message': 'etcdserver: invalid auth token'}

Why refresh on the client

etcd expects a client to authenticate again when its token is rejected. The official clients do it by default; the Rust client leaves it off:

Client Re-authenticates on invalid auth token Where
Go clientv3 (etcd v3.5.17) Yes, by default client/v3/retry_interceptor.go: the default call option is retryAuth: true; shouldRefreshToken matches ErrInvalidAuthToken and ErrAuthOldRevision, then refreshToken() authenticates again and the call is retried
Java jetcd Yes, by default jetcd-core/.../impl/AuthCredential.java refreshes the token when an RPC fails with invalid auth token
Rust etcd-client 0.21.1 (under etcd-client-py) Only with ConnectOptions::with_auto_token_refresh(true), off by default src/caller.rs do_call; the option clones every request so it can be resent

This change makes AsyncEtcd behave like the official clients.

Test plan

Resolves BA-9010

🤖 Generated with Claude Code

jopemachine and others added 2 commits November 11, 2026 11:38
etcd drops an authentication token that has not been used for
`--auth-token-ttl` (300 seconds by default). `AsyncEtcd` authenticated
once at connect and kept sending that token, so requests started failing
with `etcdserver: invalid auth token` a few minutes after start and were
not retried.

Turn on `ConnectOptions.with_auto_token_refresh()` (etcd-client-py 0.6.1)
whenever a user is configured: a request rejected with an expired token
authenticates again and is resent once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added size:XS ~10 LoC comp:common Related to Common component labels Nov 11, 2026

@lablup-octodog lablup-octodog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

AsyncEtcd kept sending the etcd auth token it obtained at connect time, so requests failed with invalid auth token once the token TTL passed; this turns on automatic token refresh and bumps etcd-client-py to 0.6.1. The linked issue BA-9010 (etcd auth token expiry) could not be found. python.lock still resolves 0.6.0, so CI fails at dependency resolution.

Findings

Should fix

  • requirements.txt:141: python.lock still pins etcd-client-py 0.6.0 with the specifier ~=0.6.0, so every CI job that resolves the venv fails with the new requirement.
  • src/ai/backend/common/etcd.py:372: No test asserts the auto-refresh option, so a change that drops this call still passes the suite.

Checks

7 of 34 checks failed and 2 are still running. The unit, scenario, and test-unit-gate jobs all end with The virtual environment has etcd-client-py 0.6.0 installed but it does not meet top level requirement etcd-client-py~=0.6.1, so the requirements.txt change without a python.lock update causes them. typecheck and scenario (1/6) are in progress.

Coverage

Read both changed files at the reviewed commit 73e80c4. Checked the original etcd.py, common/lock.py, python.lock, and parts of the etcd tests in the base checkout. The branch head has since advanced to c00009a, which adds changes/16940.fix.md.

Comment thread requirements.txt Resolved
Comment thread src/ai/backend/common/etcd.py Resolved
Update only the etcd-client-py entry; a full regeneration also upgrades unrelated packages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added size:S 10~30 LoC and removed size:XS ~10 LoC labels Nov 11, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added size:M 30~100 LoC and removed size:S 10~30 LoC labels Nov 11, 2026
@jopemachine
jopemachine marked this pull request as ready for review November 11, 2026 03:33
@jopemachine
jopemachine requested a review from a team as a code owner November 11, 2026 03:33
@HyeockJinKim
HyeockJinKim enabled auto-merge (squash) November 11, 2026 03:39
@HyeockJinKim
HyeockJinKim merged commit 3f2783f into main Nov 11, 2026
41 checks passed
@HyeockJinKim
HyeockJinKim deleted the fix/BA-9010-etcd-token-refresh branch November 11, 2026 03:43
jopemachine added a commit that referenced this pull request Nov 11, 2026
…16943)

Co-authored-by: Gyubong Lee <gbl@lablup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
jopemachine added a commit that referenced this pull request Nov 11, 2026
…16942)

Co-authored-by: Gyubong Lee <gbl@lablup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@fregataa fregataa mentioned this pull request Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:common Related to Common component size:M 30~100 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants