← Back to Pull requests

feat(pod-device-mapper): run the pod device mapper apart from the NVIDIA discovery #2543

Closed
unknown closed this pull request without merging on Nov 26, 2026 11:23 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 14:29 UTC
Author

Summary

Part of #2419. Implements ADR-072.

Background

metadata-collector runs two unrelated jobs in one pod:

  • NVIDIA discovery reads NVML and nvidia-smi and writes gpu_metadata.json, which the GPU, syslog and NIC health monitors read.

  • The pod device mapper writes the dgxc.nvidia.com/devices annotation on pods every 30 seconds. A partial drain reads it to evict only the pods that use a failed device.
  • Sharing a pod causes three problems:

    1. The mapper runs only on NVIDIA nodes, because the pod's node selector requires the NVIDIA labels. #2541 lets operators configure other devices for partial drains, but nodes with only those devices get no annotations.
    2. The mapper runs in discovery's privileged pod, with the host network, the host PID namespace, /sys and the CUDA image. Discovery gets the mapper's ClusterRole, which it never uses.
    3. The mapper starts only after the NVML collection succeeds. NVML is most likely to fail on a node with a faulty GPU, and then new pods on that node get no annotation, so partial drains there wait.

    What changes

    A new module, binary and image

    The mapper moves to pod-device-mapper/ with git mv, so its history follows. It does not import metadata-collector or NVML, and golangci-lint (depguard) now fails if it ever imports metadata-collector. The image is built with ko (ghcr.io/nvidia/nvsentinel/pod-device-mapper), and the module is added to the Makefile, ko config, image lists and CI workflows.

    The binary keeps the flag names that the mapper had in metadata-collector (--kubeconfig, --kubelet-kubeconfig, --config, --pod-mapper-max-consecutive-failures, --metrics-port), so a host-native setup only changes the binary.

    metadata-collector keeps only the discovery

    It still accepts the old mapper flags, including a bare --pod-mapper-enabled, and logs that it ignores them, so an older pod spec or host setup keeps starting.

    Two DaemonSets from the same chart

    The metadata-collector chart renders both, so every value that operators set today keeps working:

  • nvidia-metadata-collector runs the discovery, with its pod settings unchanged. It runs without a ServiceAccount token.

  • pod-device-mapper runs the mapper on the pod network, as root (the kubelet's PodResources socket belongs to root) with all capabilities dropped and a read-only filesystem. It keeps the metadata-collector ServiceAccount and ClusterRole. It runs on nvidia.com/gpu.present nodes and does not wait for the driver. It serves metrics on global.metricsPort, which the namespace NetworkPolicy allows and the PodMonitor scrapes. The metric names do not change.
  • New keys: podMapper.image, podMapper.resources (defaults to resources) and podMapper.nodeSelector. An affinity that the operator sets applies to both DaemonSets. The default affinity that follows GPU driver upgrades applies only to the discovery, because the mapper does not use the driver.

    Upgrade

    The upgrade deletes the metadata-collector DaemonSet, so the old mappers stop on all nodes together instead of in a slow rolling update. A node has no mapper until its new pod is ready, and a partial drain there waits for the annotations, as for a pod that the mapper has not seen yet.

    Behaviour to note

  • podMapper.enabled is now compared as a string, so a quoted "false" turns the mapper off. Before, it turned the mapper on.

  • kubeletHost: {value: "10.0.0.1"} used to render an env var with both value and the default valueFrom, which Kubernetes rejects. The mapper now gets only the value. Because the mapper is off the host network, kubeletHost: {} and a loopback value now give the node IP instead of localhost.

  • A query that filters metrics by the metadata-collector pod name no longer matches, and the mapper metrics move from metrics.port on the node to global.metricsPort on the pod.

  • The NIC health monitor's start-up hint now names the nvidia-metadata-collector DaemonSet.

  • The discovery runs as the namespace's default ServiceAccount, without a token. ADR-072 gives it a new ServiceAccount, but the discovery does not call the Kubernetes API, so the ServiceAccount would add nothing.
  • Testing

    Kind cluster

    I installed the metadata-collector chart and image from main on a Kind cluster (Kubernetes 1.35), with the example DRA driver and the Kubernetes sample device plugin. Then I upgraded to this branch's chart and images. The discovery ran on a test image with the NVML injection library of the fake DCGM image, and the mapper on the ko base image.

  • Helm deleted the metadata-collector DaemonSet, its pod stopped at once, and the nvidia-metadata-collector and pod-device-mapper pods ran within 10 seconds.

  • The annotations of all 7 test pods (device plugin, ResourceClaim, extended resource served by DRA, and a pod with both kinds) were identical before and after the upgrade. The first polls of the new mapper made no change, so it reads ResourceSlices from the pod network with the existing RBAC.

  • A pod with a DRA claim created after the upgrade got its annotation from the new mapper.

  • The mapper served its metrics on the pod IP, with 0 failures and a last-success time set. Its pod had no host network or host PID, all capabilities dropped, and the kubelet at the node IP.

  • The discovery pod had no ServiceAccount token, and wrote gpu_metadata.json.

  • The new metadata-collector binary started with the command line of the previous chart, and with a bare --pod-mapper-enabled, and logged the flags that it ignores.
  • <details><summary>Annotations before and after the upgrade</summary>

    ext-test/claim-only           {"devices":{"gpu.example.com":["gpu-cfaafe47-bb6a-ffd7-e24e-cf6fcc554a25"]}}
    ext-test/ext-and-claim        {"devices":{"gpu.example.com":["gpu-2140ea3e-4eff-d585-ac09-f45be74add75","gpu-71ae8bad-cbba-fd6e-18bc-73affd1e4036"]}}
    ext-test/ext-only             {"devices":{"gpu.example.com":["gpu-4c113543-c0b7-748e-7801-b2757b6b2693"]}}
    mapper-test/claim-new         {"devices":{"gpu.example.com":["gpu-b5a89175-d921-d637-0c33-360380f8cd8c"]}}
    mapper-test/no-device         -
    mapper-test/plugin-and-claim  {"devices":{"example.com/resource":["Dev-2"],"gpu.example.com":["gpu-9c071412-c92b-a6f7-a17f-7ef02b769353"]}}
    mapper-test/plugin-new        {"devices":{"example.com/resource":["Dev-1"]}}
    

    </details>

    <details><summary>Pods during the upgrade</summary>

    t+5s   metadata-collector-sv95k(Terminating) nvidia-metadata-collector-x58r9(Pending) pod-device-mapper-5kc2x(ContainerCreating)
    t+10s  nvidia-metadata-collector-x58r9(Running) pod-device-mapper-5kc2x(Running)
    

    </details>

    <details><summary>Old flags on the new metadata-collector binary</summary>

    $ metadata-collector --output-path=... --pod-mapper-enabled=true --pod-mapper-max-consecutive-failures=10 --config=/etc/config/config.toml --metrics-port=0
    INFO  Starting metadata-collector
    WARN  Ignoring the flags of the pod device mapper, which runs in pod-device-mapper  ["config","pod-mapper-enabled","pod-mapper-max-consecutive-failures"]
    INFO  Metadata collector completed successfully
    

    </details>

    GPU cluster

    A GKE cluster with 18 GPU nodes (arm64, 4 NVIDIA GB200 each, GPU Operator device plugin) ran NVSentinel from main. I upgraded its metadata-collector to this branch at b21e6fa5. I rendered this branch's metadata-collector chart with the values of the installed release and applied it in Helm's order: the new objects first, then the deletion of the metadata-collector DaemonSet. The images were built from this branch for arm64: pod-device-mapper with ko, and metadata-collector on the base image of its Dockerfile. I ran the upgrade twice, and reverted the cluster after each run.

  • The old pods were gone 6 to 9 seconds after the deletion, and both new DaemonSets had 18 of 18 pods ready.

  • The annotations of 4 test pods on 3 nodes, written by main before the upgrade, were identical after it.

  • Two pods created after the upgrade got their annotations from the new mapper, with the UUIDs from each node's gpu_metadata.json. The mapper ran on a pod IP and reached the kubelet at the node IP.

  • I scraped all 36 new pods twice, about 70 seconds apart, from inside the cluster's Prometheus pod. Every mapper had 0 failures and a last-success time that moved forward between the scrapes. Every discovery pod reported its collection time. The nvsentinel PodMonitor selects all 36 pods.

  • The mapper pod had no host network, all capabilities dropped and a read-only root filesystem. The discovery pod had no ServiceAccount token.
  • <details><summary>Annotations before and after the upgrade (UUIDs shortened)</summary>

    # Written by main before the upgrade; identical after it
    a-one-gpu     node A  {"devices":{"nvidia.com/gpu":["GPU-8ed111ca…"]}}
    a-two-gpus    node A  {"devices":{"nvidia.com/gpu":["GPU-1ca2785e…","GPU-ed6863b2…"]}}
    b-four-gpus   node B  {"devices":{"nvidia.com/gpu":["GPU-0971896b…","GPU-1f692888…","GPU-8cf65c03…","GPU-dad17a2a…"]}}
    c-one-gpu     node C  {"devices":{"nvidia.com/gpu":["GPU-a730235e…"]}}
    
    # Created after the upgrade, annotated by the new mapper
    new-a-one-gpu   node A  {"devices":{"nvidia.com/gpu":["GPU-98654403…"]}}
    new-d-two-gpus  node D  {"devices":{"nvidia.com/gpu":["GPU-05d2faba…","GPU-1ab2fef3…"]}}
    
    # gpu_metadata.json of the new discovery pods (index, UUID, PCI address)
    node A  0 GPU-1ca2785e… 0000:89:00.0   1 GPU-ed6863b2… 0000:8a:00.0   2 GPU-8ed111ca… 0000:c1:00.0   3 GPU-98654403… 0000:c2:00.0
    node D  0 GPU-ac0b32d8… 0000:89:00.0   1 GPU-75b7f02f… 0000:8a:00.0   2 GPU-1ab2fef3… 0000:c1:00.0   3 GPU-05d2faba… 0000:c2:00.0
    

    </details>

    <details><summary>Metrics of the new pods, two scrapes about 70 seconds apart</summary>

    # 18 of 18 mappers, scraped at the pod IP, port 2112. Two of them:
    pod-device-mapper  node A  failures_total=0 consecutive_failures=0 last_success 1795666734 -> 1795666854
    pod-device-mapper  node D  failures_total=0 consecutive_failures=0 last_success 1795666705 -> 1795666855
    
    # 18 of 18 discovery pods, scraped at the node IP, port 2112. Two of them:
    nvidia-metadata-collector  node A  collection_completed_timestamp_seconds=1795666676
    nvidia-metadata-collector  node D  collection_completed_timestamp_seconds=1795666677
    

    </details>

    Type of Change


  • 🐛 Bug fix

  • ✨ New feature

  • 💥 Breaking change

  • 📚 Documentation

  • 🔧 Refactoring

  • 🔨 Build/CI
  • Component(s) Affected


  • Health Monitor

  • Core Service

  • Fault Management

  • Janitor

  • Deployment/Config

  • API/Interface

  • Preflight

  • Plugins

  • Documentation/CI

  • New Component

  • Multiple Components

  • Other
  • Checklist


  • Self-review completed

  • Documentation updated (if needed)

  • Ready for review
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Added the Pod Device Mapper as a separate Kubernetes DaemonSet that records pod-device annotations for partial drains. Configure its node selection, resources, metrics, and kubelet connectivity.
    When the mapper is disabled, partial drains wait rather than fail.
    The NVIDIA Metadata Collector runs separately from the mapper.
    Documentation
    Added setup and configuration guides covering deployment, authentication, and troubleshooting.
    * Clarified the components’ responsibilities and documented their metrics endpoints.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: lalitadithya Review duration: 1253m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). 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.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2543"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 20.5% · Safe to merge
    20.5%