From 4f2eb48be971815c5332e80e3daaf7428202d4a4 Mon Sep 17 00:00:00 2001 From: Craig Peterson Date: Tue, 17 Nov 2015 15:20:41 -0700 Subject: [PATCH] fix last logic. Old abnormal events were getting confused with current ones. --- cmd/bosun/sched/check.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cmd/bosun/sched/check.go b/cmd/bosun/sched/check.go index 15d83cfb66..df20e48f48 100644 --- a/cmd/bosun/sched/check.go +++ b/cmd/bosun/sched/check.go @@ -167,9 +167,16 @@ func (s *Schedule) runHistory(r *RunHistory, ak models.AlertKey, event *Event, s } // add new event to state last := state.AbnormalStatus() + wasOpen := state.Open + // last could be StNone if it is new. Set it to normal if so because StNormal > + // StNone. If the state is not open (closed), then the last state we care about + // isn't the last abnormal state, it's just normal. + if last < StNormal || !wasOpen { + last = StNormal + } state.Append(event) a := s.Conf.Alerts[ak.Name()] - wasOpen := state.Open + // render templates and open alert key if abnormal if event.Status > StNormal { if event.Status >= last { @@ -230,12 +237,7 @@ func (s *Schedule) runHistory(r *RunHistory, ak models.AlertKey, event *Event, s } // lock while we change notifications. s.Lock("RunHistory") - // last could be StNone if it is new. Set it to normal if so because StNormal > - // StNone. If the state is not open (closed), then the last state we care about - // isn't the last abnormal state, it's just normal. - if last < StNormal || !wasOpen { - last = StNormal - } + if event.Status > last { clearOld() notifyCurrent()