diff --git a/filebeat/beater/filebeat.go b/filebeat/beater/filebeat.go index 272b36d5212..815b6fabfde 100644 --- a/filebeat/beater/filebeat.go +++ b/filebeat/beater/filebeat.go @@ -196,7 +196,7 @@ func (fb *Filebeat) setupPipelineLoaderCallback(b *beat.Beat) error { overwritePipelines := true b.OverwritePipelinesCallback = func(esConfig *conf.C) error { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(context.TODO()) defer cancel() esClient, err := eslegclient.NewConnectedClient(ctx, esConfig, "Filebeat") if err != nil { diff --git a/heartbeat/beater/heartbeat.go b/heartbeat/beater/heartbeat.go index 91508dcef75..e22503ed741 100644 --- a/heartbeat/beater/heartbeat.go +++ b/heartbeat/beater/heartbeat.go @@ -88,11 +88,7 @@ func New(b *beat.Beat, rawConfig *conf.C) (beat.Beater, error) { if b.Config.Output.Name() == "elasticsearch" && !b.Manager.Enabled() { // Connect to ES and setup the State loader if the output is not managed by agent // Note this, intentionally, blocks until connected or max attempts reached - // TODO(Tiago): I believe this cannot be cancelled here, but all tests are passing - // so I need to fund out the correct life cycle for this connection/context - ctx, cancel := context.WithCancel(context.TODO()) - defer cancel() - esClient, err := makeESClient(ctx, b.Config.Output.Config(), 3, 2*time.Second) + esClient, err := makeESClient(context.TODO(), b.Config.Output.Config(), 3, 2*time.Second) if err != nil { if parsedConfig.RunOnce { trace.Abort()