Refactor inhibit stage (#1105)

* Refactor BuildPipeline to receive a muter

* Remove marker not used by InhibitStage
This commit is contained in:
Jose Donizetti 2017-12-14 13:22:31 -02:00 committed by stuart nelson
parent 50394569f5
commit d75ff37a38
2 changed files with 5 additions and 14 deletions

View File

@ -28,7 +28,6 @@ import (
"golang.org/x/net/context"
"github.com/prometheus/alertmanager/config"
"github.com/prometheus/alertmanager/inhibit"
"github.com/prometheus/alertmanager/nflog"
"github.com/prometheus/alertmanager/nflog/nflogpb"
"github.com/prometheus/alertmanager/silence"
@ -210,7 +209,7 @@ func BuildPipeline(
confs []*config.Receiver,
tmpl *template.Template,
wait func() time.Duration,
inhibitor *inhibit.Inhibitor,
muter types.Muter,
silences *silence.Silences,
notificationLog nflog.Log,
marker types.Marker,
@ -218,7 +217,7 @@ func BuildPipeline(
) RoutingStage {
rs := RoutingStage{}
is := NewInhibitStage(inhibitor, marker)
is := NewInhibitStage(muter)
ss := NewSilenceStage(silences, marker)
for _, rc := range confs {
@ -321,11 +320,8 @@ type InhibitStage struct {
}
// NewInhibitStage return a new InhibitStage.
func NewInhibitStage(m types.Muter, mk types.Marker) *InhibitStage {
return &InhibitStage{
muter: m,
marker: mk,
}
func NewInhibitStage(m types.Muter) *InhibitStage {
return &InhibitStage{muter: m}
}
// Exec implements the Stage interface.

View File

@ -494,8 +494,7 @@ func TestInhibitStage(t *testing.T) {
return ok
})
marker := types.NewMarker()
inhibitor := NewInhibitStage(muter, marker)
inhibitor := NewInhibitStage(muter)
in := []model.LabelSet{
{},
@ -521,10 +520,6 @@ func TestInhibitStage(t *testing.T) {
})
}
// Set the second alert as previously inhibited. It is expected to have
// the WasInhibited flag set to true afterwards.
marker.SetInhibited(inAlerts[1].Fingerprint(), "123")
_, alerts, err := inhibitor.Exec(nil, log.NewNopLogger(), inAlerts...)
if err != nil {
t.Fatalf("Exec failed: %s", err)