Skip to content

Support statefulset workloads in autoscaling#44855

Merged
dd-mergequeue[bot] merged 7 commits intomainfrom
nickbirnberg/CASCL-779-enable-stateful-set-workloads
Jan 16, 2026
Merged

Support statefulset workloads in autoscaling#44855
dd-mergequeue[bot] merged 7 commits intomainfrom
nickbirnberg/CASCL-779-enable-stateful-set-workloads

Conversation

@nickbirnberg
Copy link
Copy Markdown
Member

What does this PR do?

Adds support for StatefulSets in Kubernetes Autoscaling

Motivation

https://datadoghq.atlassian.net/browse/CASCL-779

Describe how you validated your changes

Additional Notes

@github-actions github-actions bot added the long review PR is complex, plan time to review it label Jan 7, 2026
@agent-platform-auto-pr
Copy link
Copy Markdown
Contributor

agent-platform-auto-pr bot commented Jan 7, 2026

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 654cf36
📊 Static Quality Gates Dashboard

Successful checks

Info

Quality gate Change Size (prev → curr → max)
docker_cluster_agent_amd64 +4.0 KiB (0.00% increase) 180.745 → 180.749 → 181.080
30 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
agent_deb_amd64 705.544 MiB
agent_deb_amd64_fips 700.834 MiB
agent_heroku_amd64 327.023 MiB
agent_msi 571.820 MiB
agent_rpm_amd64 705.531 MiB
agent_rpm_amd64_fips 700.820 MiB
agent_rpm_arm64 687.049 MiB
agent_rpm_arm64_fips 683.186 MiB
agent_suse_amd64 705.531 MiB
agent_suse_amd64_fips 700.820 MiB
agent_suse_arm64 687.049 MiB
agent_suse_arm64_fips 683.186 MiB
docker_agent_amd64 767.687 MiB
docker_agent_arm64 773.820 MiB
docker_agent_jmx_amd64 958.566 MiB
docker_agent_jmx_arm64 953.418 MiB
docker_cluster_agent_arm64 196.602 MiB
docker_cws_instrumentation_amd64 7.135 MiB
docker_cws_instrumentation_arm64 6.689 MiB
docker_dogstatsd_amd64 38.843 MiB
docker_dogstatsd_arm64 37.128 MiB
dogstatsd_deb_amd64 30.067 MiB
dogstatsd_deb_arm64 28.212 MiB
dogstatsd_rpm_amd64 30.067 MiB
dogstatsd_suse_amd64 30.067 MiB
iot_agent_deb_amd64 43.097 MiB
iot_agent_deb_arm64 40.206 MiB
iot_agent_deb_armhf 40.795 MiB
iot_agent_rpm_amd64 43.097 MiB
iot_agent_suse_amd64 43.097 MiB
On-wire sizes (compressed)
Quality gate Change Size (prev → curr → max)
agent_deb_amd64 +9.25 KiB (0.01% increase) 173.298 → 173.307 → 174.490
agent_deb_amd64_fips +10.05 KiB (0.01% increase) 172.226 → 172.235 → 173.750
agent_heroku_amd64 +2.84 KiB (0.00% increase) 87.130 → 87.132 → 88.450
agent_msi +16.0 KiB (0.01% increase) 142.980 → 142.996 → 143.020
agent_rpm_amd64 -7.69 KiB (0.00% reduction) 175.965 → 175.958 → 177.660
agent_rpm_amd64_fips +2.84 KiB (0.00% increase) 175.087 → 175.090 → 176.600
agent_rpm_arm64 +47.29 KiB (0.03% increase) 159.402 → 159.448 → 161.260
agent_rpm_arm64_fips -20.87 KiB (0.01% reduction) 158.729 → 158.709 → 160.550
agent_suse_amd64 -7.69 KiB (0.00% reduction) 175.965 → 175.958 → 177.660
agent_suse_amd64_fips +2.84 KiB (0.00% increase) 175.087 → 175.090 → 176.600
agent_suse_arm64 +47.29 KiB (0.03% increase) 159.402 → 159.448 → 161.260
agent_suse_arm64_fips -20.87 KiB (0.01% reduction) 158.729 → 158.709 → 160.550
docker_agent_amd64 neutral 261.129 MiB
docker_agent_arm64 neutral 250.120 MiB
docker_agent_jmx_amd64 -3.35 KiB (0.00% reduction) 329.774 → 329.771 → 331.080
docker_agent_jmx_arm64 neutral 314.747 MiB
docker_cluster_agent_amd64 +8.92 KiB (0.01% increase) 63.856 → 63.865 → 64.490
docker_cluster_agent_arm64 +7.64 KiB (0.01% increase) 60.135 → 60.142 → 61.170
docker_cws_instrumentation_amd64 neutral 2.994 MiB
docker_cws_instrumentation_arm64 neutral 2.726 MiB
docker_dogstatsd_amd64 neutral 15.038 MiB
docker_dogstatsd_arm64 neutral 14.363 MiB
dogstatsd_deb_amd64 neutral 7.953 MiB
dogstatsd_deb_arm64 neutral 6.827 MiB
dogstatsd_rpm_amd64 neutral 7.964 MiB
dogstatsd_suse_amd64 neutral 7.964 MiB
iot_agent_deb_amd64 neutral 11.292 MiB
iot_agent_deb_arm64 neutral 9.653 MiB
iot_agent_deb_armhf -3.11 KiB (0.03% reduction) 9.851 → 9.848 → 10.620
iot_agent_rpm_amd64 -2.44 KiB (0.02% reduction) 11.311 → 11.308 → 12.060
iot_agent_suse_amd64 -2.44 KiB (0.02% reduction) 11.311 → 11.308 → 12.060

@cit-pr-commenter
Copy link
Copy Markdown

cit-pr-commenter bot commented Jan 7, 2026

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 305ea424-e1f7-414f-954e-f30ac295fc98

Baseline: 654cf36
Comparison: bd8ff32
Diff

Optimization Goals: ✅ No significant changes detected

Experiments ignored for regressions

Regressions in experiments with settings containing erratic: true are ignored.

perf experiment goal Δ mean % Δ mean % CI trials links
docker_containers_cpu % cpu utilization -0.17 [-3.14, +2.80] 1 Logs

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gate_metrics_logs memory utilization +2.28 [+2.06, +2.50] 1 Logs bounds checks dashboard
tcp_syslog_to_blackhole ingress throughput +1.44 [+1.37, +1.51] 1 Logs
quality_gate_idle_all_features memory utilization +0.70 [+0.67, +0.74] 1 Logs bounds checks dashboard
ddot_metrics memory utilization +0.31 [+0.08, +0.54] 1 Logs
docker_containers_memory memory utilization +0.22 [+0.15, +0.29] 1 Logs
ddot_metrics_sum_cumulative memory utilization +0.16 [-0.00, +0.33] 1 Logs
ddot_logs memory utilization +0.11 [+0.05, +0.18] 1 Logs
file_to_blackhole_1000ms_latency egress throughput +0.05 [-0.37, +0.47] 1 Logs
file_to_blackhole_0ms_latency egress throughput +0.01 [-0.51, +0.54] 1 Logs
file_tree memory utilization +0.01 [-0.04, +0.07] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput +0.01 [-0.08, +0.10] 1 Logs
uds_dogstatsd_to_api ingress throughput -0.00 [-0.14, +0.13] 1 Logs
file_to_blackhole_500ms_latency egress throughput -0.01 [-0.40, +0.38] 1 Logs
uds_dogstatsd_to_api_v3 ingress throughput -0.01 [-0.13, +0.11] 1 Logs
uds_dogstatsd_20mb_12k_contexts_20_senders memory utilization -0.03 [-0.09, +0.03] 1 Logs
file_to_blackhole_100ms_latency egress throughput -0.08 [-0.13, -0.04] 1 Logs
ddot_metrics_sum_delta memory utilization -0.09 [-0.29, +0.11] 1 Logs
quality_gate_idle memory utilization -0.13 [-0.18, -0.09] 1 Logs bounds checks dashboard
docker_containers_cpu % cpu utilization -0.17 [-3.14, +2.80] 1 Logs
otlp_ingest_logs memory utilization -0.36 [-0.47, -0.26] 1 Logs
ddot_metrics_sum_cumulativetodelta_exporter memory utilization -0.74 [-0.97, -0.50] 1 Logs
otlp_ingest_metrics memory utilization -1.05 [-1.20, -0.90] 1 Logs
quality_gate_logs % cpu utilization -2.55 [-4.02, -1.09] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed links
docker_containers_cpu simple_check_run 10/10
docker_containers_memory memory_usage 10/10
docker_containers_memory simple_check_run 10/10
file_to_blackhole_0ms_latency lost_bytes 10/10
file_to_blackhole_0ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency lost_bytes 10/10
file_to_blackhole_1000ms_latency memory_usage 10/10
file_to_blackhole_100ms_latency lost_bytes 10/10
file_to_blackhole_100ms_latency memory_usage 10/10
file_to_blackhole_500ms_latency lost_bytes 10/10
file_to_blackhole_500ms_latency memory_usage 10/10
quality_gate_idle intake_connections 10/10 bounds checks dashboard
quality_gate_idle memory_usage 10/10 bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 bounds checks dashboard
quality_gate_logs intake_connections 10/10 bounds checks dashboard
quality_gate_logs lost_bytes 10/10 bounds checks dashboard
quality_gate_logs memory_usage 10/10 bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 bounds checks dashboard
quality_gate_metrics_logs lost_bytes 10/10 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 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 (target internal profiling)

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_all_features baseline 11 (x4) Oom killed Debug Dashboard
quality_gate_idle_all_features comparison 11 (x4) Oom killed Debug Dashboard

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, 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 intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 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 intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.

