From 90521a65f8d74652c9ef565563b759762a5c3f03 Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Sat, 4 Aug 2018 21:31:12 +0200 Subject: [PATCH] Remove error return value from NotifyFunc() (#4459) It's always nil and we also forgot to check it. Signed-off-by: Julius Volz --- cmd/prometheus/main.go | 3 +-- rules/manager.go | 2 +- rules/manager_test.go | 14 ++++++-------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index fe3b78f0c..440dcd441 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -682,7 +682,7 @@ func computeExternalURL(u, listenAddr string) (*url.URL, error) { // sendAlerts implements the rules.NotifyFunc for a Notifier. // It filters any non-firing alerts from the input. func sendAlerts(n *notifier.Manager, externalURL string) rules.NotifyFunc { - return func(ctx context.Context, expr string, alerts ...*rules.Alert) error { + return func(ctx context.Context, expr string, alerts ...*rules.Alert) { var res []*notifier.Alert for _, alert := range alerts { @@ -705,6 +705,5 @@ func sendAlerts(n *notifier.Manager, externalURL string) rules.NotifyFunc { if len(alerts) > 0 { n.Send(res...) } - return nil } } diff --git a/rules/manager.go b/rules/manager.go index ad78704c0..efb2c8b93 100644 --- a/rules/manager.go +++ b/rules/manager.go @@ -573,7 +573,7 @@ type Appendable interface { } // NotifyFunc sends notifications about a set of alerts generated by the given expression. -type NotifyFunc func(ctx context.Context, expr string, alerts ...*Alert) error +type NotifyFunc func(ctx context.Context, expr string, alerts ...*Alert) // ManagerOptions bundles options for the Manager. type ManagerOptions struct { diff --git a/rules/manager_test.go b/rules/manager_test.go index 89a1620c5..9b46d1a51 100644 --- a/rules/manager_test.go +++ b/rules/manager_test.go @@ -343,14 +343,12 @@ func TestForStateRestore(t *testing.T) { testutil.Ok(t, err) opts := &ManagerOptions{ - QueryFunc: EngineQueryFunc(suite.QueryEngine(), suite.Storage()), - Appendable: suite.Storage(), - TSDB: suite.Storage(), - Context: context.Background(), - Logger: log.NewNopLogger(), - NotifyFunc: func(ctx context.Context, expr string, alerts ...*Alert) error { - return nil - }, + QueryFunc: EngineQueryFunc(suite.QueryEngine(), suite.Storage()), + Appendable: suite.Storage(), + TSDB: suite.Storage(), + Context: context.Background(), + Logger: log.NewNopLogger(), + NotifyFunc: func(ctx context.Context, expr string, alerts ...*Alert) {}, OutageTolerance: 30 * time.Minute, ForGracePeriod: 10 * time.Minute, }