From 7b781e4c3c6490211e7b731ea0567cb18d0011a7 Mon Sep 17 00:00:00 2001 From: bergquist Date: Tue, 2 Oct 2018 14:53:39 +0200 Subject: [PATCH] use notification state id instead of notifier id --- pkg/services/alerting/notifier.go | 6 +++--- pkg/services/sqlstore/alert_notification.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/services/alerting/notifier.go b/pkg/services/alerting/notifier.go index 0f3290c0dbe..9ce50eadd6b 100644 --- a/pkg/services/alerting/notifier.go +++ b/pkg/services/alerting/notifier.go @@ -74,7 +74,7 @@ func (n *notificationService) sendAndMarkAsComplete(evalContext *EvalContext, no } cmd := &m.SetAlertNotificationStateToCompleteCommand{ - Id: notifier.GetNotifierId(), + Id: notifierState.state.Id, Version: notifierState.state.Version, } @@ -84,7 +84,7 @@ func (n *notificationService) sendAndMarkAsComplete(evalContext *EvalContext, no func (n *notificationService) sendNotification(evalContext *EvalContext, notifierState *notifierState) error { if !evalContext.IsTestRun { setPendingCmd := &m.SetAlertNotificationStateToPendingCommand{ - Id: notifierState.state.NotifierId, + Id: notifierState.state.Id, Version: notifierState.state.Version, AlertRuleStateUpdatedVersion: evalContext.Rule.StateChanges, } @@ -110,7 +110,7 @@ func (n *notificationService) sendNotifications(evalContext *EvalContext, notifi for _, notifierState := range notifierStates { err := n.sendNotification(evalContext, notifierState) if err != nil { - n.log.Error("failed to send notification", "id", notifierState.notifier.GetNotifierId()) + n.log.Error("failed to send notification", "id", notifierState.notifier.GetNotifierId(), "error", err) } } diff --git a/pkg/services/sqlstore/alert_notification.go b/pkg/services/sqlstore/alert_notification.go index 8815f4c4bd7..665b4b0cd0a 100644 --- a/pkg/services/sqlstore/alert_notification.go +++ b/pkg/services/sqlstore/alert_notification.go @@ -238,7 +238,7 @@ func UpdateAlertNotification(cmd *m.UpdateAlertNotificationCommand) error { } func SetAlertNotificationStateToCompleteCommand(ctx context.Context, cmd *m.SetAlertNotificationStateToCompleteCommand) error { - return withDbSession(ctx, func(sess *DBSession) error { + return inTransactionCtx(ctx, func(sess *DBSession) error { version := cmd.Version var current m.AlertNotificationState sess.ID(cmd.Id).Get(¤t)