Skip to content

feat(ndm): add Agent workload balancing - #54652

Closed
matthewleese wants to merge 9 commits into
mainfrom
mleese/ndm-device-handoff
Closed

feat(ndm): add Agent workload balancing#54652
matthewleese wants to merge 9 commits into
mainfrom
mleese/ndm-device-handoff

Conversation

@matthewleese

@matthewleese matthewleese commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Note: This PR was created by Claude.

What does this PR do?

Adds NDM Agent workload balancing: a device can be handed from one Agent to another without restarting either one.

The component (comp/workloadbalancing)

  • def/ — the Component interface and the Active / Standby / Unmanaged states
  • impl/ — an RWMutex-guarded map of group ID to state, the agent_workload_balancing.enabled config read, and the Remote Config update callback
  • fx/, mock/, helpers/ — the usual component scaffolding
  • pkg/config/schema/yaml/core_schema.yaml — the new agent_workload_balancing.enabled setting, default false

Remote Config

New NDM_AGENT_WORKLOAD_BALANCING product in pkg/remoteconfig/state/products.go. Each config names a group and the Agent that should actively poll it. The listener is registered only when the setting is enabled.

Where the group comes from

The SNMP instance setting agent_workload_balancing_group flows through InstanceConfig into CheckConfig and out via Check#WorkloadBalancingGroupID(), a new method on the Check interface that returns the empty string for everything else. It is deliberately left out of DeviceDigest, so moving a device between groups does not change its identity.

The gate

pkg/collector/worker skips a check only when workload balancing is enabled, the check names a group, and that group is not active on this Agent.

Wiring

workloadbalancingfx.Module() at 12 binary sites; the component is threaded into the collector and the check runner.

Motivation

First slice of the NDM Agent load balancing RFC. Today moving a device between Agents means editing config on both and restarting them, which leaves a monitoring gap.

The design follows comp/haagent closely, with two deliberate differences:

  • State is per group, not per Agent. One Agent can be active for some groups and standby for others, so the component holds a map rather than a single value.
  • It fails open. HA treats an unknown state as a reason to suppress. Here a group we hold no assignment for is Unmanaged and runs, and only an explicit standby suppresses. Duplicate monitoring during a handoff is recoverable; a silent device is not. For the same reason an empty Remote Config update clears every group rather than suppressing everything, and a group that drops out of the set returns to unmanaged.

Describe how you validated your changes

  • go test -tags test ./comp/workloadbalancing/... ./pkg/collector/... ./comp/collector/... — pass
  • go build ./... — clean
  • dda inv linter.go over the touched packages — clean apart from a pre-existing cgo typecheck failure in pkg/collector/python, which this PR does not touch
  • bazel run //:gazelle for the BUILD.bazel files
  • fx graph validation via go test -tags test ./cmd/agent/subcommands/... ./cmd/dogstatsd/subcommands/... ./pkg/cli/subcommands/...

Unit tests cover: enabled/disabled config; the unmanaged-runs default; standby suppression; RemoveGroup; group independence; GetGroupStates returning a copy; Remote Config apply/error states for valid, malformed, and partially valid update sets; and the worker gate across active, standby, unmanaged, and disabled.

No manual validation yet — the Remote Config product still needs backend registration before an end-to-end handoff can be exercised.

Additional Notes

