feat(cubestore): support AWS Web Identity Token File in S3RemoteFs#10687
feat(cubestore): support AWS Web Identity Token File in S3RemoteFs#10687
Conversation
|
Claude finished @bsod90's task in 1m 46s —— View job Code Review: PR #10687
SummaryThis PR adds support for AWS Web Identity Token File (OIDC federation) in the CubeStore S3 remote filesystem. This is useful for Kubernetes/EKS environments where pods use IRSA (IAM Roles for Service Accounts) instead of static credentials. The approach is sound — it detects the web identity mode, polls the token file for changes, and only re-exchanges credentials when the file is updated. Issues Found1. Bug:
|
| if let Some(ref file) = token_file { | ||
| let current_modified = std::fs::metadata(file) | ||
| .ok() | ||
| .and_then(|m| m.modified().ok()); | ||
| if current_modified == last_modified { | ||
| continue; | ||
| } | ||
| last_modified = current_modified; | ||
| info!("Web identity token file changed, refreshing S3 credentials"); | ||
| } |
There was a problem hiding this comment.
Bug: This block gates on token_file.is_some(), but token_file can be Some even when is_web_identity is false — specifically when a user sets both CUBESTORE_AWS_ACCESS_KEY_ID and AWS_WEB_IDENTITY_TOKEN_FILE in the environment (e.g., during a migration or in a misconfigured pod).
In that scenario, is_web_identity = false, so refresh_every uses the 3-hour default, but this block still activates and skips credential refreshes unless the token file mtime changes. That effectively breaks the static-credential refresh path.
The fix is to gate on is_web_identity instead:
| if let Some(ref file) = token_file { | |
| let current_modified = std::fs::metadata(file) | |
| .ok() | |
| .and_then(|m| m.modified().ok()); | |
| if current_modified == last_modified { | |
| continue; | |
| } | |
| last_modified = current_modified; | |
| info!("Web identity token file changed, refreshing S3 credentials"); | |
| } | |
| // In web identity mode, only refresh when the token file changed. | |
| if is_web_identity { | |
| if let Some(ref file) = token_file { | |
| let current_modified = std::fs::metadata(file) | |
| .ok() | |
| .and_then(|m| m.modified().ok()); | |
| if current_modified == last_modified { | |
| continue; | |
| } | |
| last_modified = current_modified; | |
| info!("Web identity token file changed, refreshing S3 credentials"); | |
| } | |
| } |
| let is_web_identity = access_key.is_none() && token_file.is_some(); | ||
|
|
||
| let refresh_every = if is_web_identity { | ||
| Duration::from_secs(30) |
There was a problem hiding this comment.
Nit: The 30-second poll interval is reasonable for web identity, but it's hardcoded and ignores CUBESTORE_AWS_CREDS_REFRESH_EVERY_MINS entirely. Consider either:
- Using
CUBESTORE_AWS_CREDS_REFRESH_EVERY_MINSas an override when set (falling back to 30s), or - Adding a brief comment noting that the env var is intentionally ignored in web identity mode.
This prevents confusion when an operator sets the env var expecting it to control all S3 credential refresh behavior.
3f86faf to
635d2ed
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10687 +/- ##
=======================================
Coverage 58.01% 58.01%
=======================================
Files 215 215
Lines 16648 16648
Branches 3347 3347
=======================================
Hits 9659 9659
Misses 6499 6499
Partials 490 490
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
When CUBESTORE_AWS_ACCESS_KEY_ID is not set and AWS_WEB_IDENTITY_TOKEN_FILE is present, the credential provider chain falls through to STS AssumeRoleWithWebIdentity — reading the JWT from the token file and exchanging it for temporary session credentials. The refresh loop now polls the token file mtime every 30 seconds in web identity mode (vs 3-hour default for static credentials). Credentials are only re-exchanged when the file actually changes, keeping STS calls minimal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
635d2ed to
7acb84f
Compare
When CUBESTORE_AWS_ACCESS_KEY_ID is not set and AWS_WEB_IDENTITY_TOKEN_FILE is present, the credential provider chain falls through to STS AssumeRoleWithWebIdentity — reading the JWT from the token file and exchanging it for temporary session credentials.
The refresh loop now polls the token file mtime every 30 seconds in web identity mode (vs 3-hour default for static credentials). Credentials are only re-exchanged when the file actually changes, keeping STS calls minimal.
Check List