feat: reload profile credentials when the shared credentials file changes - #6
Merged
Merged
Conversation
…nges A mount started with --profile resolved its credentials once, at mount time, and kept them for the life of the process. When an external rotator rewrote ~/.aws/credentials and deactivated the old key, every read and write on the mount started failing with 403 until goofys was restarted. Profile mounts now go through a credentials provider that watches the shared credentials file (size and mtime, sampled at most once every 10 seconds off the signing path's fast path) and re-resolves the profile whenever it changes. Resolution runs through a session with shared config enabled, so role_arn, source_profile, credential_process and SSO profiles keep their full chain instead of being pinned to the raw static keys, and the expiry of any STS or SSO credentials underneath is honoured as well. If a reload fails, for instance because the rotator has the file truncated at that moment, the previously loaded credentials are kept and the failure is logged rather than surfaced as an I/O error on the mount.
giraffesyo
approved these changes
Aug 10, 2026
quannhoang
approved these changes
Aug 10, 2026
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.
Problem
A mount started with
--profileresolved its credentials once, at mount time, and kept them for the life of the process. When an external rotator rewrote~/.aws/credentialsand deactivated the old key, every read and write on the mount failed with 403 until goofys was restarted.What changed
Profile mounts now go through
sharedFileProvider, a credentials provider that watches the shared credentials file and re-resolves the profile when it changes.session.NewSessionWithOptionswith shared config enabled, sorole_arn,source_profile,credential_processand SSO profiles keep their full chain instead of being pinned to the raw static keys in~/.aws/credentials. Expiry of any STS or SSO credentials underneath is honoured as well.s3Sessionthat an earlier mount may have built for a different profile.Mounts that pass explicit keys, that set
RoleArn, or that rely onAWS_PROFILE/ the implicitdefaultprofile are unchanged.Testing
go test ./api/common/passes. New coverage: rotation picked up throughGet()without an explicitExpire(), a rotation that preserves the file's timestamp, a failed reload keeping the last known good credentials, a profile declared only in~/.aws/config, and an unknown profile. The tests pinAWS_SHARED_CREDENTIALS_FILE,AWS_CONFIG_FILE, IMDS and ECS credential env vars, and save/restore thes3Sessionglobal so they stay hermetic and order independent.