Skip to content

FX-1197: Add agent config and agent profiles to the managed Agent installation intent - #3753

Open
yuhuyoyo wants to merge 9 commits into
mainfrom
yuhu/managed-install-agent-config-on-generic
Open

yuhuyoyo wants to merge 9 commits into
mainfrom
yuhu/managed-install-agent-config-on-generic

Conversation

@yuhuyoyo

@yuhuyoyo yuhuyoyo commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

What

Adds two optional, provider-neutral settings to the managed Agent installation intent (the ConfigMap the Fleet Daemon watches), wired into the generic provider decoder only (from #3751):

  • agentConfig — {"spec": <DatadogAgentSpec fragment>} merged over the bootstrap spec at install time. Bootstrap stays authoritative for clusterName, site, and the linux node selectors; spec.global.credentials / cluster Agent tokens are rejected, so the Fleet-delivered credentials are never overridden. The shape matches the Fleet INSTALLER_CONFIG payload and the Datadog Agent setup page's datadog-agent.yaml, so a fragment such as features.apm.instrumentation (single-step instrumentation) applies verbatim.
  • agentProfiles — DatadogAgentProfile entries (name, profileAffinity, config.spec) created next to the managed DatadogAgent, mirroring the existing Windows profile: fleet ownership labels + controller owner reference, validated against the profile allowlists (gpu, apm, hostProfiler), garbage-collected via the owner reference on uninstall, and waited on by managedAgentInstallationResourcesAbsent. When profiles are requested the DatadogAgent is annotated agent.datadoghq.com/update-metadata: "true", as required by the Agent Profiles feature.

Both settings participate in the intent digest (canonicalized so JSON reformatting does not change it, which keeps replay-with-different-content protection covering the config), and uninstall intents carrying them are rejected.

The decode/merge/validate/digest logic lives in one shared finalizeManagedAgentInstallationIntent used by the generic provider decoder. EKS is intentionally untouched: its decoder keeps its existing inline logic (no agentConfig / agentProfiles on the EKS wire format, no EKS marketplace schema/template changes) and can adopt the shared finalize tail later. This PR is stacked on #3751 (fx-1127-generic-identity); merge order is #3751 first.

Why

MCI installs the agent with a minimal bootstrap intent, so on generic-provider clusters (Nebius, CoreWeave — the provider added in #3751) a rule cannot request GPU monitoring (GPU-nodes-only via a DatadogAgentProfile with profileNodeAffinity) or APM single-step instrumentation at install time. The only post-install remote path (update_operator config deployments) patches the DatadogAgent only and cannot address profiles or node selectors. Carrying the config in the install intent makes rule-create → install → features on, with no manual YAML.

Note that base APM is enabled by default in the operator (defaultAPMEnabled = true), so the agentConfig path is not needed for plain APM. It is for single-step instrumentation (which is not default-on) and other non-default settings.

Live test on a real Nebius GPU cluster (2026-11-12)

Verified end-to-end against a Nebius managed Kubernetes GPU cluster with the generic provider:

  • Works end-to-end: intent ConfigMap → fleet daemon → DatadogAgent + gpu-nodes DatadogAgentProfile (VALID/APPLIED) → a second DaemonSet scheduled only on the GPU node, with the base DaemonSet desired count 0 on profile-matched nodes → DD_GPU_ENABLED=true, NVML detected, and gpu.* metrics (e.g. gpu.total_energy_consumption) arriving in Datadog.

  • The GPU node affinity label is cloud-specific:

    • Nebius: nebius.com/gpu=true — not nvidia.com/gpu.present.
    • CoreWeave: gpu.nvidia.com/class / gpu.coreweave.cloud/driver-version.
    • NVIDIA GPU operator: nvidia.com/gpu.present.
    • EKS: no GPU label.

    A wrong label is a silent no-op: the profile matches 0 nodes, the base DaemonSet covers the GPU node without GPU monitoring, and the fleet state still reports DONE. Suggested follow-up: surface the matched-node count in DatadogAgentProfile status, or have the fleet daemon warn when a requested profile matches 0 nodes.

  • Nebius has no nvidia RuntimeClass (drivers are baked into the node image). Intents targeting managed-driver clouds must set features.gpu.requiredRuntimeClassName: ""; the operator default is "nvidia", which leaves the agent pods unschedulable there.

  • Install → acknowledge → uninstall was verified. Deleting the intent ConfigMap garbage-collects the state ConfigMap because it is owned by the intent ConfigMap, so Fleet must always update the intent ConfigMap in place, never delete and recreate it.

  • Nebius provider detection ([FX-1133] Detect Nebius and default kubelet.tlsVerify to false #3722) works in managed-install mode: DD_KUBELET_TLS_VERIFY=false is set on all agent containers.

Testing

  • go test ./pkg/fleet/ -count=1 green.
  • go build ./... clean; make lint reports 0 issues.
  • Unit coverage: generic intent decode with agentConfig / agentProfiles (merge semantics, bootstrap authority, digest stability across reformatting, digest change on config change), unsafe-settings table (credentials in agentConfig / profile config, unknown fields, reserved/duplicated/invalid profile names, missing affinity, feature outside the profile allowlist, settings on uninstall), profile lifecycle (create/validate/idempotent ensure/drift rejection), uninstall waits for fleet-owned profiles, and a full installDatadogAgent with profiles asserting the update-metadata annotation and the created profile.

The dd-source counterpart (MCI rule install_options → intent plumbing) is ddoghq/dd-source#171714.

🤖 Generated with Claude Code

yuhuyoyo and others added 2 commits November 7, 2026 16:44
Provider-neutral identity for installers that are not tied to a specific
cloud (MCI on Nebius, CoreWeave and later clouds), per FX-1127:

- env DD_MANAGED_INSTALLATION_ID + DD_RESOURCE_KEY_SHA256
- updater tags managed_installation_id, resource_key_sha256,
  managed_agent_installation:generic-v1
- intent decoder for provider "generic" (json field resourceKeySHA256)

The EKS provider is unchanged; configuring both fails closed as before.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Adds the absent desired-state path, the whitespace validation branch,
TargetID's undecodable digest branch, and table-driven error cases for
every decoder rejection: missing and oversized intents, trailing JSON,
unsupported version, invalid operation and acknowledged operation IDs,
acknowledgement mismatch, invalid bootstrap cluster name and site, and
unsupported desired state. Addresses the PR-gate patch coverage threshold.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@datadog-official

datadog-official Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Pipelines  Code Coverage

🎯 Code Coverage (details)
• Patch Coverage: 94.76%
• Overall Coverage: 58.18% (+0.20%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5de72d8 | Docs | Give us feedback!

@yuhuyoyo
yuhuyoyo force-pushed the yuhu/managed-install-agent-config-on-generic branch from 4c9b5bb to a4283ae Compare November 10, 2026 19:33
@yuhuyoyo
yuhuyoyo changed the base branch from fx-1127-generic-identity to main November 10, 2026 19:33
@yuhuyoyo yuhuyoyo added the enhancement New feature or request label Nov 10, 2026 — with ddtool CLI
@yuhuyoyo yuhuyoyo added this to the v1.33.0 milestone Nov 10, 2026
@yuhuyoyo yuhuyoyo changed the title Add agent config and agent profiles to the managed Agent installation intent FX-1197: Add agent config and agent profiles to the managed Agent installation intent Nov 10, 2026
@yuhuyoyo
yuhuyoyo marked this pull request as ready for review November 10, 2026 22:39
@yuhuyoyo
yuhuyoyo requested a review from a team November 10, 2026 22:39
@yuhuyoyo
yuhuyoyo requested a review from a team as a code owner November 10, 2026 22:39
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T22:41:33.177129Z 74aca56 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74aca56d8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

yuhuyoyo and others added 4 commits November 12, 2026 21:34
… intent

Managed Cloud Instrumentation (MCI) installs the agent with a minimal
bootstrap spec, so GPU monitoring and APM single-step instrumentation
cannot be requested at install time today; the only remote path
(update_operator) cannot express DatadogAgentProfile-based node scoping.

Extend the managed Agent installation intent with two optional settings
the EKS decoder accepts:

- agentConfig: a {"spec": <DatadogAgentSpec fragment>} merged over the
  bootstrap spec at install time. Bootstrap stays authoritative for
  clusterName, site, and the linux node selectors; credentials are
  rejected. This is the same shape the Fleet INSTALLER_CONFIG path and
  the APM setup page use, so the ssi-mode datadog-agent.yaml applies
  verbatim.
- agentProfiles: DatadogAgentProfile entries (name, profileAffinity,
  config.spec) the Fleet Daemon creates next to the managed DatadogAgent,
  fleet-owned like the existing Windows profile (validated with the
  profile allowlists, torn down via owner garbage collection, waited on
  during uninstall). When profiles are present the DatadogAgent gets the
  agent.datadoghq.com/update-metadata annotation.

Both settings are covered by the intent digest (canonicalized, so JSON
reformatting does not change it) and rejected on uninstall intents.

The decode/merge/validate/digest logic sits in a provider-neutral
finalizeManagedAgentInstallationIntent, so provider decoders beyond EKS
(the generic provider proposed in #3751) can adopt the same settings with
a wire-field pair and one call.

Co-Authored-By: Claude Code <noreply@anthropic.com>
The PR Gates patch-coverage check requires 80% of modified lines to be
covered; the agentProfiles paths only had happy-path and rejection
tests. Add tests for valid profile decoding, decoder edge cases
(trailing content, profile count limit, config without spec), fragment
merge without component overrides, profile validation branches
(terminating, foreign ownership, missing owner), install fault modes
(profile create/read failures on new and existing targets, drift), the
acknowledge-time pinned-config validation, and the uninstall inventory
profile list failure, bringing local patch coverage to ~96%.

Environment: Datadog workspace

Co-Authored-By: Claude Code <noreply@anthropic.com>
Route the generic provider intent through the shared
finalizeManagedAgentInstallationIntent so Nebius/CoreWeave installs can
request DatadogAgentProfiles (GPU monitoring) via the install intent,
matching the EKS decoder wiring from PR 3753. Update the desired-state
error expectation now that the shared finalize emits the provider-neutral
message. Local test branch for live Nebius GPU-cluster validation only.

Environment: Datadog workspace

Co-Authored-By: Claude Code <noreply@anthropic.com>
Revert the EKS intent decoder and the EKS marketplace schema/template
changes so agentConfig/agentProfiles are wired only into the generic
provider decoder (PR #3751). EKS keeps its inline decoder and can adopt
the shared finalizeManagedAgentInstallationIntent tail later.

Rewrite the agent config/profile tests against the generic wire format
and swap the APM example configs for log collection: base APM is enabled
by default in the operator, so the agentConfig mechanism targets
single-step instrumentation and other non-default settings.

Environment: Datadog workspace

Co-Authored-By: Claude Code <noreply@anthropic.com>
@yuhuyoyo
yuhuyoyo force-pushed the yuhu/managed-install-agent-config-on-generic branch from 74aca56 to c780a6a Compare November 12, 2026 22:33
@yuhuyoyo
yuhuyoyo changed the base branch from main to fx-1127-generic-identity November 12, 2026 22:34
yuhuyoyo and others added 2 commits November 12, 2026 22:58
Collapse every comment the PR introduces to one line and one sentence,
dropping redundant detail. No code or test behavior changes.

Environment: Datadog workspace

Co-Authored-By: Claude Code <noreply@anthropic.com>
The intent decoder only ran ValidateDatadogAgentProfileSpec, which does
not enforce the 63-character label-value limit on profile names and does
not parse node selector requirements. A DNS-valid multi-label name longer
than 63 characters, or an affinity requirement such as `operator: In`
with no values, therefore passed decoding even though the profile
controller skips that profile during reconciliation. Fleet could then
report a successful installation without applying the requested
configuration.

Run agentprofile.ValidateProfileAndReturnRequirements during decoding,
matching reconcileProfiles, so these intents are rejected before
installation completion. Add regression tests for both cases.

Environment: Datadog workspace

Co-Authored-By: Claude Code <noreply@anthropic.com>
Base automatically changed from fx-1127-generic-identity to main November 13, 2026 18:05
Resolve add/add conflicts in pkg/fleet/managed_agent_installation_intent_generic.go
and its test (artifact of #3751's squash merge): keep the PR side, which wires
agentConfig/agentProfiles through finalizeManagedAgentInstallationIntent.

Environment: Datadog workspace

Co-Authored-By: Claude Code (claude-deepseek-v4.1-flash) <noreply@anthropic.com>

This branch has not been deployed

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

Labels

enhancement New feature or request team/fleet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants