Replies: 1 comment
-
|
Related prometheus/prometheus#13955 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
DISCLAIMER this proposal is AI generated
1. Problem Statement
Currently, various notifiers (Email, WeChat, etc.) implement their own logic to retrieve secrets. When
*_fileconfiguration options are used (e.g.,smtp_auth_password_file), the standard implementation often usesos.ReadFiledirectly inside theNotifyloop.This leads to:
2. Proposed Solution
Introduce a
SecretFileProvider(orSecretCache) component. This component will be responsible for reading, caching, and watching files containing secrets.Location
I recommend placing this in a new package
pkg/secretsorutil/secretsto avoid circular dependencies with the config package, as config is imported by almost everyone.3. API Design
We define a strategy enum to handle the different use cases requested:
4. Implementation Details
The
GetLogicThe
GetStringmethod will function as follows:ReadOnceorFileWatch, return the cached value.os.ReadFile.StrategyFileWatch):fsnotifywatcher...datasymlink swaps common in Kubernetes Secrets, otherwisefsnotifymight lose track of the file after an atomic update.Thread Safety
Since
Notifycalls happen concurrently, the Provider must usesync.RWMutexto protect the internal cache map.5. Usage Example
Here is how the implementation in email.go would change.
Before:
After:
Assuming the
Emailstruct now holds a reference to the global or context-injectedSecretProvider:6. Lifecycle Management
The
SecretProvidershould ideally be initialized in main.go or thecoordinatorand passed down to thepipelineand subsequently to the Notifiers.When Alertmanager reloads its configuration:
SecretProvidercould be closed (stopping all watches).Beta Was this translation helpful? Give feedback.
All reactions