[YUNIKORN-3605] Run DRA Reserve in UpdateAllocation #1162
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.48) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 536 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.376
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1162"
general
weight: 0.35
thc1006
Description
This is on top of #1158 (YUNIKORN-3607), because the tests use its
newDRAContextForTest. Only the second commit belongs to this change, and I will rebase it once #1158 is merged.On master, DRA Reserve runs in the bind goroutine, which can start after
UpdateAllocationhas returned to the core. The core can schedule the next pod before that, and the DynamicResources Filter does not yet see the devices of the first pod as taken. I ran the real core and plugin with two pods that have one claim each, on a node with gpu-0 and gpu-1. When both pods were pending at the same time, both claims got gpu-0 in 14 of 20 runs on 2799d6d0.UpdateAllocationnow runs Reserve afterAssumePod, with the task lock held as the comment onContext.reserveasks. The scheduling loop waits for this call, so the next pod is filtered with the devices already reserved. kube-scheduler uses the same order: Reserve right after assume in the scheduling cycle, and PreBind in the binding cycle. The cycle state is kept on the task, and the bind runs PreBind only if a Reserve was kept.When the task leaves Scheduling for any state other than Allocated, for example because the pod is deleted, the Reserve is undone and the cycle state deleted. This runs on a goroutine, because the state machine calls the leave hook with the task lock held and Unreserve can call the API server.
When Reserve fails, the allocation is rolled back without changing the task state.
rescheduleOnBindFailureis not used there, because it would move a task that completed in the meantime back to Scheduling. Unreserve runs beforeUpdateAllocationreturns, as it does in the scheduling cycle of kube-scheduler, and the rollback is sent after it. After a failed Reserve, Unreserve calls the API server only to undo what an earlier PreBind of the pod left.Reserve and PreBind no longer run under one hold of the task lock, so a pod resource update (
SetTaskPod) can land between them. On master the same gap exists betweenAssumePodand the start of the bind. In v1.37, PreBind does not read the resources of the pod.This does not cover a placeholder replacement on another node. The core confirms it after the placeholder is released, outside the scheduling loop, so another pod can be scheduled before that Reserve. YUNIKORN-3632 tracks it.
Type of change
Jira issue
Jira ID : https://issues.apache.org/jira/browse/YUNIKORN-3605
AI Tooling
If an AI tool was used:
Check https://www.apache.org/legal/generative-tooling.html for details.
Generated by Claude Code.
AI helped analyze the bug and write and test the patch.
How has this been tested?
make test_allwas run, and no failures reported.make e2e_testwas run, and no failures reported.TestUpdateAllocation_NewTask_ReservesDRADeviceuses the real DynamicResources plugin. AfterUpdateAllocationfor the first pod, Filter for the second pod fails with "cannot allocate all claims"; without the change it finds the device free. When the first pod is then deleted before its bind, the device is free again for the second pod.TestUpdateAllocation_NewTask_DRAReservechecks that Reserve runs with the task lock held, and that Unreserve and the rollback of a failed Reserve are done whenUpdateAllocationreturns. It also covers a task that completed before the rollback, a task that already left Scheduling and a shutdown beforeAssumePod.TestLeavingSchedulingDropsDRAReservationcovers the cleanup when the task leaves Scheduling.With the change, the two claims in the setup above got gpu-0 and gpu-1 in all 20 runs.
Questions:
release-noteslabel.