← Back to Pull requests

fixing the PodGroup members deadlock by holding partial GPU reservations #3523

Closed
unknown closed this pull request without merging on Dec 04, 2026 04:29 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 00:19 UTC
Author

What type of PR is this?

/kind bug

What this PR does / why we need it:

HAMi reserves GPUs for a pod in Filter. The scheduler extender API has no Unreserve, so when kube-scheduler gives up a cycle (for example when a gang times out at Permit, or Coscheduling rejects the group), HAMi is never told. The pod's GPUs stay counted until the pod is filtered again or deleted. Two gangs that split a node can then block each other indefinitely (#3484).

This PR releases the reservation when kube-scheduler reports the failure in the pod's PodScheduled=False condition:

  • The reservation is dropped from the pod cache and the quota when a new or changed PodScheduled=False arrives for an unbound pod. Resyncs, bound pods and pods in the allocating bind phase are left alone. A failure from an older cycle is ignored if this replica's newer Filter is not visible yet.

  • The released allocation annotations (hami.io/vgpu-node, hami.io/vgpu-time, device annotations) are removed from the pod, so a restarted scheduler or a new leader does not count them again. The JSON patch tests the pod's resourceVersion, node and time, so it never clears an allocation a later Filter wrote. Only the leader patches, in the background, outside allocLock.

  • An in-memory marker stops informer events from adding the allocation back before the cleanup shows up, or if the patch fails.
  • All changes are in pkg/scheduler. There are no new flags and no chart changes.

    Which issue(s) this PR fixes:
    Fixes #3484

    Special notes for your reviewer:

    This covers the first fix proposed in the issue, releasing stale reservations. It does not add group-aware reservation or change the node-lock behavior.

    Local testing:

  • make verify and make test pass (all 45 packages, with -race).

  • Each new unit test fails when its part of the fix is removed: the release, the annotation cleanup, the resourceVersion check and the ordering guard.

  • e2e on minikube (Kubernetes v1.35) with kube-scheduler and Coscheduling (scheduler-plugins v0.35.7), the HAMi scheduler as extender, and one node with 4 fake GPUs:
  • | Scenario | master | this PR |
    |---|---|---|
    | #3484: two gangs of 4 x 1 GPU, queued A1, B1, A2, B2, ... | neither gang bound after 150 s, 4 GPUs stuck | one gang bound 4/4 after 24 s |
    | Gang rejected, then a HAMi restart, then a pod needing 4 GPUs | - | annotations cleared; pod bound 8 s after the restart |
    | Regression: gang that fits, then a normal 4-GPU pod | - | gang bound 4/4; pod bound in 1 s; no errors in the logs |

    Not tested: native gang scheduling with spec.schedulingGroup (Kubernetes 1.36+). It reports failures through the same PodScheduled condition, but I could not run it locally.

    AI disclosure: I used an LLM (Claude) to help with the code, the tests and this description. I reviewed and tested all changes myself.

    Does this PR introduce a user-facing change?:

    ```release-note
    Fixed GPU reservations of pods that failed a scheduling cycle (for example a PodGroup Permit timeout) staying counted, which could deadlock gangs.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Reservations are released from unbound pods after failed scheduling attempts, and stale updates no longer restore them.
    Reservations remain in place for bound or actively allocating pods.
    Allocation cleanup preserves newer allocations when pod details have changed.
    * Reservation records are cleared when pods are deleted or become bound.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 461 lines (+345 / -116) across 5 files Reviewer: archlitchi Review duration: 14650m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.46) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 461 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    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.367
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3523"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 45.6% (MEDIUM) · Higher = larger blast radius
    45.6%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 19.7% · Safe to merge
    19.7%