← Back to Pull requests

capacityscheduling: handle DeletedFinalStateUnknown in delete handlers #1023

Open
cwedgwood opened this pull request with 111 lines diff across 2 files
View on GitHub
cwedgwood cwedgwood commented on Nov 11, 2026 01:24 UTC
Author

What type of PR is this?

/kind bug

What this PR does / why we need it:

The CapacityScheduling plugin registers pod and ElasticQuota informer handlers whose FilterFunc explicitly accepts cache.DeletedFinalStateUnknown tombstones. However, deletePod and deleteElasticQuota then type-assert the object directly to v1.Pod / v1alpha1.ElasticQuota. When a delete is only observed through a relist after a watch gap (for example after an API server restart), the informer delivers a tombstone and the scheduler panics:

panic: interface conversion: interface {} is cache.DeletedFinalStateUnknown, not *v1.Pod [recovered, repanicked]

stack top: CapacityScheduling.deletePod (pkg/capacityscheduling/capacity_scheduling.go). Observed with v0.32.7; the code is unchanged on master.

This change unwraps tombstones in both delete handlers (the same pattern already used by the coscheduling pod delete handler) and ignores unexpected object types instead of panicking.

Which issue(s) this PR fixes:

Fixes #1022

Special notes for your reviewer:

  • Unit tests add tombstone cases to TestDeletePod and TestDeleteElasticQuota and a test that unexpected objects are ignored. The tombstone cases panic with the error above without the fix.

  • pkg/sysched/sysched.go podDeleted uses the same unchecked obj.(*v1.Pod) pattern; left out to keep this PR scoped, happy to fix in a follow-up.
  • Does this PR introduce a user-facing change?

    ``release-note
    Fixed a panic in the CapacityScheduling plugin when a Pod or ElasticQuota delete event is delivered as a DeletedFinalStateUnknown tombstone.
    ``

    Diff: 111 lines (+107 / -4) across 2 files Reviewer: ffromani Review duration: 16995m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.33) × (1 − Review Confidence (0.86)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.33 · 111 lines diff across 2 files
    0.33
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.91 · 4 substantive comment(s)
    0.91
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    86%
    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.282
    Real PR Conversation Timeline
    6 items
    netlify[bot] netlify[bot] commented on Nov 11, 2026 01:24 UTC
    Bot

    <span aria-hidden="true">👷</span> Deploy request for kubernetes-sigs-scheduler-plugins pending review.


    Visit the deploys page to approve it

    | Name | Link |
    |:-:|------------------------|
    |<span aria-hidden="true">🔨</span> Latest commit | 2fc4fb2dbe2e98ab18987411081de3c908e94d3d |

    kubernetes-prow[bot] kubernetes-prow[bot] commented on Nov 11, 2026 01:24 UTC
    Bot

    Welcome @cwedgwood! <br><br>It looks like this is your first PR to <a href='https://github.com/kubernetes-sigs/scheduler-plugins'>kubernetes-sigs/scheduler-plugins</a> 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval. <br><br>You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation. <br><br>You can also check if kubernetes-sigs/scheduler-plugins has its own contribution guidelines. <br><br>You may want to refer to our testing guide if you run into trouble with your tests not passing. <br><br>If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs! <br><br>Thank you, and welcome to Kubernetes. :smiley:

    kubernetes-prow[bot] kubernetes-prow[bot] commented on Nov 11, 2026 01:24 UTC
    Bot

    Hi @cwedgwood. Thanks for your PR.

    I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

    Regular contributors should join the org to skip this step.

    Once the patch is verified, the new status will be reflected by the ok-to-test label.

    I understand the commands that are listed here.

    <details>

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
    </details>

    kubernetes-prow[bot] kubernetes-prow[bot] commented on Nov 11, 2026 01:24 UTC
    Bot

    [APPROVALNOTIFIER] This PR is NOT APPROVED

    This pull-request has been approved by: <a href="https://github.com/kubernetes-sigs/scheduler-plugins/pull/1023#" title="Author self-approved">cwedgwood</a>
    Once this PR has been reviewed and has the lgtm label, please assign huang-wei for approval. For more information see the Code Review Process.

    The full list of commands accepted by this bot can be found here.

    <details open>
    Needs approval from an approver in each of these files:

  • OWNERS
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":["huang-wei"]} -->

    ffromani ffromani commented on Nov 13, 2026 12:59 UTC
    Reviewer

    /ok-to-test

    Reviewers
    Assignees
    cwedgwood cwedgwood
    Labels
    risk: low confidence: 86.1% 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: 32.7% (LOW) · Higher = larger blast radius
    32.7%
    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: 86.1% · Lower = rushed or shallow review
    86.1%
    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: 4.6% · Safe to merge
    4.6%