Remote Alertmanager: Pass the sync.WaitGroup to the goroutine as an argument

This commit is contained in:
Santiago Hernández 2025-10-07 15:26:08 +02:00
parent ee4532925b
commit bd6733a1b7
1 changed files with 2 additions and 2 deletions

View File

@ -131,7 +131,7 @@ func (fam *RemoteSecondaryForkedAlertmanager) ApplyConfig(ctx context.Context, c
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
// Figure out if we need to sync the external Alertmanager in another goroutine. // Figure out if we need to sync the external Alertmanager in another goroutine.
go func() { go func(wg sync.WaitGroup) {
defer wg.Done() defer wg.Done()
// If the Alertmanager has not been marked as "ready" yet, delegate the call to the remote Alertmanager. // If the Alertmanager has not been marked as "ready" yet, delegate the call to the remote Alertmanager.
// This will perform a readiness check and sync the Alertmanagers. // This will perform a readiness check and sync the Alertmanagers.
@ -154,7 +154,7 @@ func (fam *RemoteSecondaryForkedAlertmanager) ApplyConfig(ctx context.Context, c
} }
fam.log.Debug("Finished syncing configuration with the remote Alertmanager") fam.log.Debug("Finished syncing configuration with the remote Alertmanager")
} }
}() }(wg)
if fam.shouldFetchRemoteState { if fam.shouldFetchRemoteState {
wg.Wait() wg.Wait()