Commit f57e7a3
authored
[OTAGENT-1149] Fix standalone otel-agent remote-config/configsync guards leaking from env vars (#54485)
## Summary
- Standalone `otel-agent` (`DD_OTEL_STANDALONE=true`) disables `remote_configuration.enabled` at `SourceFile` priority, which is lower than `SourceEnvVar`. A deployment tool that colocates `otel-agent` with a core Datadog Agent — e.g. the Datadog Operator's DaemonSet path — injects `DD_REMOTE_CONFIGURATION_ENABLED=true` into every container including `otel-agent`, silently overriding the guard. This crashes the embedded trace agent's RC client at startup (exit 255: `could not instantiate the tracer remote config client: grpc client disabled via cmd_port: -1`), since standalone mode has already disabled the core-agent IPC (`cmd_port=-1`) the RC client would need.
- Raise the guard to `SourceAgentRuntime`, which outranks `SourceEnvVar`, so it can no longer be overridden by an injected env var.
- Apply the same treatment to configsync: force `agent_ipc.config_refresh_interval=0` under standalone mode, so a colocated core agent's `DD_AGENT_IPC_CONFIG_REFRESH_INTERVAL` env var can't make "standalone" `otel-agent` keep syncing config from a core agent it isn't supposed to depend on.
See [OTAGENT-1149](https://datadoghq.atlassian.net/browse/OTAGENT-1149) for the full investigation (verified end-to-end against the Datadog Operator in a kind cluster).
## Test plan
- [x] Added `TestStandaloneModeIgnoresCoreAgentIPCEnvVars` reproducing the env-var-leak scenario (`cmd/otel-agent/config/agent_config_test.go`)
- [x] `dda inv test --targets=./cmd/otel-agent/config/...` passes
- [x] `dda inv otel-agent.build` succeeds
- [x] Re-verified end-to-end against the Datadog Operator DaemonSet manifest from the ticket: built a local Linux/arm64 image with the fix, deployed via the Datadog Operator into a kind cluster with `remoteConfiguration.enabled: true` (the previously-crashing config), and confirmed `otel-agent` starts cleanly and stays up (0 restarts). Logs show `configsync disabled: agent_ipc.config_refresh_interval invalid: 0`, no RC-client crash, and the expected standalone boot sequence (`Starting dogtelextension in standalone mode`, tagger gRPC server on :15000), with OTLP receivers up and payloads posting successfully to the Datadog API.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
[OTAGENT-1149]: https://datadoghq.atlassian.net/browse/OTAGENT-1149?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Co-authored-by: yang.song <yang.song@datadoghq.com>1 parent b39d95d commit f57e7a3
4 files changed
Lines changed: 68 additions & 13 deletions
File tree
- cmd/otel-agent
- config
- subcommands/run
- releasenotes/notes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
182 | 210 | | |
183 | 211 | | |
184 | 212 | | |
| |||
224 | 252 | | |
225 | 253 | | |
226 | 254 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | 255 | | |
240 | 256 | | |
241 | 257 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
210 | 231 | | |
211 | 232 | | |
212 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
317 | 319 | | |
318 | 320 | | |
319 | 321 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments