From 7b74a22d9fb07d4b2834add5db0d0a0f9446a6db Mon Sep 17 00:00:00 2001 From: Maxime Riaud <65339037+misteriaud@users.noreply.github.com> Date: Mon, 16 Dec 2024 19:47:06 +0100 Subject: [PATCH] [ASCII-2585] Migrating ProcessAgent to use IPC cert (#31844) --- cmd/process-agent/subcommands/status/status.go | 3 +-- comp/process/apiserver/apiserver.go | 4 ++++ comp/process/apiserver/apiserver_test.go | 2 ++ comp/process/bundle_test.go | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/process-agent/subcommands/status/status.go b/cmd/process-agent/subcommands/status/status.go index 2660ee8fb71b4..8826c7547fb61 100644 --- a/cmd/process-agent/subcommands/status/status.go +++ b/cmd/process-agent/subcommands/status/status.go @@ -28,8 +28,6 @@ import ( "github.com/DataDog/datadog-agent/pkg/util/fxutil" ) -var httpClient = apiutil.GetClient(false) - const ( notRunning = ` ============= @@ -111,6 +109,7 @@ func writeError(log log.Component, w io.Writer, e error) { } func fetchStatus(statusURL string) ([]byte, error) { + httpClient := apiutil.GetClient(false) body, err := apiutil.DoGet(httpClient, statusURL, apiutil.LeaveConnectionOpen) if err != nil { return nil, status.NewConnectionError(err) diff --git a/comp/process/apiserver/apiserver.go b/comp/process/apiserver/apiserver.go index c216b2a93fef4..24bbe6353d06f 100644 --- a/comp/process/apiserver/apiserver.go +++ b/comp/process/apiserver/apiserver.go @@ -15,6 +15,7 @@ import ( "go.uber.org/fx" "github.com/DataDog/datadog-agent/cmd/process-agent/api" + "github.com/DataDog/datadog-agent/comp/api/authtoken" log "github.com/DataDog/datadog-agent/comp/core/log/def" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" ) @@ -32,6 +33,8 @@ type dependencies struct { Log log.Component + At authtoken.Component + APIServerDeps api.APIServerDeps } @@ -54,6 +57,7 @@ func newApiServer(deps dependencies) Component { ReadTimeout: timeout, WriteTimeout: timeout, IdleTimeout: timeout, + TLSConfig: deps.At.GetTLSServerConfig(), }, } diff --git a/comp/process/apiserver/apiserver_test.go b/comp/process/apiserver/apiserver_test.go index c9b0f4b96e92d..a0d94db4db4c2 100644 --- a/comp/process/apiserver/apiserver_test.go +++ b/comp/process/apiserver/apiserver_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/assert" "go.uber.org/fx" + "github.com/DataDog/datadog-agent/comp/api/authtoken/fetchonlyimpl" "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/settings/settingsimpl" "github.com/DataDog/datadog-agent/comp/core/status" @@ -39,6 +40,7 @@ func TestLifecycle(t *testing.T) { }), statusimpl.Module(), settingsimpl.MockModule(), + fetchonlyimpl.MockModule(), )) assert.Eventually(t, func() bool { diff --git a/comp/process/bundle_test.go b/comp/process/bundle_test.go index 591dce9f63cfb..9fb4131e013c0 100644 --- a/comp/process/bundle_test.go +++ b/comp/process/bundle_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/fx" + "github.com/DataDog/datadog-agent/comp/api/authtoken/fetchonlyimpl" "github.com/DataDog/datadog-agent/comp/core" configComp "github.com/DataDog/datadog-agent/comp/core/config" log "github.com/DataDog/datadog-agent/comp/core/log/def" @@ -60,6 +61,7 @@ func TestBundleDependencies(t *testing.T) { rdnsquerier.MockModule(), npcollectorimpl.MockModule(), statsd.MockModule(), + fetchonlyimpl.MockModule(), ) }