Chore: Drop xerrors dependency (#26718)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package alerting
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -16,7 +17,6 @@ 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
|
||||
@@ -215,9 +215,9 @@ func (e *AlertEngine) processJob(attemptID int, attemptChan chan int, cancelChan
|
||||
evalContext.Rule.State = evalContext.GetNewState()
|
||||
if err := e.resultHandler.handle(evalContext); err != nil {
|
||||
switch {
|
||||
case xerrors.Is(err, context.Canceled):
|
||||
case errors.Is(err, context.Canceled):
|
||||
e.log.Debug("Result handler returned context.Canceled")
|
||||
case xerrors.Is(err, context.DeadlineExceeded):
|
||||
case errors.Is(err, context.DeadlineExceeded):
|
||||
e.log.Debug("Result handler returned context.DeadlineExceeded")
|
||||
default:
|
||||
e.log.Error("Failed to handle result", "err", err)
|
||||
|
||||
@@ -271,7 +271,7 @@ func TestAlertRuleExtraction(t *testing.T) {
|
||||
|
||||
Convey("Should fail on save", func() {
|
||||
_, err := extractor.GetAlerts()
|
||||
So(err.Error(), ShouldEqual, "Alert validation error: Panel id is not correct, alertName=Influxdb, panelId=1")
|
||||
So(err.Error(), ShouldEqual, "alert validation error: Panel id is not correct, alertName=Influxdb, panelId=1")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestSlackNotifier(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err = NewSlackNotifier(model)
|
||||
So(err, ShouldBeError, "Alert validation error: Could not find url property in settings")
|
||||
So(err, ShouldBeError, "alert validation error: Could not find url property in settings")
|
||||
})
|
||||
|
||||
//nolint:goconst
|
||||
@@ -157,7 +157,7 @@ func TestSlackNotifier(t *testing.T) {
|
||||
|
||||
_, err = NewSlackNotifier(model)
|
||||
|
||||
So(err, ShouldBeError, "Alert validation error: Recipient on invalid format: \"#open tsdb\"")
|
||||
So(err, ShouldBeError, "alert validation error: Recipient on invalid format: \"#open tsdb\"")
|
||||
})
|
||||
|
||||
Convey("with user recipient with spaces should return an error", func() {
|
||||
@@ -177,7 +177,7 @@ func TestSlackNotifier(t *testing.T) {
|
||||
|
||||
_, err = NewSlackNotifier(model)
|
||||
|
||||
So(err, ShouldBeError, "Alert validation error: Recipient on invalid format: \"@user name\"")
|
||||
So(err, ShouldBeError, "alert validation error: Recipient on invalid format: \"@user name\"")
|
||||
})
|
||||
|
||||
Convey("with user recipient with uppercase letters should return an error", func() {
|
||||
@@ -197,7 +197,7 @@ func TestSlackNotifier(t *testing.T) {
|
||||
|
||||
_, err = NewSlackNotifier(model)
|
||||
|
||||
So(err, ShouldBeError, "Alert validation error: Recipient on invalid format: \"@User\"")
|
||||
So(err, ShouldBeError, "alert validation error: Recipient on invalid format: \"@User\"")
|
||||
})
|
||||
|
||||
Convey("with Slack ID for recipient should work", func() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package alerting
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
@@ -9,7 +10,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/annotations"
|
||||
"github.com/grafana/grafana/pkg/services/rendering"
|
||||
@@ -101,9 +101,9 @@ func (handler *defaultResultHandler) handle(evalContext *EvalContext) error {
|
||||
|
||||
if err := handler.notifier.SendIfNeeded(evalContext); err != nil {
|
||||
switch {
|
||||
case xerrors.Is(err, context.Canceled):
|
||||
case errors.Is(err, context.Canceled):
|
||||
handler.log.Debug("handler.notifier.SendIfNeeded returned context.Canceled")
|
||||
case xerrors.Is(err, context.DeadlineExceeded):
|
||||
case errors.Is(err, context.DeadlineExceeded):
|
||||
handler.log.Debug("handler.notifier.SendIfNeeded returned context.DeadlineExceeded")
|
||||
default:
|
||||
handler.log.Error("handler.notifier.SendIfNeeded failed", "err", err)
|
||||
|
||||
@@ -66,10 +66,10 @@ func (e ValidationError) Error() string {
|
||||
}
|
||||
|
||||
if e.Err != nil {
|
||||
return fmt.Sprintf("Alert validation error: %s%s", e.Err.Error(), extraInfo)
|
||||
return fmt.Sprintf("alert validation error: %s%s", e.Err.Error(), extraInfo)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("Alert validation error: %s", extraInfo)
|
||||
return fmt.Sprintf("alert validation error: %s", extraInfo)
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -215,7 +215,7 @@ func TestAlertRuleModel(t *testing.T) {
|
||||
|
||||
_, err := NewRuleFromDBAlert(alert)
|
||||
So(err, ShouldNotBeNil)
|
||||
So(err.Error(), ShouldEqual, "Alert validation error: Neither id nor uid is specified in 'notifications' block, type assertion to string failed AlertId: 1 PanelId: 1 DashboardId: 1")
|
||||
So(err.Error(), ShouldEqual, "alert validation error: Neither id nor uid is specified in 'notifications' block, type assertion to string failed AlertId: 1 PanelId: 1 DashboardId: 1")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user