Alerting: Use background context for maintenance function (#64065)

This commit is contained in:
Yuri Tseretyan 2023-03-02 14:19:52 -05:00 committed by GitHub
parent e9ed76722d
commit e760f22402
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,7 +103,8 @@ func newAlertmanager(ctx context.Context, orgID int64, cfg *setting.Cfg, store A
retention: retentionNotificationsAndSilences,
maintenanceFrequency: silenceMaintenanceInterval,
maintenanceFunc: func(state alertingNotify.State) (int64, error) {
return fileStore.Persist(ctx, silencesFilename, state)
// Detached context here is to make sure that when the service is shut down the persist operation is executed.
return fileStore.Persist(context.Background(), silencesFilename, state)
},
}
@ -112,7 +113,8 @@ func newAlertmanager(ctx context.Context, orgID int64, cfg *setting.Cfg, store A
retention: retentionNotificationsAndSilences,
maintenanceFrequency: notificationLogMaintenanceInterval,
maintenanceFunc: func(state alertingNotify.State) (int64, error) {
return fileStore.Persist(ctx, notificationLogFilename, state)
// Detached context here is to make sure that when the service is shut down the persist operation is executed.
return fileStore.Persist(context.Background(), notificationLogFilename, state)
},
}