← Back to Pull requests

[YUNIKORN-3605] Run DRA Reserve in UpdateAllocation #1162

Open
unknown opened this pull request with 536 lines diff across 6 files
View on GitHub
unknown unknown commented on Dec 02, 2026 08:54 UTC
Author

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 UpdateAllocation has 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.

UpdateAllocation now runs Reserve after AssumePod, with the task lock held as the comment on Context.reserve asks. 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. rescheduleOnBindFailure is not used there, because it would move a task that completed in the meantime back to Scheduling. Unreserve runs before UpdateAllocation returns, 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 between AssumePod and 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

  • Bug Fix
  • Jira issue

    Jira ID : https://issues.apache.org/jira/browse/YUNIKORN-3605

  • I have created a Jira issue for this pull request.

  • The Jira ID is part of the title of this pull request.
  • AI Tooling


    If an AI tool was used:
  • The PR includes the phrase "Generated by \<tool>", where \<tool> is the name of the AI tool used.

  • My use of AI contributions follows the ASF legal policy.
  • 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?

  • New unit tests were added to cover new or changed code paths.

  • make test_all was run, and no failures reported.

  • make e2e_test was run, and no failures reported.

  • new e2e tests have been added.
  • TestUpdateAllocation_NewTask_ReservesDRADevice uses the real DynamicResources plugin. After UpdateAllocation for 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_DRAReserve checks that Reserve runs with the task lock held, and that Unreserve and the rollback of a failed Reserve are done when UpdateAllocation returns. It also covers a task that completed before the rollback, a task that already left Scheduling and a shutdown before AssumePod. TestLeavingSchedulingDropsDRAReservation covers 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:

  • The change needs documentation, a pull request for apache/yunikorn-site repository will be created.

  • There is breaking changes for older versions: jira is tagged with release-notes label.

  • The licenses files needs to be updated.
  • Diff: 536 lines (+402 / -134) across 6 files Reviewer: thc1006 Review duration: 2727m
    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
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.9% (MEDIUM) · Higher = larger blast radius
    47.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.6% · Safe to merge
    25.6%