Still draft. Remaining work, in its own PRs: the datadog.agent.workload_balancing.running metric, inventory metadata, and an e2e test (blocked on #53246 for Remote Config fakeintake support).

Adds the comp/workloadbalancing skeleton that holds per-group active/standby
state, so a network device can be handed from one Agent to another without
restarting either one.

The component tracks state per group rather than per Agent, which is the main
difference from haagent. It also fails open: a group we hold no assignment for
is Unmanaged and runs. Only an explicit standby suppresses a group, because
duplicate monitoring during a handoff is recoverable and a silent device is not.

Nothing consumes the component yet. The Remote Config listener, the check
gating, and the metric follow in later PRs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

@codex review

@github-actions github-actions Bot added the long review PR is complex, plan time to review it label Aug 10, 2026

@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: 0266106bcc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread pkg/config/schema/yaml/core_schema.yaml Outdated
Comment on lines +5445 to +5447
Set to true to enable Agent workload balancing. When enabled, the Agent only runs checks
for the workload balancing groups it has been assigned, allowing a device to be moved
between Agents without restarting either one.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Document unmanaged groups as still running

For users reading the generated public datadog.yaml, this says enabling workload balancing makes the Agent only run assigned groups. The component added in this commit deliberately treats a missing assignment as Unmanaged, and IsGroupActive returns true unless the state is Standby, so a group that is never assigned or later removed will still run. Please update this description, or change the state semantics, so the public config does not promise suppression of all unassigned groups.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed in 2b694d7.

The description now says the Agent skips the groups assigned to another Agent, and spells out that a group this Agent holds no assignment for keeps running. That is deliberate: IsGroupActive only suppresses on an explicit standby, because a device nobody polls is a worse failure than a device two Agents poll during a handoff.

Note: This reply was written by Claude.

matthewleese and others added 2 commits August 10, 2026 11:38
Adds the NDM_AGENT_WORKLOAD_BALANCING product and the update callback that
applies its assignments. Each config names a group and the Agent that should
actively poll it.

Remote Config resends every config targeting this Agent on each update, so the
set is authoritative: a group missing from it has lost its assignment and is
dropped rather than left on standby. An empty update clears every group, which
is the opposite of what the HA Agent does with one. HA stops running its checks
when it loses its assignment; we keep running ours, because the failure that
matters here is a device nobody is polling.

The listener is only registered when agent_workload_balancing.enabled is true.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Provides the component everywhere haagent is already provided, so anything that
constructs a collector can depend on it. Twelve sites, matching haagent exactly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 73.30%
Overall Coverage: 52.35% (+0.06%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 507c1f7 | Docs | Datadog PR Page | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Files inventory check summary

File checks results against ancestor 1d86ce75:

Results for datadog-agent_7.84.0~devel.git.56.507c1f7.pipeline.130068453-1_amd64.deb:

No change detected

Results for datadog-iot-agent_7.84.0~devel.git.56.507c1f7.pipeline.130068453-1_amd64.deb:

No change detected

Adds the group a check belongs to and the runner-side gate that acts on it.

The SNMP instance setting agent_workload_balancing_group flows through
InstanceConfig into CheckConfig and out via Check#WorkloadBalancingGroupID, a new
method on the Check interface that defaults to the empty string for everything
else. It is deliberately left out of DeviceDigest so moving a device between
groups does not change its identity.

The worker skips a check only when workload balancing is enabled, the check names
a group, and that group is not active on this Agent. A check with no group, or a
group we have never been assigned, always runs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@dd-octo-sts

dd-octo-sts Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 1d86ce7
📊 Static Quality Gates Dashboard
🔗 SQG Job

Successful checks

Info

Quality gate Change Size (prev → curr → max)
agent_deb_amd64 +44.77 KiB (0.01% increase, -0.89% of buffer) 759.542 → 759.586 → 764.430
agent_deb_amd64_fips +44.77 KiB (0.01% increase, -1.56% of buffer) 712.884 → 712.928 → 715.680
agent_heroku_amd64 +44.77 KiB (0.01% increase, -0.65% of buffer) 312.265 → 312.309 → 318.990
agent_msi +50.89 KiB (0.01% increase, -0.28% of buffer) 643.243 → 643.292 → 660.900
agent_rpm_amd64 +44.77 KiB (0.01% increase, -0.90% of buffer) 759.526 → 759.570 → 764.400
agent_rpm_amd64_fips +44.77 KiB (0.01% increase, -1.55% of buffer) 712.868 → 712.912 → 715.680
agent_rpm_arm64 +40.77 KiB (0.01% increase, -36.38% of buffer) 735.491 → 735.530 → 735.600
agent_rpm_arm64_fips +44.77 KiB (0.01% increase, -2.84% of buffer) 692.100 → 692.143 → 693.640
agent_suse_amd64 +44.77 KiB (0.01% increase, -0.90% of buffer) 759.526 → 759.570 → 764.400
agent_suse_amd64_fips +44.77 KiB (0.01% increase, -1.55% of buffer) 712.868 → 712.912 → 715.680
agent_suse_arm64 +40.77 KiB (0.01% increase, -36.38% of buffer) 735.491 → 735.530 → 735.600
agent_suse_arm64_fips +44.77 KiB (0.01% increase, -2.84% of buffer) 692.100 → 692.143 → 693.640
docker_agent_amd64 +44.77 KiB (0.01% increase, -2.41% of buffer) 818.154 → 818.198 → 819.970
docker_agent_arm64 +40.78 KiB (0.00% increase, -2.61% of buffer) 819.162 → 819.202 → 820.690
docker_agent_jmx_amd64 +44.77 KiB (0.00% increase, -2.60% of buffer) 1009.051 → 1009.095 → 1010.730
docker_agent_jmx_arm64 +40.78 KiB (0.00% increase, -2.40% of buffer) 998.712 → 998.752 → 1000.370
docker_cluster_agent_amd64 +32.1 KiB (0.01% increase, -2.92% of buffer) 210.228 → 210.259 → 211.300
docker_dogstatsd_arm64 -64.0 KiB (0.17% reduction, +9.65% of buffer) 37.623 → 37.560 → 38.270
iot_agent_deb_amd64 +40.09 KiB (0.08% increase, -37.57% of buffer) 46.416 → 46.455 → 46.520
iot_agent_deb_arm64 +36.09 KiB (0.08% increase, -5.19% of buffer) 43.091 → 43.127 → 43.770
iot_agent_deb_armhf +32.05 KiB (0.07% increase, -21.01% of buffer) 43.871 → 43.902 → 44.020
iot_agent_rpm_amd64 +40.09 KiB (0.08% increase, -37.75% of buffer) 46.416 → 46.455 → 46.520
iot_agent_suse_amd64 +40.09 KiB (0.08% increase, -37.36% of buffer) 46.415 → 46.454 → 46.520
10 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
docker_cluster_agent_arm64 223.267 MiB
docker_cws_instrumentation_amd64 7.439 MiB
docker_cws_instrumentation_arm64 6.877 MiB
docker_dogstatsd_amd64 39.479 MiB
docker_host_profiler_amd64 305.802 MiB
docker_host_profiler_arm64 317.115 MiB
dogstatsd_deb_amd64 30.220 MiB
dogstatsd_deb_arm64 28.244 MiB
dogstatsd_rpm_amd64 30.220 MiB
dogstatsd_suse_amd64 30.220 MiB

@matthewleese matthewleese added qa/done QA done before merge and regressions are covered by tests and removed changelog/no-changelog No changelog entry needed labels Aug 10, 2026
@matthewleese matthewleese changed the title feat(ndm): add the workloadbalancing component feat(ndm): add Agent workload balancing Aug 10, 2026
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 10, 2026

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: fc7946ba-9562-4df2-ac50-ae347d214a15

Baseline: 1d86ce7
Comparison: 507c1f7
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gate_private_action_runner memory utilization +0.08 [-0.04, +0.20] 1 Logs bounds checks dashboard
quality_gate_security_mean_fs_load memory utilization -0.12 [-0.15, -0.08] 1 Logs bounds checks dashboard
quality_gate_idle_all_features memory utilization -0.20 [-0.24, -0.17] 1 Logs bounds checks dashboard
quality_gate_security_idle memory utilization -0.40 [-0.45, -0.34] 1 Logs bounds checks dashboard
quality_gate_idle memory utilization -0.68 [-0.73, -0.64] 1 Logs bounds checks dashboard
quality_gate_security_no_fs_load memory utilization -0.87 [-0.96, -0.77] 1 Logs bounds checks dashboard
quality_gate_metrics_logs memory utilization -1.30 [-1.54, -1.06] 1 Logs bounds checks dashboard
quality_gate_logs % cpu utilization -3.44 [-4.27, -2.62] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
quality_gate_idle intake_connections 10/10 3 ≤ 4 bounds checks dashboard
quality_gate_idle memory_usage 10/10 148.25MiB ≤ 154MiB bounds checks dashboard
quality_gate_idle total_bytes_received 10/10 734.22KiB ≤ 819.20KiB bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 3 ≤ 4 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 492.87MiB ≤ 512MiB bounds checks dashboard
quality_gate_idle_all_features total_bytes_received 10/10 1.13MiB ≤ 1.25MiB bounds checks dashboard
quality_gate_logs intake_connections 10/10 17 ≤ 40 bounds checks dashboard
quality_gate_logs memory_usage 10/10 184.02MiB ≤ 195MiB bounds checks dashboard
quality_gate_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_logs total_bytes_received 10/10 264.16MiB ≤ 292MiB bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 384.39 ≤ 2000 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 18 ≤ 40 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 375.93MiB ≤ 430MiB bounds checks dashboard
quality_gate_metrics_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_metrics_logs total_bytes_received 10/10 0.94GiB ≤ 1.04GiB bounds checks dashboard
quality_gate_private_action_runner memory_usage 10/10 71.79MiB ≤ 75MiB bounds checks dashboard
quality_gate_security_idle cpu_usage 10/10 27.45 ≤ 100 bounds checks dashboard
quality_gate_security_idle memory_usage 10/10 300.73MiB ≤ 330MiB bounds checks dashboard
quality_gate_security_mean_fs_load cpu_usage 10/10 60.79 ≤ 200 bounds checks dashboard
quality_gate_security_mean_fs_load memory_usage 10/10 280.64MiB ≤ 310MiB bounds checks dashboard
quality_gate_security_no_fs_load cpu_usage 10/10 21.06 ≤ 100 bounds checks dashboard
quality_gate_security_no_fs_load memory_usage 10/10 287.79MiB ≤ 320MiB bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

Replicate Execution Details

We run multiple replicates for each experiment/variant. However, we allow replicates to be automatically retried if there are any failures, up to 8 times, at which point the replicate is marked dead and we are unable to run analysis for the entire experiment. We call each of these attempts at running replicates a replicate execution. This section lists all replicate executions that failed due to the target crashing or being oom killed.

Note: In the below tables we bucket failures by experiment, variant, and failure type. For each of these buckets we list out the replicate indexes that failed with an annotation signifying how many times said replicate failed with the given failure mode. In the below example the baseline variant of the experiment named experiment_with_failures had two replicates that failed by oom kills. Replicate 0, which failed 8 executions, and replicate 1 which failed 6 executions, all with the same failure mode.

Experiment Variant Replicates Failure Logs Debug Dashboard
experiment_with_failures baseline 0 (x8) 1 (x6) Oom killed Debug Dashboard

The debug dashboard links will take you to a debugging dashboard specifically designed to investigate replicate execution failures.

❌ Retried Profiling Replicate Execution Failures (ddprof)

Note: Profiling replicas may still be executing. See the debug dashboard for up to date status.

Experiment Variant Replicates Failure Debug Dashboard
quality_gate_idle baseline 10 Oom killed Debug Dashboard
quality_gate_idle_all_features baseline 10 Oom killed Debug Dashboard
quality_gate_idle_all_features comparison 10 Oom killed Debug Dashboard
quality_gate_logs comparison 10 Oom killed Debug Dashboard
quality_gate_metrics_logs baseline 10 Oom killed Debug Dashboard
quality_gate_metrics_logs comparison 10 Oom killed Debug Dashboard
quality_gate_security_idle baseline 10 Crashed (exit code: 134) Debug Dashboard
quality_gate_security_idle comparison 10 Oom killed Debug Dashboard
quality_gate_security_no_fs_load baseline 10 Oom killed Debug Dashboard
quality_gate_security_no_fs_load comparison 10 Crashed (exit code: 134) Debug Dashboard

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_private_action_runner, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.

…onent

@DataDog/ndm-core has no entry in the slack and jira notification channel maps,
which fails slack_teams_channels_check. Use the team name the rest of NDM uses.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@dd-octo-sts

dd-octo-sts Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Go Package Import Differences

Baseline: 1d86ce7
Comparison: 507c1f7

binaryosarchchange
agentlinuxamd64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl
agentlinuxarm64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl
agentwindowsamd64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl
agentdarwinamd64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl
agentdarwinarm64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl
agentaixppc64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl
iot-agentlinuxamd64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl
iot-agentlinuxarm64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl
heroku-agentlinuxamd64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl
cluster-agentlinuxamd64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl
cluster-agentlinuxarm64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl
cluster-agent-cloudfoundrylinuxamd64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl
cluster-agent-cloudfoundrylinuxarm64
+4, -0
+github.com/DataDog/datadog-agent/comp/workloadbalancing/def
+github.com/DataDog/datadog-agent/comp/workloadbalancing/fx
+github.com/DataDog/datadog-agent/comp/workloadbalancing/helpers
+github.com/DataDog/datadog-agent/comp/workloadbalancing/impl

matthewleese and others added 2 commits August 10, 2026 13:03
Three fixes from the automated review:

- PythonCheck implements check.Check but lives behind the python build tag, so widening the
  interface broke every python-enabled build. It now returns an empty group.
- An RC update we cannot parse used to drop its group back to unmanaged, which starts this Agent
  polling a device another Agent already holds. Keep the last assignment applied for that config
  path instead. A config that stops being sent is still dropped.
- The agent_workload_balancing.enabled description in the public config promised the Agent only
  runs assigned groups. It skips groups assigned to another Agent; an unassigned group keeps
  running.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…llector is built

The first pass mirrored haagent's twelve fx sites, but haagent is provided in several of them for
reasons unrelated to the collector, such as the haagent inventory metadata component. Only the
collector component depends on workloadbalancing, so the module belongs in the three graphs that
build it: the agent run subcommand, the cluster agent, and the cloudfoundry cluster agent. The other
nine either use the noop collector or never construct one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…hes over

The component and its Remote Config wiring add about 37 KiB on disk, and five gates had less buffer
than that: agent_rpm_arm64 and agent_suse_arm64 were 9 KiB under their limit, and the three
iot_agent amd64 gates 24 KiB under. Raise those five by enough to cover the whole stack, which lands
at 735.55 MiB and 46.47 MiB with the metric and metadata PRs applied on top. On-wire sizes all still
pass and are untouched.
@matthewleese

Copy link
Copy Markdown
Contributor Author

Heads up for @DataDog/agent-build: ae4e4f697e4 raises five on-disk size gates.

The component and its Remote Config wiring add about 37 KiB, and these five had less buffer than that already: agent_rpm_arm64 and agent_suse_arm64 were 9 KiB under the limit, and the three iot_agent amd64 gates 24 KiB under. Raised to 735.60 MiB and 46.52 MiB respectively, which covers the whole stack (this PR plus #54656 and #54659 lands at 735.55 MiB and 46.47 MiB). On-wire sizes all pass and are untouched.

Happy to go through the exception process instead if you would rather the limits stayed put.

Note: This comment was written by Claude.

A group whose assignment named no Agent went to standby everywhere, because the leader
comparison is exact and no hostname matches the empty string. Nothing validated active_agent, so
a group the backend has created but not yet assigned would leave its device unpolled, which is
the one outcome this component exists to avoid. An unnamed leader is now unmanaged, which runs
the checks and still reports the group so the gap is visible rather than silent.

The fallback for a config we cannot parse wrote its group unconditionally, in the same loop that
applied the configs we can. Map iteration is unordered, so when one update carried both a fresh
assignment for a group and a stale unparseable config for the same group, the stale one won
about one time in ten. Apply the parseable configs first and let the fallback fill only the
groups that pass left untouched.

Alongside those: guard appliedConfigs with the mutex that already guards the group states rather
than relying on the RC client staying serial, bound the group ID that reaches a metric tag, say
so once when the group count is higher than expected, and name both hostnames when a group goes
to standby so an assignment that means this host but spells it differently is diagnosable.

SetGroupLeader and RemoveGroup had no callers outside the component's own tests now that Remote
Config drives everything through setGroupLeaders, and a partial single-group write sits badly
next to replace-the-whole-set semantics. Drop them from the interface.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@matthewleese

Copy link
Copy Markdown
Contributor Author

Closing to restart from scratch: the design RFC now has Workload Balancing reuse HA Agent's HA_AGENT Remote Config product instead of registering NDM_AGENT_WORKLOAD_BALANCING as its own product (see the Device Handoff RFC). That changes the RC listener, schema, and payload shape enough that it's cleaner to reimplement against the new design than patch this branch. Tracked in datadog-agent#54801.

Note: This PR was closed by Claude.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant