Repository navigation
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Per-node idempotence, shared-capacity selection, and reconfiguration accounting can violate allocation guarantees.
Review effort: Balanced
Findings: 1
Open (4)
What changed in this PR
Implements topology-aware DRA CPU claim allocation and release.
Changes:
- Allocates claim CPUs by NUMA topology and returns CDI edits.
- Excludes claimed CPUs from pool supplies and restores them on release.
- Adds allocation, rollback, release, and reconfiguration tests.
| File | Description |
|---|---|
topology-aware-policy.go |
Tracks claims and reapplies them during reconfiguration. |
resources.go |
Adds claim/unclaim supply accounting. |
dra.go |
Implements topology-aware claim lifecycle. |
dra_test.go |
Tests DRA allocation and accounting behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
a1bb176 to
f4dd220
Compare
f4dd220 to
be437ab
Compare
be437ab to
751b471
Compare
751b471 to
db70637
Compare
db70637 to
645ec1a
Compare
ec6eca1 to
32a15b5
Compare
467f77b to
6fe1982
Compare
6fe1982 to
dae0c31
Compare
7cb21ff to
59ea171
Compare
59ea171 to
8cc6dd0
Compare
8cc6dd0 to
1268fdd
Compare
1268fdd to
4586fa5
Compare
4586fa5 to
73180be
Compare
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
73180be to
a22b69f
Compare
klihub
left a comment
There was a problem hiding this comment.
@bart0sh There is one more thing related to this and DRA-claimed CPUs in general that I think we should add. However, since it could use a small addition to pkg/resmgr/policy and I've missed that earlier in the review, we can add that with a separate, self-contained, additional PR in this stack as well.
We should extend ExportResourceData() and the related existing commonly defined consts in resmgr/policy to expose per container the DRA-claimed CPU sets, in addition to the currently exposed isolated, exclusive, and shared CPU sets.
Sounds good. I'll do this in a separate PR. |
askervin
left a comment
There was a problem hiding this comment.
Only a tiny nit, that is so tiny that I'm perfectly fine this getting merged as is.


Allocating and releasing CPUs for claims
The topology-aware policy implements
AllocateClaimandReleaseClaimnow, so a claim against the NUMA devices #820 publishes gets CPUs of those nodes, and thetest42-dra-devicese2e test is extended to claims.What a claim gets
Each allocation result names a NUMA node device, and consumes some
dra.cpu/cpuof it.AllocateClaimdecodes that into a number of CPUs per node.For each node it picks that many CPUs out of the node's free, grantable CPUs, isolated plus sharable less reserved, with the same
cpuAllocatoran exclusive grant uses. Two CPUs are therefore the two threads of one core, not one thread of each of two cores. Several results on one node get disjoint CPUs, and if one result cannot be filled, nothing stays claimed.The container gets one CDI edit per result, each setting
DRA_CPUSET_<claim UID>=<cpuset>to the whole claim's CPUs.ReleaseClaimgives the CPUs back, and releasing an unknown claim is not an error, as the kubelet may unprepare a claim more than once.A claim is a grant
A claim's CPUs are held as a grant, the policy's existing record of what is allocated: exclusive CPUs reserved from the deepest pool holding all of them, with no shared portion and no memory. Claim grants are kept beside the container grants in
allocations, keyed by claim UID, and a claim grant has no container. So the NRI path cannot hand claimed CPUs to an exclusive or shared grant while the claim lives, and the claim is checked, dumped and saved with the other grants. Claim UIDs and container IDs stay separate keyspaces: in the saved state a claim grant is keyedclaim:<uid>.Reserving the grant refuses CPUs another grant holds, and refuses sharable CPUs whose loss would overcommit the shared portions already granted, as for any exclusive grant.
After a claim or release,
updateSharedAllocationsrecomputes the shared cpusets, so shared containers move off claimed CPUs and back onto released ones.Reconfigurerebuilds the pool tree and reinstates the claim grants before the container grants. A claim's CPUs cannot move, so a configuration which would take a claimed CPU away from us, by reserving it for example, is refused and the old configuration stays.What is not here
These are known limitations, each lifted by a later PR in the series:
DeviceClassships yet, so a claim needs one written by the user. The e2e test creates its own.Verification
serversysfs. They cover one and several results on one or two nodes, a whole node, a node less its reserved CPUs, and each refused result, including a claim with no results. They also check picking by topology, re-preparing a claim, disjoint claims and exhaustion, a failed multi-result claim leaving nothing claimed, release, aReconfigurewhich keeps claims and one refused for reserving a claimed CPU, and a claim and a container with the same ID both surviving a reconfiguration and a round trip through the cache.Reconfigure, skipping the release, and picking anew on a repeated prepare.AllocateClaimalready picks only what the shared containers can spare, so the test reserves directly.test42-dra-devicespasses on n4c16 with Kubernetes 1.37 and theDRAConsumableCapacityandDRANodeAllocatableResourcesgates. With CPU 15 reserved, the devices offer exactly 4, 4, 4 and 3 CPUs. A claim for all of node 3 gets 12-14. Two 2-CPU claims on node 1 get one core each, 4-5 and 6-7. A third stays unscheduled until the first is deleted, then gets 4-5. A besteffort container runs on no claimed CPU, gives up the two CPUs a claim takes of its node, and gets them back on release.