Alerting: Fix data races and improve testing (#81994)

* Alerting: fix race condition in (*ngalert/sender.ExternalAlertmanager).Run

* Chore: Fix data races when accessing members of *ngalert/state.FakeInstanceStore

* Chore: Fix data races in tests in ngalert/schedule and enable some parallel tests

* Chore: fix linters

* Chore: add TODO comment to remove loopvar once we move to Go 1.22
This commit is contained in:
Diego Augusto Molina
2024-02-14 12:45:39 -03:00
committed by GitHub
parent 06b5875c3c
commit 9c29e1a783
7 changed files with 198 additions and 73 deletions

View File

@@ -127,13 +127,14 @@ func (s *ExternalAlertmanager) ApplyConfig(orgId, id int64, alertmanagers []Exte
}
func (s *ExternalAlertmanager) Run() {
logger := s.logger
s.wg.Add(2)
go func() {
s.logger.Info("Initiating communication with a group of external Alertmanagers")
logger.Info("Initiating communication with a group of external Alertmanagers")
if err := s.sdManager.Run(); err != nil {
s.logger.Error("Failed to start the sender service discovery manager", "error", err)
logger.Error("Failed to start the sender service discovery manager", "error", err)
}
s.wg.Done()
}()