← Back to Pull requests

feat(workloadmeta): collect GPU topology data in the Cluster Agent #61824

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Dec 02, 2026 10:14 UTC
Author

What does this PR do?

Adds to the Cluster Agent's workloadmeta the data the upcoming gpu_topology check needs to compute the gpu.scheduling.topology. metrics. That check reports how GPUs are used across the Kueue or KAI Scheduler topology levels: block, rack, host. Everything is behind a new gpu_topology.enabled setting (default false). It requires cluster_agent.kueue.enabled or cluster_agent.kai_scheduler.enabled (or both).

  • New KubernetesKueueTopology kind. It holds the cluster-scoped Kueue Topology and its ordered spec.levels[].nodeLabel, read on whichever served version the API server picks (v1alpha1/v1beta1/v1beta2). The kind isn't streamed to node Agents and the tagger ignores it.

  • New KubernetesKAITopology kind. It holds the cluster-scoped KAI Scheduler Topology (kai.scheduler/v1alpha1, a different API group from the KAI PodGroups) and its ordered spec.levels[].nodeLabel. It's collected when cluster_agent.kai_scheduler.enabled is on, with the same RBAC probe as the Kueue Topology. Like the Kueue kind, it isn't streamed to node Agents and the tagger ignores it.

  • KubernetesKueueResourceFlavor: adds TopologyName and Tolerations.

  • KubernetesNode: adds GPUCapacity and GPUAllocatable per GPU device plugin resource (nvidia.com/gpu, nvidia.com/gpu.shared, amd.com/gpu, gpu.intel.com/i915, gpu.intel.com/xe), plus MIGCapacity and Taints. Keys are kept when the count is 0. The resource list is shared in pkg/util/gpu.

  • Pods: ContainerResources.GPURequests per GPU resource, for containers and init containers. A missing request falls back to the limit. It is only parsed when gpu_topology is on and leader election is enabled.

  • pkg/clusteragent/gputopologygate: Synced() tells the check when the node, pod, ResourceFlavor and Topology stores (Kueue and KAI) have finished their first LIST. Until then every node would look free. The Topology stores are only in the gate, not in the Cluster Agent readiness check; the ResourceFlavor store stays in readiness, as on main.

  • gpu_topology.assumed_tolerations (default []) and gpu_topology.kai.node_pool_label (default kai.scheduler/node-pool, KAI's nodePoolLabelKey) will be read by the check. With KAI, the check reports per (KAI Topology, node pool).
  • <details>
    <summary>Functional changes</summary>

    | Before | After |
    | --- | --- |
    | — | gpu_topology.enabled: true with Kueue on: Kueue Topologies are collected; flavors also keep topologyName/tolerations; nodes keep GPU capacity/allocatable/taints; pods keep per-container GPU requests |
    | Missing RBAC on resourceflavors with gpu_topology on: the flavor store retried forever and blocked readiness | One warning, the store is skipped, readiness isn't blocked. Other errors are still retried |
    | — | gpu_topology.enabled: true with KAI on: KAI Topologies are collected; nodes and pods get the same GPU data as with Kueue. With Kueue off, no Kueue GPU topology store starts |
    | — | Missing RBAC on topologies.kai.scheduler, or no KAI Topology CRD: one warning or info, the store is skipped and the check doesn't wait for it |
    | — | Kueue or KAI Topologies that can't be listed (e.g. broken conversion webhook) only hold back the gpu_topology check, not the Cluster Agent readiness |
    | — | gpu_topology.enabled without cluster_agent.kueue.enabled or cluster_agent.kai_scheduler.enabled, or without leader_election: one warning at startup, no GPU request parsing |

    Unchanged: with gpu_topology off (the default), pod entities, Kueue and KAI collection and readiness, the kube metadata stream and the proto are the same as before.

    </details>

    Motivation

    Step 1 of the topology-aware GPU metrics (design: gpu.scheduling.topology., data layer in DCA workloadmeta). The check itself, and its release note, come in a follow-up PR.

    Pods: since #61355 the pod store always runs when cluster_agent.kueue.enabled is on (KAI also needs pods at startup), and gpu_topology requires one of them. So this PR adds no pod store of its own. It doesn't start one on the leader only, and it doesn't use a field selector or a GPU-only filter. It only adds the GPU requests on top of the init containers that #61395 collects.

    Leader: the check will use the same leader rule as job_scheduler_events (#61005). With leader_election: false no replica is the leader, and nothing is reported. This PR only logs the warning and skips the GPU request parsing in that case.

    Describe how you validated your changes

    Unit tests for every parser change (Kueue and KAI Topology levels, flavor topologyName/tolerations, node GPU maps/MIG/taints, per-resource pod GPU requests for both the minimal and the typed parser, option off = unchanged), the RBAC probe for Kueue and KAI (served version, missing CRD, forbidden, temporary error), the Kueue and KAI topology stores, the gate (synced only after the KAI Topology store syncs), KAI-only and Kueue+KAI gating, the tagger, assumed_tolerations parsing from YAML and env var, and the node_pool_label default and env var.

    Additional Notes

  • Memory: the pod store cost is Kueue's now. This PR adds an 8-byte map field per workloadmeta container, nil unless the container requests a GPU, plus about 250 B per GPU-requesting container when the feature is on. GPU nodes get a few small maps; Topologies are a few strings each. Method: synthetic entities through the real workloadmeta store, heap diff after GC. This doesn't include the tagger's data per pod, which this PR doesn't change.

  • RBAC (Helm/Operator, follow-up): the Cluster Agent needs list/watch on topologies.kueue.x-k8s.io (Kueue) and topologies.kai.scheduler (KAI). resourceflavors and pods are already granted when Kueue is enabled, and pods when KAI is.

  • nvidia.com/gpu.shared counts replicas, not GPUs. The check must report such nodes as unsupported and never add them to GPU capacity.

  • cc @DataDog/container-platform for the kubeapiserver collector / workloadmeta changes.
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: gjulianm Review duration: 3597m
    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 #61824"
    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%