DRA: pin topology-aware containers to their claims #823
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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 #823"
general
weight: 0.35
bart0sh
Pinning containers to their claims
Seventh PR of the DRA series, on top of #821. Three commits: the
topology-aware policy pins a container holding claims to the claims' CPUs, the
test42-dra-devicese2e test checks the pinning, and strict topology hintsno longer fail a container because of its claimed CPUs. Nothing in
pkg/resmgrchanges.
What a claiming container runs on
A container holding claims runs on the CPUs of its claims. A container with no
CPU request of its own, the usual case, runs on its claims only. A container
with a CPU request also gets its normal allocation: exclusive CPUs, and shared
CPUs if it has a shared portion. A container with reserved CPUs, such as one
in
kube-system, gets its reserved CPUs as well if it has a CPU request.Hiding hyperthreads applies to the exclusive CPUs only. The claimed CPUs are
pinned as they are, since they are exactly what the claim asked for.
Strict topology hints apply to the container's own CPUs only. A claim is
allocated before its container exists, so its CPUs cannot follow the
container's hints. Failing the container for that would make strict hints
fail at random for containers with claims. If the claimed CPUs do not match a
strict hint, the policy logs a warning and allows them.
Where a claiming container goes
A claiming container with normal CPUs gets its grant from the pool of the
claimed CPUs, the same pool the claim grant itself came from, rather than from
the pool scoring would pick. So its memory comes from the claims' NUMA node,
and so do its own exclusive and shared CPUs.
A container with reserved CPUs stays in the root pool, like other reserved
containers, and its memory comes from there. The claim's pool usually has no
reserved CPUs, so the container would get normal CPUs there instead.
The CPU shares follow the rule for mixed allocations: they come from the
shared or reserved portion if there is one, otherwise from all the CPUs the
container runs on.
A besteffort container holding a claim is also not counted as a zero-request
shared container of its pool. Otherwise it would hold back a milli-CPU of
shared capacity there, and the last CPUs of its node could not be claimed.
A container's claims are fixed for its lifetime: the kubelet prepares them
before the container is created and unprepares them only after all of the
pod's containers have stopped, so no running container ever holds a released
claim.
updateSharedAllocationsleaves a claiming container with no sharedportion alone. One with a shared portion is updated like any other container,
and keeps its claimed CPUs. Containers with
cpuPreservekeep the cpuset theruntime gave them, as before.
How a container is linked to its claims
The policy reads the
DRA_CPUSET_<claim UID>variable #821 puts in thecontainer's environment. A container holds a claim if it has the variable for
a claim grant the policy holds, and its value names that grant's CPUs. The
value is compared as a cpuset, so
0-1and1,0name the same CPUs. Avariable for an unknown claim, or naming other CPUs, is ignored. No cache or
interface change is needed: the policy looks the variables up with the
existing
GetEnv.This is replaced later in the series: #852 tells claim requests apart by their CDI devices, and drops the variable.
The claims are looked up once, when the container is allocated, and kept on
its grant. Placement, pinning, CPU shares and the shared-pool checks all read
them from there, so pool scoring does not look up every claim for every
container.
This is a temporary approach. The pod spec can set the variable too, so a
pod which knows a claim's UID and CPUs can run on them without holding the
claim. A container's CDI devices name its claims and are set by the runtime
alone, so they are the right link. But not every maintained runtime release
reports them to NRI yet: containerd does from v2.3, CRI-O does not yet. We
switch to CDI device names once every maintained release of both runtimes
reports them.
What is not here
These are known limitations, each lifted by a later PR in the series:
but the policy resets its saved state on start, so after the plugin
restarts their CPUs are free again and can be granted twice.
refreshes it when claimed CPUs leave the free supply.
DeviceClassships yet, so a claim needs one written by the user.The e2e test creates its own.
Verification
go test -race ./cmd/plugins/topology-aware/... ./pkg/resmgr/...passes,and golangci-lint finds no issues.
exclusive, exclusive and shared, reserved, and reserved with no CPU request,
a container holding two claims, a variable naming other CPUs, one naming an
unknown claim, and a claiming container keeping its claim while another
claim comes and goes. For a claiming container it also checks the pool, the
memory zone, the shared or reserved portion and the CPU shares. Each of
these changes fails it: dropping the claimed CPUs from
applyGrant, pinninga claiming container without its own CPUs, skipping every claiming container
in
updateSharedAllocations, placing a reserved container in the claim'spool, and zeroing the container's own CPU request in
newRequest.the rest of its node. It fails if the container is counted as a zero-request
shared container. A third test checks that a container with a strict
topology hint is allocated and keeps its claim, whether the claim matches
the hint or not.
container. A container holding a claim stays on it across a reconfiguration.
Comparing the value as a string, or not carrying the claims onto the grant
or through a reconfiguration, fails the tests.
test42-dra-devicespasses on n4c16 with Kubernetes 1.37, containerdv2.4.1, and the
DRAConsumableCapacityandDRANodeAllocatableResourcesgates. Every claiming container with no CPU request runs on exactly its
claim's CPUs and on memory of its claim's node: 12-14 on node 3, 4-5 and 6-7
on node 1, then 4-5 for the third claim once the first is released. A claim
on the node the besteffort container runs on, node 0 in this run, gets 0-1.
Two containers sharing one claim both run on its CPUs, 0-1, with node 0's
memory. The besteffort container still runs on no claimed CPU and gets
released CPUs back. A pod with a 100m CPU request of its own and a claim on
node 2 runs on CPUs 8-11, all CPUs of node 2: the claimed CPUs plus the
shared ones, with node 2's memory.