Skip to content

Commit

Permalink
Notifier: don't reuse payload after relabeling
Browse files Browse the repository at this point in the history
Also clarify why these variables are being cleared.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
  • Loading branch information
bboreham committed Mar 8, 2024
1 parent c8d31eb commit df6ff4e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions notifier/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,11 @@ func (n *Manager) sendAll(alerts ...*Alert) bool {

if len(ams.cfg.AlertRelabelConfigs) > 0 {
amAlerts = relabelAlerts(ams.cfg.AlertRelabelConfigs, labels.Labels{}, alerts)
// TODO(nabokihms): figure out the right way to cache marshalled alerts.
// Now it works well only for happy cases.
v1Payload = nil
v2Payload = nil

if len(amAlerts) == 0 {
continue
}
// We can't use the cached values from previous iteration.
v1Payload, v2Payload = nil, nil
}

switch ams.cfg.APIVersion {
Expand Down Expand Up @@ -531,6 +528,11 @@ func (n *Manager) sendAll(alerts ...*Alert) bool {
}
}

if len(ams.cfg.AlertRelabelConfigs) > 0 {
// We can't use the cached values on the next iteration.
v1Payload, v2Payload = nil, nil
}

for _, am := range ams.ams {
wg.Add(1)

Expand Down

0 comments on commit df6ff4e

Please sign in to comment.