Skip to content

Commit b27860f

Browse files
authored
[ADP] gate data_plane.enabled to Linux at config load time (#50151)
## Summary ADP (Agent Data Plane) is Linux-only, but `data_plane.enabled: true` was silently ignored on Windows and macOS with no feedback to the user. This PR adds a platform gate in the config loading path that emits a warning and resets `data_plane.enabled` to false on non-Linux platforms, ensuring every downstream consumer (dogstatsd ADP path, OTLP proxy) automatically sees the correct value without per-site guards. Follows up on review feedback from #49891. No changelog entry since ADP still is a "hidden feature". ## Test plan - [x] `dda inv test --targets=./pkg/config/setup/...` passes (291 tests) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: jesse.szwedko <[email protected]>
1 parent 7d29ffb commit b27860f

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

pkg/config/setup/config.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"net"
1515
"os"
1616
"path/filepath"
17+
"runtime"
1718
"slices"
1819
"strconv"
1920
"strings"
@@ -682,6 +683,7 @@ func LoadDatadog(config pkgconfigmodel.Config, secretResolver secrets.Component,
682683

683684
sanitizeAPIKeyConfig(config, "api_key")
684685
sanitizeAPIKeyConfig(config, "logs_config.api_key")
686+
sanitizeDataPlaneConfig(config, runtime.GOOS)
685687
setNumWorkers(config)
686688

687689
flareStrippedKeys := config.GetStringSlice("flare_stripped_keys")
@@ -1185,6 +1187,25 @@ func sanitizeAPIKeyConfig(config pkgconfigmodel.Config, key string) {
11851187
config.Set(key, trimmed, pkgconfigmodel.SourceAgentRuntime)
11861188
}
11871189

1190+
// sanitizeDataPlaneConfig gates data_plane.enabled to Linux only.
1191+
// The Agent Data Plane (ADP) is a Linux-only component. On non-Linux platforms
1192+
// this function always installs a SourceAgentRuntime override of false, which
1193+
// beats file and fleet-policy sources and prevents them from re-enabling ADP
1194+
// after this call returns. A warning is emitted only when the value was
1195+
// explicitly set to true at call time.
1196+
//
1197+
// The goos parameter is the target OS string (normally runtime.GOOS). It is
1198+
// exposed as a parameter so that tests can exercise both branches without
1199+
// needing to cross-compile.
1200+
func sanitizeDataPlaneConfig(config pkgconfigmodel.Config, goos string) {
1201+
if goos != "linux" {
1202+
if config.GetBool(DataPlaneEnabled) {
1203+
log.Warnf("%s is not supported on %s and will be ignored", DataPlaneEnabled, goos)
1204+
}
1205+
config.Set(DataPlaneEnabled, false, pkgconfigmodel.SourceAgentRuntime)
1206+
}
1207+
}
1208+
11881209
// sanitizeExternalMetricsProviderChunkSize ensures the value of `external_metrics_provider.chunk_size` is within an acceptable range
11891210
func sanitizeExternalMetricsProviderChunkSize(config pkgconfigmodel.Config) {
11901211
if !config.IsKnown("external_metrics_provider.chunk_size") {

pkg/config/setup/config_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,3 +1534,63 @@ func TestLoadProxyFromEnv(t *testing.T) {
15341534
assert.Equal(t, "http://www.example.com/", cfg.Get("proxy.http"))
15351535
assert.Equal(t, pkgconfigmodel.SourceConfigPostInit, cfg.GetSource("proxy.http"))
15361536
}
1537+
1538+
func TestSanitizeDataPlaneConfig(t *testing.T) {
1539+
tests := []struct {
1540+
name string
1541+
goos string
1542+
initialValue bool
1543+
wantValue bool
1544+
wantSource pkgconfigmodel.Source
1545+
}{
1546+
{
1547+
name: "linux preserves true",
1548+
goos: "linux",
1549+
initialValue: true,
1550+
wantValue: true,
1551+
wantSource: pkgconfigmodel.SourceFile,
1552+
},
1553+
{
1554+
name: "windows resets true to false",
1555+
goos: "windows",
1556+
initialValue: true,
1557+
wantValue: false,
1558+
wantSource: pkgconfigmodel.SourceAgentRuntime,
1559+
},
1560+
{
1561+
name: "darwin resets true to false",
1562+
goos: "darwin",
1563+
initialValue: true,
1564+
wantValue: false,
1565+
wantSource: pkgconfigmodel.SourceAgentRuntime,
1566+
},
1567+
{
1568+
// Even when already false, non-Linux writes SourceAgentRuntime so that
1569+
// lower-priority sources (e.g. fleet policies) cannot re-enable ADP later.
1570+
name: "windows locks false via SourceAgentRuntime",
1571+
goos: "windows",
1572+
initialValue: false,
1573+
wantValue: false,
1574+
wantSource: pkgconfigmodel.SourceAgentRuntime,
1575+
},
1576+
{
1577+
name: "darwin locks false via SourceAgentRuntime",
1578+
goos: "darwin",
1579+
initialValue: false,
1580+
wantValue: false,
1581+
wantSource: pkgconfigmodel.SourceAgentRuntime,
1582+
},
1583+
}
1584+
1585+
for _, tt := range tests {
1586+
t.Run(tt.name, func(t *testing.T) {
1587+
cfg := newTestConf(t)
1588+
cfg.Set("data_plane.enabled", tt.initialValue, pkgconfigmodel.SourceFile)
1589+
1590+
sanitizeDataPlaneConfig(cfg, tt.goos)
1591+
1592+
assert.Equal(t, tt.wantValue, cfg.GetBool("data_plane.enabled"))
1593+
assert.Equal(t, tt.wantSource, cfg.GetSource("data_plane.enabled"))
1594+
})
1595+
}
1596+
}

0 commit comments

Comments
 (0)