[v11.1.x] Alerting: Make context deadline on AlertNG service startup configurable (#96132)
Alerting: Make context deadline on AlertNG service startup configurable (#96053)
* Make alerting context deadline configurable
* Remove debug logs
* Change default timeout
* Update tests
(cherry picked from commit 1fdc48faba)
This commit is contained in:
@@ -151,7 +151,7 @@ type AlertNG struct {
|
||||
|
||||
func (ng *AlertNG) init() error {
|
||||
// AlertNG should be initialized before the cancellation deadline of initCtx
|
||||
initCtx, cancelFunc := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
initCtx, cancelFunc := context.WithTimeout(context.Background(), ng.Cfg.UnifiedAlerting.InitializationTimeout)
|
||||
defer cancelFunc()
|
||||
|
||||
ng.store.Logger = ng.Log
|
||||
|
||||
@@ -45,7 +45,8 @@ func SetupTestEnv(tb testing.TB, baseInterval time.Duration) (*ngalert.AlertNG,
|
||||
|
||||
cfg := setting.NewCfg()
|
||||
cfg.UnifiedAlerting = setting.UnifiedAlertingSettings{
|
||||
BaseInterval: setting.SchedulerBaseInterval,
|
||||
BaseInterval: setting.SchedulerBaseInterval,
|
||||
InitializationTimeout: 30 * time.Second,
|
||||
}
|
||||
// AlertNG database migrations run and the relative database tables are created only when it's enabled
|
||||
cfg.UnifiedAlerting.Enabled = new(bool)
|
||||
|
||||
@@ -496,6 +496,7 @@ func setupEnv(t *testing.T, sqlStore db.DB, cfg *setting.Cfg, b bus.Bus, quotaSe
|
||||
ac := acimpl.ProvideAccessControl(featuremgmt.WithFeatures())
|
||||
ruleStore, err := ngstore.ProvideDBStore(cfg, featuremgmt.WithFeatures(), sqlStore, &foldertest.FakeService{}, &dashboards.FakeDashboardService{}, ac)
|
||||
require.NoError(t, err)
|
||||
cfg.UnifiedAlerting.InitializationTimeout = 30 * time.Second
|
||||
_, err = ngalert.ProvideService(
|
||||
cfg, featuremgmt.WithFeatures(), nil, nil, routing.NewRouteRegister(), sqlStore, ngalertfakes.NewFakeKVStore(t), nil, nil, quotaService,
|
||||
secretsService, nil, m, &foldertest.FakeService{}, &acmock.Mock{}, &dashboards.FakeDashboardService{}, nil, b, &acmock.Mock{},
|
||||
|
||||
Reference in New Issue
Block a user