Skip to content

configstream: let clients ingest streamed env-var-sourced settings (#55310) - #55612

Open
rahulkaukuntla wants to merge 1 commit into
7.83.xfrom
backport-55310-to-7.83.x
Open

configstream: let clients ingest streamed env-var-sourced settings (#55310)#55612
rahulkaukuntla wants to merge 1 commit into
7.83.xfrom
backport-55310-to-7.83.x

Conversation

@rahulkaukuntla

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds nodetreemodel.DirectBulkSet to model.Writer, taking a whole resolved snapshot ([]model.DirectSetting) in one pass. Unlike Set it accepts SourceEnvVar and skips change notifications, so it exists for config streaming and nothing else should call it. A key absent from the client's schema is warned and stored rather than dropped, matching the YAML loader, so the client mirrors the sender. Incremental updates still go through Set, so notifications continue to reach registered receivers.

Remote agents (trace-agent, process-agent, security-agent, system-probe) disable their own env-var layer and instead mirror the core agent's resolved config over configstream, keeping each setting's original source. Env vars are set on the core agent's process, so a faithful mirror has to write those settings as SourceEnvVar — but nodetreemodel.Set refuses to write that layer, since it's normally populated by reading the process's own environment.

(cherry picked from commit c91f57a)

Motivation

Describe how you validated your changes

Additional Notes

…55310)

Adds `nodetreemodel.DirectBulkSet` to `model.Writer`, taking a whole resolved snapshot (`[]model.DirectSetting`) in one pass. Unlike `Set` it accepts `SourceEnvVar` and skips change notifications, so it exists for config streaming and nothing else should call it. A key absent from the client's schema is warned and stored rather than dropped, matching the YAML loader, so the client mirrors the sender. Incremental updates still go through `Set`, so notifications continue to reach registered receivers.

Remote agents (trace-agent, process-agent, security-agent, system-probe) disable their own env-var layer and instead mirror the core agent's resolved config over configstream, keeping each setting's original source. Env vars are set on the core agent's process, so a faithful mirror has to write those settings as `SourceEnvVar` — but `nodetreemodel.Set` refuses to write that layer, since it's normally populated by reading the process's own environment.

So today every env-var-sourced setting in a snapshot is dropped: the remote agents silently diverge from the core agent's config, and it was one of the largest sources of configstream error-log noise in staging. The fix is a separate ingestion path that accepts the real source, leaving `Set`'s guardrail in place for direct callers.

Ran a real configstream session locally: core agent with `DD_LOG_LEVEL`, `DD_TAGS`, `DD_APM_ENV` and `DD_APM_MAX_MEMORY` set, and a trace-agent started with an empty environment (the consumer disables its own env-var layer, so anything env-sourced it ends up with can only have come from the stream).

- 2136 settings applied in ~84ms, zero `"Writing to env var layers is not allowed..."` errors.
- All four landed: the trace-agent logs at DEBUG, and `/info` reports `default_env = livetest-env` (from the nested `apm_config.env`) and `max_memory = 300000000`.
- Live updates still take effect: `agent config set log_level info` arrived as a `ConfigUpdate` and silenced the trace-agent's DEBUG lines.
- `TestDirectBulkSet` pins precedence (a `SourceFile` write loses to an existing `SourceAgentRuntime` value in the same call) and unknown-key storage.

Also ran `dda inv linter.go`, `dda inv test` and `dda inv tidy`, all passing.

Co-authored-by: rahul.kaukuntla <rahul.kaukuntla@datadoghq.com>
(cherry picked from commit c91f57a)
@rahulkaukuntla
rahulkaukuntla requested review from a team as code owners August 28, 2026 19:02
@temporal-github-worker-1

Copy link
Copy Markdown
Contributor

Backport evaluation: View Slack thread

@dd-octo-sts dd-octo-sts Bot added the internal Identify a non-fork PR label Aug 28, 2026
@github-actions github-actions Bot added the medium review PR review might take time label Aug 28, 2026
@rahulkaukuntla rahulkaukuntla added qa/done QA done before merge and regressions are covered by tests changelog/no-changelog No changelog entry needed labels Aug 28, 2026

@aiuto aiuto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta question: Why are we backporting this?

  • We are a week away from the code freeze for the next release, so we are very late in the current release cycle.
  • There is no bug attached to either this PR or the one it is picked from. So why any urgency?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog No changelog entry needed internal Identify a non-fork PR medium review PR review might take time qa/done QA done before merge and regressions are covered by tests team/agent-build team/fleet-automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants