feat: adding expiration time for secret cache in secret manager plugin#906
Merged
feat: adding expiration time for secret cache in secret manager plugin#906
Conversation
bf31ec5 to
928d4e0
Compare
karenc-bq
reviewed
Jun 19, 2025
928d4e0 to
ca99cc4
Compare
karenc-bq
reviewed
Jun 19, 2025
9961ade to
59dfd8b
Compare
karenc-bq
reviewed
Jun 19, 2025
karenc-bq
reviewed
Jun 19, 2025
karenc-bq
reviewed
Jun 19, 2025
| self._secret = self._fetch_latest_credentials() | ||
| if self._secret: | ||
| AwsSecretsManagerPlugin._secrets_cache[self._secret_key] = self._secret | ||
| AwsSecretsManagerPlugin._secrets_cache.put(self._secret_key, self._secret, token_expiration_ns) |
Contributor
There was a problem hiding this comment.
Based on the way CacheMap checks for expiration:
def is_expired(self) -> bool:
return time.perf_counter_ns() > self._expiration_time_ns
This should be
Suggested change
| AwsSecretsManagerPlugin._secrets_cache.put(self._secret_key, self._secret, token_expiration_ns) | |
| AwsSecretsManagerPlugin._secrets_cache.put(self._secret_key, self._secret, time.perf_counter_ns() + token_expiration_ns) |
Contributor
Author
There was a problem hiding this comment.
Put already adds the time.perf_counter_ns()
def put(self, key: K, item: V, item_expiration_ns: int): self._cache[key] = CacheItem(item, time.perf_counter_ns() + item_expiration_ns) self._cleanup()
59dfd8b to
06c9894
Compare
# Conflicts: # docs/using-the-python-driver/using-plugins/UsingTheAwsSecretsManagerPlugin.md
06c9894 to
2df14d5
Compare
karenc-bq
approved these changes
Jun 23, 2025
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.
Description
The secrets manager plugin currently stores secrets with no expiry time. Users should be able to specify the amount of time a secret stays in the wrapper's cache.
Manually tested with secret cache.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.