← Back to Pull requests

feat(cluster-agent): send the scheduling goodput of Kueue and KAI from the Cluster Agent #61760

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Dec 01, 2026 16:39 UTC
Author

What does this PR do?

Adds a job_scheduler_goodput check to the Cluster Agent. The Cluster Agent leader sends the scheduling goodput of Kueue Workloads and KAI Scheduler PodGroups: how much of the GPU time that GPU workloads request is spent waiting to become fully runnable. It is off by default and does not change anything else.

Metrics

  • gpu.scheduling.badput_time and gpu.scheduling.fully_admitted_time, counts in GPU-hours. On every run each GPU workload adds seconds since the previous run × requested GPUs to one of them, according to its state at the start of the interval. Goodput is fully_admitted / (fully_admitted + badput) at query time.

  • One series per workload, so any grouping (cluster, queue, reason, GPU type) is an exact sum. Each counted workload sends both metrics, the other as 0, so the goodput of a group where everything waits or everything runs is 0 or 1 rather than missing.

  • Tags: job_scheduler, job_scheduler_queue, job_scheduler_workload, kube_namespace, kueue_workload / kueue_local_queue / kueue_cluster_queue or kai_pod_group / kai_queue, and gpu_type when known.

  • Badput also carries reason, one of six scheduler-independent categories (quota_or_capacity, placement_or_topology, configuration_or_request, preemption_or_reclaim, startup_or_system, other_or_unknown), and the raw scheduler_reason. Series have no host and carry kube_cluster_name, orch_cluster_id and the Agent's configured global tags.
  • What counts as fully runnable

  • Kueue: Admitted and PodsReady (requires waitForPodsReady; without it a Workload is not counted). A Workload waiting to recover (PodsReady=False, WaitForRecovery) is badput (reason:startup_or_system, scheduler_reason:WaitForRecovery). That badput is held and submitted when the recovery ends, and dropped if the Workload finishes instead, because Kueue also reports WaitForRecovery for a few seconds before Finished. GPUs are (admitted pods − reclaimable pods) × GPUs per pod, with the kube-scheduler init container and sidecar rule. Everything comes from the Cluster Agent workloadmeta: Workload conditions and pod sets, the LocalQueue (ClusterQueue of unadmitted Workloads) and the ResourceFlavor node labels (gpu_type). No tagger, no API calls.

  • KAI: every active pod Running and not being deleted, with at least minMember pods running or succeeded. GPUs are the requests of the active pods plus their KAI gpu-fraction annotation. KAI has no readiness condition, so the check watches the pods of the KAI scheduler with an informer filtered by spec.schedulerName (setting below), started on the leader only and keeping only the fields goodput reads: GPU requests and limits, init-container restart policy, node selector and required node affinity, the pod-group-name and gpu-fraction annotations, phase, deletion timestamp and container termination times. If the pod watch receives nothing, not even the bookmark the API server sends about every minute, for 3 minutes, a new informer lists the pods again. Counting goes on from that fresh list, or starts a new baseline if the list does not complete. A Forbidden or Unauthorized error stops the informer at once. This is a second pod watch next to the one workloadmeta runs when KAI metadata is on, because workloadmeta pods carry none of those fields and adding them would grow the entity type that node Agents also link. For a PodGroup without active pods it reads the owning batch Job to tell a retry from completion: finished Jobs once, active or suspended ones at most every 60 s (the first read after a running PodGroup's pods stop is not cached), at most 20 reads and 10 s per run, PodGroups that were running first. While its Job is not read, a running PodGroup is still counted until its last pod finished and a waiting one contributes nothing; after 3 failed reads, or at once on a Forbidden error, it is handled as having no known owner, like the Python check.
  • Settings (all off by default): cluster_agent.kueue.goodput.enabled (requires cluster_agent.kueue.enabled), cluster_agent.kai_scheduler.goodput.enabled (requires cluster_agent.kai_scheduler.enabled) and cluster_agent.kai_scheduler.goodput.scheduler_name (default kai-scheduler, for installs such as NVIDIA Run:ai). The check needs leader_election. KAI needs RBAC for the Cluster Agent to list/watch pods cluster-wide and get batch jobs.

    The goodput data is added to the SchedulerEvents payload of the Kueue Workload and KAI PodGroup entities, filled only when the flag is on and not part of the kube metadata stream, so node Agents get no new data and their binaries do not grow. IsLeader is moved next to RunLeaderElection and shared with job_scheduler_events.

    Motivation

    Scheduling goodput answers "are my workloads waiting too long to get the GPUs they requested?" for the Accelerator Telemetry fleet allocation use cases. The prototype lived in the Python node checks, which needed a leader-only hack for Kueue and a "one instance only" rule for KAI. With the job scheduler work moving to the Cluster Agent (#61005), the cluster-level view and leader election make it a better home.

    Design: scheduling goodput, job scheduler split. Python reference and review history: DataDog/integrations-core#26012.

    Describe how you validated your changes

    Unit tests for the parsers and the check, with the design-doc scenarios ported from integrations-core#26012: normal run, not enough resources, partial scheduling, admitted but unable to run, preemption, Kueue quota exhausted, and 18 overlapping workloads whose series must sum to the right GPU-hours in every grouping. Also the reason mapping, gpu_type (flavors, mixed flavors, pod selectors), the KAI cutoffs (last pod, Job end, earlier attempts), Job reads that are skipped or fail, leader and follower runs, the pod informer lifecycle (start, stop, restart, not synced) and Cancel racing Run.

    dda inv test --race on the touched packages, dda inv linter.go (cluster-agent), dda inv schema.lint, the release note lint, gazelle, the tag manifest, buildifier and dda inv cluster-agent.build pass. Every commit builds on its own.

    Run on a local kind cluster (8 fake GPUs) with Kueue v0.20.7 (waitForPodsReady), KAI Scheduler v0.19.0 and a fakeintake, at c0ff6443483. In every scenario the GPU-seconds match seconds × GPUs from the Kubernetes timestamps within one 15 s interval per transition, with the expected reason, scheduler_reason and tags:

  • Kueue: quota wait then running, with the last interval cut at Finished; quota exhausted (WaitingForQuota); request above the queue maximum (ExceedsMaxQuota, reason:configuration_or_request as in the doc's category table); admitted but unable to run (WaitForStart); preemption (preemption_or_reclaim until readmitted); gpu_type from the ResourceFlavor; ClusterQueue tag on unadmitted Workloads.

  • KAI: normal Job cut at the last pod; partial scheduling (PartiallyRunning); retry wait then Job failure (NoPods); no get jobs RBAC (warning, unknown-owner fallback, nothing kept forever).

  • Restart (one interval lost for both schedulers), flags off (check not scheduled), one badput and one fully admitted point per workload per run, no host, check status OK.
  • Additional Notes

    - workloadmeta has no freshness signal, so if the Workload or PodGroup watch breaks, the check keeps counting the last state it saw instead of starting a new baseline.
    - KAI: the 60 s cache of an active owning Job can overcount badput by up to 60 s for a PodGroup without pods whose Job finishes while cached. Accepted to keep Job reads bounded.
    - Kueue: recovery badput is submitted when the recovery ends, not over the intervals it covers. It is dropped if the Workload disappears, cannot be read, or the leader changes during the recovery.

  • For Kueue workloads with partial admission, GPU time is based on the admitted pod count. Pods requested but not admitted are not counted as waiting GPU time.

  • Not covered by the doc either: KAI gpu_type only comes from what the pods require, not from the GPU actually assigned.

  • Follow-ups: Helm chart and Operator settings and RBAC, gpu/metadata.csv wording in integrations-core, a metric source and origin mapping for job_scheduler_goodput (needs a dd-source origin ID; until then the series have unknown origin), and an e2e test with fakeintake (owned by Accelerator Telemetry, after the kind validation).
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: gjulianm Review duration: 4651m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #61760"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%