You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support per-request CPU allocation in multi-request ResourceClaims - #407
Today the driver writes one CDI device per claim (DRA_CPUSET_=) and binds one container to the entire claim. If a ResourceClaim has two requests (a, b) and two containers in the same pod reference request: a and request: b, the first container gets CPUs for both requests and the second fails with CreateContainerError.
This PR splits claim allocations, CDI devices, and container bindings per request so each container in a pod gets only the CPUs for the request it references.
Support per-request CPU allocation for multi-request ResourceClaims so different containers in the same pod can bind distinct requests of one claim and receive only their own request's CPUs.
AI usage disclosure
YES — used an AI coding assistant to help draft, refactor, and review the implementation, unit/E2E tests, and documentation. All changes were reviewed and verified by the author.
Summary by CodeRabbit
New Features
Multi-request CPU claims can now assign separate requests to different containers within the same pod, with request-specific CPU allocations and metadata.
Added an example showing how to configure a pod with multiple requests in one claim.
Bug Fixes
Claims cannot be shared across pods, and the same request cannot be assigned to multiple containers. Invalid assignments leave the pod pending with an error.
Documentation
Updated guidance on claim sharing, CPU requests and limits, and per-request CDI behavior.
Added upgrade and rollback guidance for the new per-request behavior.
Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
Walkthrough
The driver now allocates and tracks CPU sets by ResourceClaim request, emits request-specific CDI devices and environment variables, and binds requests to containers within one pod. Tests, examples, and documentation cover multi-request claims, ownership, synchronization, and upgrade or rollback behavior.
Changes: Request-scoped allocation state
Layer / File(s)
Summary
Request-level binding and ownership pkg/store/allocation_state.go, pkg/store/allocation_state_test.go
Allocation state now binds containers to specific claim requests, validates request CPU sets, and tracks claim ownership by pod.
End-to-end tests and the example cover per-request allocation and container mapping. The documentation describes claim ownership, CDI entries, workload requirements, and upgrade or rollback behavior.
#390: This change allows containers in one pod to bind different requests from the same ResourceClaim, addressing the issue’s one-container-per-claim restriction.
The new per-request claim handling looks sound for the main scenario in the linked issue. Upgrading a node in place can lose recorded pod/container ownership of already-prepared claims, because the checkpoint format changed without a version bump or migration. Fix that, resolve the merge conflict, and tighten a few store consistency checks before merging.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Linked Issues check
Issue #389 has one direct link and no closed or contextual status. Its coding requirement is inferred from the reported symptoms. The PR changes ownership from one owner per claim to one owner per req…
Clarify the expected behavior in #389 when two containers in one pod reference the same request of a multi-request claim. Specify whether the second container must start with the same CPUs, must start with no CPUs, or must be rejected with …
Passed checks: 3 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: per-request CPU allocation for ResourceClaims that contain multiple requests. The changeset splits claim allocations, CDI specs, and container bindings by request, whi…
Out of Scope Changes check
The changes address per-request allocation, which #389 requires. The changed areas are: - pkg/store/allocation_state*.go: per-request ownership and checkpoint format. - pkg/driver/cdi.go, `dra_hoo…
Full details: Title check
Explanation
The title names the main change: per-request CPU allocation for ResourceClaims that contain multiple requests. The changeset splits claim allocations, CDI specs, and container bindings by request, which matches the title. The title is specific and does not cover every detail, which is expected.
Full details: Out of Scope Changes check
Explanation
The changes address per-request allocation, which #389 requires. The changed areas are:
pkg/store/allocation_state*.go: per-request ownership and checkpoint format.
pkg/driver/cdi.go, dra_hooks.go, nri_hooks.go: per-request CDI devices and env vars, with request-keyed binding.
Matching unit tests and mocks.
E2E helpers and tests for per-request and multi-request claims.
Docs and an example YAML that describe the new model.
The FirstAvailable subrequest handling and the legacy DRA_CPUSET_<uid> compatibility support the per-request split. They are not separate features. The upgrade and rollback documentation describes behavior that this PR changes, so it is related. No change was found that is unconnected to the request-scoped allocation.
Full details: Linked Issues check
Explanation
Issue #389 has one direct link and no closed or contextual status. Its coding requirement is inferred from the reported symptoms. The PR changes ownership from one owner per claim to one owner per request. The summary and docs state that a container can map to a request and that a container without request maps to all requests. Two sub-cases follow from this design:
Containers that reference different requests of one claim (for example c1->a, c2->b): The summary shows that Bind and CreateContainer bind per-request CPUs. The new tests in nri_hooks_test.go (TestCreateContainerMultiRequest) and allocation_state_test.go cover this case. The E2E test verifyPerRequestClaim checks distinct CPUs per container. This sub-case is implemented.
Two containers that both reference request a (the exact scenario in #389): The docs and allocation_state.go still reject this. Bind rejects "binding a request to another container", and docs state that violations cause CreateContainerError. The issue text does not state the expected result for this case. It lists only the failures. It is therefore unclear whether the still-present rejection satisfies #389, or whether the issue requires c2 to start.
The repository was not inspected for the issue's intended outcome. The issue body contains no acceptance criteria.
Resolution
Clarify the expected behavior in #389 when two containers in one pod reference the same request of a multi-request claim. Specify whether the second container must start with the same CPUs, must start with no CPUs, or must be rejected with a specific error. Then reassess the same-request case against that behavior. Use the code paths (*AllocationState).Bind and IsOwner in pkg/store/allocation_state.go for that check.
kubernetes-prowBot
added
approved
Indicates a PR has been approved by an approver from all required OWNERS files.
needs-rebase
Indicates a PR cannot be merged because it has merge conflicts with HEAD.
cncf-cla: yes
Indicates the PR's author has signed the CNCF CLA.
size/XXL
Denotes a PR that changes 1000+ lines, ignoring generated files.
labels
Nov 28, 2026
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Minor · Check request CPU assignments on repeat reservation. · allocation_state.go:348-350
pkg/store/allocation_state.go:348-350 Minor · Data Integrity & Integration · Quick win
Check request CPU assignments on repeat reservation.
If the store has x={2}, y={3}, Reserve also accepts x={3}, y={2} because the claim CPU set is unchanged. It keeps the first split. A subsequent Bind for x={3} then fails. Synchronize passes the CDI request map to Reserve and then passes the request CPU set to Bind, so this mismatch can surface after reservation reports success. Compare named assignments before returning success. Preserve the aggregate-only legacy repeat against the same claim CPU set. (raw.githubusercontent.com)
Additional comments: 1
pkg/store/allocation_state.go: 1
164-164: Minor · Data Integrity & Integration · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Reject an empty request key mixed with named requests.
The shared validator accepts ""={2}, y={3}. If a prepare retry needs x, it falls back to "" and emits a legacy CDI device for CPU 2. Bind interprets that key as the whole claim and rejects it because the claim has CPUs 2 and 3. Reject mixed maps in the shared validator so both reservation and checkpoint restore enforce the same rule. Keep the singleton empty-key format described in docs/user/upgrade.md. (raw.githubusercontent.com)
Reviewing files that changed from the base of the PR and between 27682fa and 9a6f321.
Files selected for processing: 22
docs/user/feature-support.md
docs/user/how-it-works.md
docs/user/upgrade.md
docs/user/workload-requirements.md
hack/examples/pod_with_multi_request_claim.yaml
pkg/driver/cdi.go
pkg/driver/cdi_test.go
pkg/driver/dra_hooks.go
pkg/driver/dra_hooks_test.go
pkg/driver/driver.go
pkg/driver/nri_hooks.go
pkg/driver/nri_hooks_test.go
pkg/driver/nri_reconnect_test.go
pkg/driver/startup_test.go
pkg/driver/synchronization_test.go
pkg/store/allocation_state.go
pkg/store/allocation_state_checkpoint.go
pkg/store/allocation_state_checkpoint_test.go
pkg/store/allocation_state_test.go
test/e2e/cpu_assignment_test.go
test/e2e/e2e_suite_test.go
test/e2e/metadata_test.go
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
…ner bindings
Currently we track ownership per container using {PodUID, ContainerName}, and Bind/Unbind/IsOwner operate on the whole claim UID.
That prevents containers in the same pod from binding different requests of a multi-request claim, and doesn't cleanly
enforce that a claim belongs to a single pod across sibling requests.
This commit splits ownership into a single ownerPod on the claim and a list of bound container names per request.
Containers in the same pod can now bind separate requests. The v1 checkpoint schema and existing callers are updated to match.
CDI specs are not updated yet, this prepares for follow up commit that split CDI and DRA/NRI hooks per request.
Currently each claim CDI spec file holds a single device (claim-<uid>) with one
env var (DRA_CPUSET_<uid>=<cpus>), so kubelet cannot filter CDI devices per
request.
This commit updates CdiManager to store multiple devices in the claim's single
spec file (so follow-up commits can write per-request entries like
claim-<uid>_<request> with DRA_CPUSET_<uid>_<request>=<cpus>) and read env vars
across all devices in that spec.
Split prepared CPU allocations and CDI devices by base request name so
containers referencing a single request of a multi-request ResourceClaim
receive only that request's CPUs.
Update NRI CreateContainer and Synchronize to parse, validate, and
bind per-request allocations while keeping compatibility with legacy whole-claim DRA_CPUSET_<uid> entries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
approvedIndicates a PR has been approved by an approver from all required OWNERS files.cncf-cla: yesIndicates the PR's author has signed the CNCF CLA.kind/featureCategorizes issue or PR as related to a new feature.size/XXLDenotes a PR that changes 1000+ lines, ignoring generated files.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind feature
What this PR does / why we need it
Today the driver writes one CDI device per claim (DRA_CPUSET_=) and binds one container to the entire claim. If a ResourceClaim has two requests (a, b) and two containers in the same pod reference request: a and request: b, the first container gets CPUs for both requests and the second fails with CreateContainerError.
This PR splits claim allocations, CDI devices, and container bindings per request so each container in a pod gets only the CPUs for the request it references.
Which issue(s) this PR is related to
Fixes #389
Special notes for reviewers
Release note
AI usage disclosure
YES — used an AI coding assistant to help draft, refactor, and review the implementation, unit/E2E tests, and documentation. All changes were reviewed and verified by the author.
Summary by CodeRabbit