From 199e77affa785ea8e64690bca27917c9242b7b4e Mon Sep 17 00:00:00 2001 From: Olivier G <52180542+ogaca-dd@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:07:39 +0100 Subject: [PATCH] [OTEL-2181] Set a specific default timeout value when getting the flare for OTEL (#31388) --- comp/otelcol/collector/impl-pipeline/pipeline.go | 6 ++++-- pkg/config/setup/config.go | 1 + test/new-e2e/tests/otel/utils/config_utils.go | 2 -- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/comp/otelcol/collector/impl-pipeline/pipeline.go b/comp/otelcol/collector/impl-pipeline/pipeline.go index a0f72266efb8a..e3e2d89e2f87f 100644 --- a/comp/otelcol/collector/impl-pipeline/pipeline.go +++ b/comp/otelcol/collector/impl-pipeline/pipeline.go @@ -151,10 +151,12 @@ func NewComponent(reqs Requires) (Provides, error) { OnStart: collector.start, OnStop: collector.stop, }) - + timeoutCallback := func(flaretypes.FlareBuilder) time.Duration { + return time.Second * time.Duration(reqs.Config.GetInt("otelcollector.flare.timeout")) + } return Provides{ Comp: collector, - FlareProvider: flaretypes.NewProvider(collector.fillFlare), + FlareProvider: flaretypes.NewProviderWithTimeout(collector.fillFlare, timeoutCallback), StatusProvider: status.NewInformationProvider(collector), }, nil } diff --git a/pkg/config/setup/config.go b/pkg/config/setup/config.go index 5690289442f25..cb222ce628e73 100644 --- a/pkg/config/setup/config.go +++ b/pkg/config/setup/config.go @@ -879,6 +879,7 @@ func InitConfig(config pkgconfigmodel.Setup) { config.BindEnvAndSetDefault("otelcollector.extension_timeout", 0) // in seconds, 0 for default value config.BindEnvAndSetDefault("otelcollector.submit_dummy_metadata", false) // dev flag - to be removed config.BindEnvAndSetDefault("otelcollector.converter.enabled", true) + config.BindEnvAndSetDefault("otelcollector.flare.timeout", 60) // inventories config.BindEnvAndSetDefault("inventories_enabled", true) diff --git a/test/new-e2e/tests/otel/utils/config_utils.go b/test/new-e2e/tests/otel/utils/config_utils.go index a4daa89e3baa8..ddee2793648fa 100644 --- a/test/new-e2e/tests/otel/utils/config_utils.go +++ b/test/new-e2e/tests/otel/utils/config_utils.go @@ -21,7 +21,6 @@ import ( "k8s.io/apimachinery/pkg/fields" extension "github.com/DataDog/datadog-agent/comp/otelcol/ddflareextension/def" - "github.com/DataDog/datadog-agent/pkg/util/testutil/flake" "github.com/DataDog/datadog-agent/test/fakeintake/client/flare" ) @@ -105,7 +104,6 @@ func TestOTelFlareExtensionResponse(s OTelTestSuite, providedCfg string, fullCfg // TestOTelFlareFiles tests that the OTel Agent flares contain the expected files func TestOTelFlareFiles(s OTelTestSuite) { - flake.Mark(s.T()) err := s.Env().FakeIntake.Client().FlushServerAndResetAggregators() require.NoError(s.T(), err) agent := getAgentPod(s)