From f3502a3e4e53c4e44ff592c39c2419a23d22efae Mon Sep 17 00:00:00 2001 From: Tiago Queiroz Date: Fri, 18 Oct 2024 11:57:14 -0400 Subject: [PATCH] Address PR comments --- filebeat/beater/filebeat.go | 2 +- heartbeat/beater/heartbeat.go | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) 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()