Skip to content

Commit

Permalink
Merge branch 'alertmanager-controller' into alertmanager-test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoBrigitte committed Dec 17, 2024
2 parents 3b67a41 + 5ee639c commit 186477a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/controller/alertmanager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func SetupAlertmanagerReconciler(mgr ctrl.Manager, conf config.Config) error {

// Setup the controller
return ctrl.NewControllerManagedBy(mgr).
Named("alertmanager").
For(&v1.Secret{}, builder.WithPredicates(secretPredicate)).
Watches(&v1.Pod{}, p, builder.WithPredicates(podPredicate)).
Complete(r)
Expand Down
4 changes: 3 additions & 1 deletion pkg/alertmanager/alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ func (s Service) Configure(ctx context.Context, secret *v1.Secret) error {
}

// configure sends the configuration and templates to Mimir Alertmanager's API
// It is the caller responsibility to make sure templates names are valid (do not contain any path), and that templates are referenced in the configuration.
// https://grafana.com/docs/mimir/latest/references/http-api/#set-alertmanager-configuration
func (s Service) configure(ctx context.Context, alertmanagerConfigContent []byte, templates map[string]string, tenantID string) error {
logger := log.FromContext(ctx)

// Load alertmanager configuration
// Validate Alertmanager configuration
// The returned config is not used, as transforming it via String() would produce an invalid configuration with all secrets replaced with <redacted>.
_, err := config.Load(string(alertmanagerConfigContent))
if err != nil {
return errors.WithStack(fmt.Errorf("alertmanager: failed to load configuration: %w", err))
Expand Down

0 comments on commit 186477a

Please sign in to comment.