func (u *verticalController) syncDeploymentKind(
// isRolloutComplete checks if all pods of a workload have completed a rollout
// Returns true if the rollout is complete (all pods updated).
func isRolloutComplete(recommendationID string, pods []*workloadmeta.KubernetesPod, podsPerRecomendationID map[string]int32) bool {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can name this slightly differently, what we are checking if is the current recommendation is entirely rolled out, something like isRecommendationRolloutComplete

}

// Create a fake Deployment in the dynamic client
deployment := &unstructured.Unstructured{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can use ToUnstructured from pkg/clusteragent/autoscaling/utils.go

Copy link
Copy Markdown
Contributor

@vboulineau vboulineau left a comment

Choose a reason for hiding this comment

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

LGTM, small comments

@vboulineau vboulineau added the changelog/no-changelog No changelog entry needed label Jan 15, 2026
@vboulineau vboulineau added this to the 7.76.0 milestone Jan 15, 2026
@nickbirnberg nickbirnberg force-pushed the nickbirnberg/CASCL-779-enable-stateful-set-workloads branch from 5846335 to b98375c Compare January 15, 2026 14:34
@nickbirnberg nickbirnberg added the qa/done QA done before merge and regressions are covered by tests label Jan 16, 2026
@nickbirnberg nickbirnberg marked this pull request as ready for review January 16, 2026 15:55
@nickbirnberg nickbirnberg requested review from a team as code owners January 16, 2026 15:55
Copy link
Copy Markdown
Member

@L3n41c L3n41c left a comment

Choose a reason for hiding this comment

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

Only found few spelling typos.

func (u *verticalController) syncDeploymentKind(
// isRecommendationRolloutComplete checks if the current recommendation is entirely rolled out.
// Returns true if all pods have the given recommendation ID.
func isRecommendationRolloutComplete(recommendationID string, pods []*workloadmeta.KubernetesPod, podsPerRecomendationID map[string]int32) bool {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo

Suggested change
func isRecommendationRolloutComplete(recommendationID string, pods []*workloadmeta.KubernetesPod, podsPerRecomendationID map[string]int32) bool {
func isRecommendationRolloutComplete(recommendationID string, pods []*workloadmeta.KubernetesPod, podsPerRecommendationID map[string]int32) bool {

func isRecommendationRolloutComplete(recommendationID string, pods []*workloadmeta.KubernetesPod, podsPerRecomendationID map[string]int32) bool {
// currently basic check with 100% match expected.
// TODO: Refine the logic and add backoff for stuck PODs.
return podsPerRecomendationID[recommendationID] == int32(len(pods))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo

Suggested change
return podsPerRecomendationID[recommendationID] == int32(len(pods))
return podsPerRecommendationID[recommendationID] == int32(len(pods))

targetGVK schema.GroupVersionKind,
recommendationID string,
pods []*workloadmeta.KubernetesPod,
podsPerRecomendationID map[string]int32,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo

Suggested change
podsPerRecomendationID map[string]int32,
podsPerRecommendationID map[string]int32,

podsPerDirectOwner map[string]int32,
) (autoscaling.ProcessResult, error) {
// Check if we need to rollout
if isRecommendationRolloutComplete(recommendationID, pods, podsPerRecomendationID) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if isRecommendationRolloutComplete(recommendationID, pods, podsPerRecomendationID) {
if isRecommendationRolloutComplete(recommendationID, pods, podsPerRecommendationID) {

case k8sutil.StatefulSetKind:
return u.syncStatefulSetKind(ctx, podAutoscaler, autoscalerInternal, updateStrategy, target, targetGVK, recomendationID, pods, podsPerRecomendationID)
default:
autoscalerInternal.UpdateFromVerticalAction(nil, fmt.Errorf("automic rollout not available for target Kind: %s. Applying to existing PODs require manual trigger", targetGVK.Kind))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo

Suggested change
autoscalerInternal.UpdateFromVerticalAction(nil, fmt.Errorf("automic rollout not available for target Kind: %s. Applying to existing PODs require manual trigger", targetGVK.Kind))
autoscalerInternal.UpdateFromVerticalAction(nil, fmt.Errorf("automatic rollout not available for target Kind: %s. Applying to existing PODs require manual trigger", targetGVK.Kind))

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 16, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@nickbirnberg
Copy link
Copy Markdown
Member Author

I have read the CLA Document and I hereby sign the CLA

@nickbirnberg
Copy link
Copy Markdown
Member Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 bot commented Jan 16, 2026

View all feedbacks in Devflow UI.

2026-01-16 19:48:59 UTC ℹ️ Start processing command /merge


2026-01-16 19:49:05 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-01-16 21:06:16 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 45m (p90).


2026-01-16 21:52:56 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue dd-mergequeue bot merged commit 775be41 into main Jan 16, 2026
320 of 321 checks passed
@dd-mergequeue dd-mergequeue bot deleted the nickbirnberg/CASCL-779-enable-stateful-set-workloads branch January 16, 2026 21:52
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

changelog/no-changelog No changelog entry needed long review PR is complex, plan time to review it qa/done QA done before merge and regressions are covered by tests team/container-autoscaling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants