feat(msfs): reload AIS authn_token_file on rotation#88
Conversation
AIS auth tokens (JWTs) are rotated on disk by an external process, but setupAIStoreContext loaded the token once and cached it in api.BaseParams.Token for the life of the mount, so a rotated token was never picked up without a restart. Re-read authn_token_file whenever its mtime changes (thread-safe), via a new currentBaseParams accessor consulted before each AIStore API call, so a rotated token is used live. The AIS SDK applies BaseParams.Token per request (SetAuxHeaders in api.do), so a per-call refreshed copy takes effect on the next request. Mirrors MSC's FileBasedCredentialsProvider. An inline authn_token still wins and is never reloaded; anonymous (no token) is unchanged. NGCDP-9025
📝 WalkthroughWalkthroughAdds live AIStore authentication token reloading when ChangesAIStore Live Token Reload
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
multi-storage-file-system/backend_aistore.go (1)
88-93: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winOnly seed
tokenMTimeafter a successful initial file load. Ifauthn.LoadTokenfails during setup, the file’s current mtime still gets pinned, socurrentBaseParamswon’t retry unless the mtime changes. That can leave a repaired token file stuck on the empty token until restart or a touch.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@multi-storage-file-system/backend_aistore.go` around lines 88 - 93, The initial token load in backendAIStore currently clears the error but still seeds tokenMTime even when authn.LoadToken fails, which can prevent retries after a later repair. Update the setup flow around authn.LoadToken and currentBaseParams so tokenMTime is only recorded after a successful load, and leave it unset/reset on failure so the token file can be re-read when it becomes readable again.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@multi-storage-file-system/backend_aistore.go`:
- Around line 88-93: The initial token load in backendAIStore currently clears
the error but still seeds tokenMTime even when authn.LoadToken fails, which can
prevent retries after a later repair. Update the setup flow around
authn.LoadToken and currentBaseParams so tokenMTime is only recorded after a
successful load, and leave it unset/reset on failure so the token file can be
re-read when it becomes readable again.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: cdce2b81-7081-4618-9839-3e9548998fe4
📒 Files selected for processing (2)
multi-storage-file-system/backend_aistore.gomulti-storage-file-system/backend_aistore_test.go
AIS auth tokens (JWTs) are rotated on disk by an external process, but setupAIStoreContext loaded the token once and cached it in api.BaseParams.Token for the life of the mount, so a rotated token was never picked up without a restart.
Re-read authn_token_file whenever its mtime changes (thread-safe), via a new currentBaseParams accessor consulted before each AIStore API call, so a rotated token is used live. The AIS SDK applies BaseParams.Token per request (SetAuxHeaders in api.do), so a per-call refreshed copy takes effect on the next request. Mirrors MSC's FileBasedCredentialsProvider. An inline authn_token still wins and is never reloaded; anonymous (no token) is unchanged.
NGCDP-9025
Description
Change description.
{Relates to/Closes} {Task ID}.
Checklist
.release_notes/.unreleased.mdmulti-storage-client/pyproject.toml.release_notes/.unreleased.md.release_notes/{bumped package version}.mdfile.Summary by CodeRabbit
New Features
Tests