Skip to content

Commit f440a21

Browse files
authored
Update process-agent shouldStayAlive check in Kubernetes environments (#48031)
### What does this PR do? Reduces the scope of `shouldStayAlive` so that only Linux on K8s could be affected using the `coreagent.ProcessChecksRunInCoreAgent` function which only returns true on Linux. In theory, this function shouldn't even be reached in a Windows K8s scenario since the process-agent container will be deployed any relevant check (NPM/Process). However, it seems appropriate to reduce potential scope since if this occurs, it signals a bigger problem since the checks won't run anywhere else. ### Motivation Do not potentially keep agents on Windows K8s alive. ### Describe how you validated your changes e2e ### Additional Notes Co-authored-by: daniel.tafoya <daniel.tafoya@datadoghq.com>
1 parent 42c79d3 commit f440a21

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cmd/process-agent/command/main_common.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import (
6565
"github.com/DataDog/datadog-agent/pkg/process/metadata/workloadmeta/collector"
6666
"github.com/DataDog/datadog-agent/pkg/process/util"
6767
proccontainers "github.com/DataDog/datadog-agent/pkg/process/util/containers"
68+
"github.com/DataDog/datadog-agent/pkg/process/util/coreagent"
6869
"github.com/DataDog/datadog-agent/pkg/util/coredump"
6970
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
7071
"github.com/DataDog/datadog-agent/pkg/util/log"
@@ -323,7 +324,7 @@ func initMisc(deps miscDeps) error {
323324
// TODO: remove this once the Helm chart no longer deploys the process-agent container when
324325
// runInCoreAgent is enabled (the chart's doNotCheckTag logic prevents automatic detection).
325326
func shouldStayAlive() bool {
326-
if env.IsKubernetes() {
327+
if env.IsKubernetes() && coreagent.ProcessChecksRunInCoreAgent() {
327328
log.Error("The process-agent is idle: process checks run in the core agent. Update your Helm chart or Datadog Operator to the latest version to prevent this (https://docs.datadoghq.com/containers/kubernetes/installation/).")
328329
return true
329330
}

0 commit comments

Comments
 (0)