Skip to content

fix(cdi): use a unique CDI annotation key per resource pool - #355

Open
rollandf wants to merge 1 commit into
Mellanox:masterfrom
rollandf:cdi-key
Open

rollandf wants to merge 1 commit into
Mellanox:masterfrom
rollandf:cdi-key

Conversation

@rollandf

Copy link
Copy Markdown
Member

When useCdi is enabled, the CDI annotation key was derived only from the CDI vendor and kind (cdi.k8s.io/nvidia.com_net-rdma), so every resource pool returned the same key from Allocate. Kubelet merges the annotations of all resources allocated to a container into a single map, so when a container requested several RDMA resources only one annotation survived and only one device was injected.

Include the pool (resource) name in the annotation key, e.g. cdi.k8s.io/nvidia.com_net-rdma_. If the pool name would produce an invalid key (over 63 characters, or not ending with an alphanumeric character), fall back to a short SHA-256 hash of the pool name.

Fixes: https://redmine.nvidia.com/issues/5369341

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Gives each resource pool a stable CDI annotation key so kubelet can keep annotations from multiple pools.

  • CDI allocations keep a separate annotation for each pool.

No actionable issues were found. Tests were inspected but not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Allocate for each pool] --> B[Hash CDI prefix and pool name]
  B --> C[Create pool-specific annotation key]
  C --> D[Kubelet merges annotations]
  D --> E[Runtime reads unchanged CDI device names]
Loading

Reviews (2) · Last reviewed commit: "fix(cdi): use a unique CDI annotation ke..." · Reviewed by Greptile

When useCdi is enabled, the CDI annotation key was derived only from
the CDI vendor and kind (cdi.k8s.io/nvidia.com_net-rdma), so every
resource pool returned the same key from Allocate. Kubelet merges the
annotations of all resources allocated to a container into a single
map, so when a container requested several RDMA resources only one
annotation survived and only one device was injected.

Include the pool (resource) name in the annotation key, e.g.
cdi.k8s.io/nvidia.com_net-rdma_<pool>. If the pool name would produce
an invalid key (over 63 characters, or not ending with an
alphanumeric character), fall back to a short SHA-256 hash of the
pool name.

Fixes: https://redmine.nvidia.com/issues/5369341

Signed-off-by: Fred Rolland <frolland@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants