Skip to content

Commit 324b006

Browse files
committed
feat(alerting): dont allow alert responses to cancel
1 parent 0d86b82 commit 324b006

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

pkg/services/alerting/engine.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,22 @@ func (e *Engine) processJob(grafanaCtx context.Context, job *Job) error {
9595

9696
job.Running = true
9797
evalContext := NewEvalContext(grafanaCtx, job.Rule)
98-
e.evalHandler.Eval(evalContext)
99-
e.resultHandler.Handle(evalContext)
100-
e.log.Debug("Job Execution completed", "timeMs", evalContext.GetDurationMs(), "alertId", evalContext.Rule.Id, "name", evalContext.Rule.Name, "firing", evalContext.Firing)
98+
evalDone := make(chan struct{})
99+
100+
go func() {
101+
e.evalHandler.Eval(evalContext)
102+
close(evalDone)
103+
}()
101104

105+
var err error = nil
106+
select {
107+
case <-grafanaCtx.Done():
108+
err = grafanaCtx.Err()
109+
case <-evalDone:
110+
err = e.resultHandler.Handle(evalContext)
111+
}
112+
113+
e.log.Debug("Job Execution completed", "timeMs", evalContext.GetDurationMs(), "alertId", evalContext.Rule.Id, "name", evalContext.Rule.Name, "firing", evalContext.Firing)
102114
job.Running = false
103-
return evalContext.Error
115+
return err
104116
}

0 commit comments

Comments
 (0)