DRA template policy #817
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 #817"
general
weight: 0.35
klihub
DRA template policy
The first policy that allocates claims
Fourth PR of the DRA series, on top of #806. Until now every backend answered
AllocateClaimwithpolicy.ErrNoDRAClaims. Here the template policy gets areal implementation, so a claim can be prepared end to end on a cluster for the
first time. Template is the file people copy when they write a policy, so every
choice below is the simplest one that still works.
Four commits, in order: the policy, its DeviceClass and docs, feature
gate support in the e2e harness, and an e2e test that runs the whole path.
One device, consumable capacity
Template publishes one device,
cpus, withallowMultipleAllocationsand adra.cpu/cpucapacity equal to the number of CPUs it is allowed to hand out(KEP-5075). The allowed CPUs are
availableResources.cpuif that is a cpuset,else all online CPUs, minus
reservedResources.cpuif that is a cpuset. Thepublished value is the device's total: the scheduler subtracts each claim's
ConsumedCapacityitself, so the slice never changes while the plugin runs.The device is pushed through
PublishDRADevices(#803) once, fromStart. ACPU configuration DRA cannot use, available CPUs given as a quantity for
instance, only logs a warning and publishes no devices: failing
Startwouldalso stop template for everyone running it with DRA off, and with no devices
there are no claims to fail on it.
The request policy is
Default: 1withValidRange{Min: 1, Step: 1}. A claimnaming no amount therefore takes one CPU, not the whole device (the upstream
default), and requests are rounded to whole CPUs.
Reconfigurerefuses any change to the available or reserved CPUs, whether ornot claims exist. Template ignored those fields until now, so nothing is lost,
and it means the published device never has to be republished.
Allocation
Per result,
AllocateClaimtakes as many CPUs as the result consumed, lowest IDfirst, from the allowed CPUs no other claim holds. A real policy would pick by
topology; the code says so. The state is one cpuset per claim UID, kept in the
policy's own cache entry. Free CPUs are computed from it on demand, so release
is a delete and there is no second set to keep in sync.
claim again for every pod that uses it.
a result for somebody else's device, which carries no
dra.cpu/cpuentry.DRA_CPUSET_<claim UID>=<cpuset>, one variable per claim withall of its CPUs. Every result's edit sets the same value, so it does not
matter that CDI keeps only one of them.
Template manages no cpusets, so it neither pins a claim's containers to their
CPUs nor keeps other containers off them. The code and the docs say so. A policy
that does manage cpusets has to exclude claimed CPUs from what it hands out.
Names and the DeviceClass
The capacity name
dra.cpu/cpuis fully qualified, so a result carriesexactly that string and the lookup is one map key. A
QualifiedNamewithout a domain would notmatch its qualified form as a map key (see kubernetes/kubernetes#142202).
The chart gains a
template.nri.ioDeviceClass underconfig.dra.enabled.Claims survive a plugin restart
The claims are kept in the policy's
claimscache entry and read back inStart, so a restarted plugin still knows which CPUs are taken. Since #818,resmgr clears policy data only when the policy changes, and each policy resets
its own entries in
Setup. Template is the first policy that does not: itrebuilds nothing from running containers, and a claim may have no container at
all yet, so what it saved is all it has.
An entry a policy keeps across restarts has to stay readable:
GetPolicyEntrytreats an entry it cannot decode as fatal. The claims are a
map[string]cpuset.CPUSet, so changing that type means a new cache key.Both the unit tests and the e2e test check this, and both fail with the reset
put back in
Setup.e2e: feature gates and a template suite
The harness learns
k8s_feature_gates="Gate1=true,Gate2=false".provision.yamlturns it into a kubeadm config that sets the gates on the API server, the
scheduler and the kubelet. Unset keeps today's plain
kubeadm init.vm_namecan now be set by the caller, so a gated and an ungated VM do not share a
directory.
policies.test-suite/template/n4c16/test01-draruns with available CPUscpuset:4-7, so two 2-CPU claims use up the device. It checks that:not the 4-5 the third pod still holds.
The test skips when
allowMultipleAllocationsis missing from the publisheddevice, which is what the API server does without
DRAConsumableCapacity.Running template in the harness also needed a deploy playbook and a
templateentry in the per-plugin cases of
helm-launch,config-resourceandplugin-daemonset.e2e does not run in CI. To run it:
Testing
go test ./...passes, and golangci-lint finds no issues.partial claim, disjoint claims, exhaustion, several results in one claim, an
idempotent re-prepare, a missing, zero or fractional amount, a capacity name
other than
dra.cpu/cpu, release of known and unknown claims, restore ofsaved claims, and the reconfigure refusal.
helm templateandhelm lintpass with DRA enabled and disabled.device push of #803: PASS with
DRAConsumableCapacity=true, SKIP withDRAConsumableCapacity=false. An earlier revision also passed with no gatesset, since
DRAConsumableCapacityis on by default there. The restart checkcame after these runs: it passes gated, and fails with the reset put back
in
Setup. After the switch to thedra.cpu/cpuandDRA_CPUSET_namesit passed again gated.
the ungated one provisioned with the plain
kubeadm init.