Skip to content

feat: support reloading ephemeral AWS credentials via file - #26537

Merged
waynr merged 8 commits into
mainfrom
feat/support-reloading-ephemeral-credentials-files
Jun 18, 2025
Merged

waynr merged 8 commits into
mainfrom
feat/support-reloading-ephemeral-credentials-files

Conversation

@waynr

@waynr waynr commented Jun 18, 2025

Copy link
Copy Markdown
Contributor

This addresses #26497.

The implementation is accomplished by introducing a new ObjectStore adapter called ReauthingObjectStore that wraps an existing Arc<dyn ObjectStore> along with an Arc<AwsCredentialReloader> in order to provide two forms of credential reloading:

  • Periodic credential reloading that initially reads an expiry time (in seconds from the epoch) from the credentials file. This expiry time is used to set a timer after which the background task will attempt to reload the credentials and set the new expiry time as the next reload wakup time.
    • If there are no new credentials, the background loop defaults to checking every hour.
  • On any ObjectStore call if object_store::Error::Unauthenticated is detected in the first attempt then we attempt to reload credentials from disk before retrying.
    • Currently we only retry the ObjectStore method call once since it's assumed that if reloading the credentials doesn't solve the problem then the right behavior should be to allow the error to return up the stack.

This works by implementing a customer object_store::CredentialProvider that contains a shared reference to a AwsCredential instance synchronized by a RwLock.

@waynr
waynr force-pushed the feat/support-reloading-ephemeral-credentials-files branch from 7c20df9 to 48e4337 Compare June 18, 2025 06:56
@waynr
waynr requested a review from a team June 18, 2025 06:58
env = gen_name!($prefix, "AWS_CREDENTIALS_FILE"),
action
)]
pub aws_credentials_file: Option<String>,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should this be documented in the verbose serve help text?

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.

Seems like it would be useful?

@waynr
waynr force-pushed the feat/support-reloading-ephemeral-credentials-files branch from 48e4337 to 2ab7bde Compare June 18, 2025 07:16

@stuartcarnie stuartcarnie 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.

Looks good to me. 💯 for a comprehensive set of tests.

Comment on lines +1215 to +1227
macro_rules! retry_if_unauthenticated {
($self:ident, $expression:expr) => {
match $expression {
Ok(v) => Ok(v),
Err(object_store::Error::Unauthenticated { source, .. }) => {
warn!(error = ?source, "authentication with object store failed, attempting to reload from disk");
let _ = $self.credential_reloader.check_and_update().await;
$expression
}
Err(e) => Err(e),
}
}
}

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.

Nice

env = gen_name!($prefix, "AWS_CREDENTIALS_FILE"),
action
)]
pub aws_credentials_file: Option<String>,

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.

Seems like it would be useful?

return None;
}
};
let next_expiry = file_credentials.expiry;

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.

👍🏻 to using the expiry to trigger reloading the credentials.

@waynr
waynr merged commit c491110 into main Jun 18, 2025
@waynr
waynr deleted the feat/support-reloading-ephemeral-credentials-files branch June 18, 2025 16:45
mgattozzi pushed a commit that referenced this pull request Sep 8, 2025
* feat: allow users to specify lookback duration for PersistedFiles buffer (#26528)

* feat: support reloading ephemeral AWS credentials via file (#26537)
  * feat: introduce re-authenticating ObjectStore adapter for AWS file credentials
  * test: validate AwsCredentialReloader background update behavior
  * test: add tests and fixtures to validate ReauthingObjectStore behavior
  * docs: add --aws-credentials-file to manually-curated docstrings
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.

2 participants