Skip to content

fix(k8s): read the GPU family label as an architecture fallback #7640

Description

@devops-cli-service

Split from #7437.

Problem The GPU placement code names the node label nvidia.com/gpu.architecture through CONST_K8S_GPU_ARCHITECTURE_LABEL (src/devops_cli/k8s/gpu_thresholds.py, src/devops_cli/k8s/gpu_placement.py). The homelab NodeFeatureRule copies GPU Feature Discovery's nvidia.com/gpu.family into nvidia.com/gpu.architecture only because this code names that key. When the code reads the family label too, the environment can drop the copied label. ## Why this part is deferred The earlier proposal of #7437 asked a test to pass a node label map to _newest_architecture. That is wrong. _newest_architecture(template: dict[str, Any]) -> str at src/devops_cli/k8s/gpu_thresholds.py:116 takes a DaemonSet manifest template and reads its node selector terms. The work also needs a NodeFeatureRule and a manifest change in the homelab environment tree, which is not this repository. The warning fix of #7437 ships on its own. ## Acceptance criteria - The GPU threshold code MUST read nvidia.com/gpu.family from the node selector terms of a DaemonSet template when the template holds no nvidia.com/gpu.architecture term. - WHEN A test passes a DaemonSet template whose node selector terms hold one nvidia.com/gpu.family match expression with the value ampere, and no nvidia.com/gpu.architecture term. - THEN _newest_architecture returns ampere. - The GPU threshold code MUST keep the nvidia.com/gpu.architecture term first when a template holds both keys. - WHEN A test passes a DaemonSet template whose node selector terms hold both keys with different values. - THEN _newest_architecture returns the nvidia.com/gpu.architecture value. - The check in src/devops_cli/k8s/gpu_placement.py MUST keep comparing DaemonSet match expressions against node labels as Kubernetes does. - WHEN A node holds only nvidia.com/gpu.family and the DaemonSet requires nvidia.com/gpu.architecture. - THEN the placement report states that the node does not accept the DaemonSet.

Proposed design

Problem statement

The GPU threshold code reads only nvidia.com/gpu.architecture from DaemonSet node selector terms. The homelab environment copies nvidia.com/gpu.family into that label only because of this code. This change reads the family label as a fallback, keeps the architecture label first, and leaves placement matching exact.

Acceptance criteria

Requirement: Family label fallback

The GPU threshold code SHALL read nvidia.com/gpu.family from the node selector terms of a DaemonSet template when the template holds no nvidia.com/gpu.architecture term.

Scenario: Family-only template

  • WHEN A test passes a DaemonSet template whose node selector terms hold one nvidia.com/gpu.family match expression with the value ampere, and no nvidia.com/gpu.architecture term.
  • THEN _newest_architecture returns ampere.

Requirement: Architecture label precedence

The GPU threshold code MUST keep the nvidia.com/gpu.architecture term first when a template holds both keys.

Scenario: Both labels present

  • WHEN A test passes a DaemonSet template whose node selector terms hold both keys with different values.
  • THEN _newest_architecture returns the nvidia.com/gpu.architecture value.

Requirement: Exact placement matching

The GPU placement check MUST compare DaemonSet match expressions against node labels by exact label key, as Kubernetes does.

Scenario: Family label does not satisfy architecture requirement

  • WHEN A test passes a GPU node labelled nvidia.com/gpu.family=ampere and nvidia.com/gpu.total-vram=24, and a tier whose required term names nvidia.com/gpu.architecture=ampere and nvidia.com/gpu.total-vram=24.
  • THEN placement_warnings returns the MESSAGES.k8s.gpu_node_architecture_not_accepted warning for that node.

Existing Tool Considered

No alternatives check has run. No open tool or library covers this need: NVIDIA GPU Feature Discovery publishes nvidia.com/gpu.family, but it does not read DaemonSet templates or render GPU thresholds. The change extends the existing gpu_thresholds.py functions. Written cost: about 2,000 tokens to write and test, about 1,000 tokens for each later change, and less than 1 hour of elapsed time.

Key questions

  • What input does _newest_architecture take, and which label does it read today?: It takes a DaemonSet manifest template. It reads spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms and selects the newest value of nvidia.com/gpu.architecture from matchExpressions. [sources: src/devops_cli/k8s/gpu_thresholds.py:116, src/devops_cli/config/constants.py:1183]
  • When a template holds both nvidia.com/gpu.architecture and nvidia.com/gpu.family, which label wins?: The architecture label wins. The code reads architecture values when any architecture match expression exists. It reads family values only when no architecture expression exists. (best practice) [sources: src/devops_cli/k8s/gpu_thresholds.py:116, src/devops_cli/config/constants.py:1183]
    • Chosen: Architecture first, family fallback. This keeps the current label first and adds family only when architecture is absent.
    • Rejected: Family first, architecture fallback. This changes the current priority and breaks the issue requirement.
    • Rejected: Merge both label value sets. This can select a family value over an architecture value and breaks the issue requirement.
  • Should gpu_placement.py treat nvidia.com/gpu.family as nvidia.com/gpu.architecture when it checks a node?: No. Kubernetes matches label keys exactly. The placement check keeps exact matching, and the family fallback stays in the threshold render. (best practice) [sources: src/devops_cli/k8s/gpu_placement.py, src/devops_cli/k8s/gpu_thresholds.py:116]
    • Chosen: Keep exact label matching. This matches Kubernetes node selector behavior and the issue requirement.
    • Rejected: Alias family to architecture in placement. This reports a node as accepted when Kubernetes does not schedule the pod.
  • Where does the NodeFeatureRule and manifest change live?: They live in the homelab environment tree in dan-petty/homelab, not in this repository. This issue changes only the devops-cli code. [sources: CONTEXT.md]
  • Should the family label key be a named constant?: Yes. Add CONST_K8S_GPU_FAMILY_LABEL = "nvidia.com/gpu.family" next to CONST_K8S_GPU_ARCHITECTURE_LABEL, and import it in gpu_thresholds.py. (best practice) [sources: src/devops_cli/config/constants.py:1183, src/devops_cli/k8s/gpu_thresholds.py:116]
    • Chosen: Named constant. It keeps one source for label keys and avoids a duplicated literal.
    • Rejected: Literal in the function. It hides the label key and makes later changes harder.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    scope/k8s
    source/agent
    status/new
    on Nov 28, 2026
  2. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    ContributorAuthor
  3. added
    value/medium
    effort/low
    priority/p2-medium
    on Nov 28, 2026
  4. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    ContributorAuthor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 29, 2026
  6. removed
    status/in-review
    owner/agent
    on Nov 29, 2026
  7. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    ContributorAuthor

    Live since 2026-11-29 16:17 UTC

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/k8ssource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions