pkg/services: Check errors (#19712)

* pkg/services: Check errors
* pkg/services: Don't treat context.Canceled|context.DeadlineExceeded as error
This commit is contained in:
Arve Knudsen
2019-10-22 14:08:18 +02:00
committed by GitHub
parent de5038441f
commit 2a78d2a61c
37 changed files with 431 additions and 191 deletions
+11 -1
View File
@@ -15,6 +15,7 @@ import (
"github.com/grafana/grafana/pkg/services/rendering"
"github.com/grafana/grafana/pkg/setting"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
)
// AlertEngine is the background process that
@@ -210,7 +211,16 @@ func (e *AlertEngine) processJob(attemptID int, attemptChan chan int, cancelChan
// dont reuse the evalContext and get its own context.
evalContext.Ctx = resultHandleCtx
evalContext.Rule.State = evalContext.GetNewState()
e.resultHandler.handle(evalContext)
if err := e.resultHandler.handle(evalContext); err != nil {
if xerrors.Is(err, context.Canceled) {
e.log.Debug("Result handler returned context.Canceled")
} else if xerrors.Is(err, context.DeadlineExceeded) {
e.log.Debug("Result handler returned context.DeadlineExceeded")
} else {
e.log.Error("Failed to handle result", "err", err)
}
}
span.Finish()
e.log.Debug("Job Execution completed", "timeMs", evalContext.GetDurationMs(), "alertId", evalContext.Rule.ID, "name", evalContext.Rule.Name, "firing", evalContext.Firing, "attemptID", attemptID)
close(attemptChan)