capacityscheduling: handle DeletedFinalStateUnknown in delete handlers #1023
<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 |
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:
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>
[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:
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"]} -->
/ok-to-test
ffromani
cwedgwood
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
FilterFuncexplicitly acceptscache.DeletedFinalStateUnknowntombstones. However,deletePodanddeleteElasticQuotathen type-assert the object directly tov1.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: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:
TestDeletePodandTestDeleteElasticQuotaand a test that unexpected objects are ignored. The tombstone cases panic with the error above without the fix.pkg/sysched/sysched.gopodDeleteduses the same uncheckedobj.(*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.