Code change:
// } if err := wait.Poll(200*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) { <del> _, err := getPod(testCtx.ClientSet, waitingPod.Name, waitingPod.Namespace) return apierrors.IsNotFound(err), nil </del> <ins> w := false permitPlugin.fh.IterateOverWaitingPods(func(wp framework.WaitingPod) { w = true }) return !w, nil </ins> }); err != nil { <del> t.Error("Expected the waiting pod to get preempted and deleted") </del> <ins> t.Error("Expected the waiting pod to get preempted") } // Expect the waitingPod to be still present. if _, err := getPod(testCtx.ClientSet, waitingPod.Name, waitingPod.Namespace); err != nil { t.Error("Get waiting pod in waiting pod failed.") } // Expect the runningPod to be deleted physically. _, err = getPod(testCtx.ClientSet, runningPod.Name, runningPod.Namespace) if err != nil && !errors.IsNotFound(err) { t.Error("Get running pod failed.") } if err == nil { t.Error("Running pod still exist.") </ins> } if permitPlugin.numPermitCalled == 0 { t.Errorf("Expected the permit plugin to be called.") } permitPlugin.reset() <del> testutils.CleanupPods(testCtx.ClientSet, t, []*v1.Pod{waitingPod, preemptorPod}) </del> <ins> testutils.CleanupPods(testCtx.ClientSet, t, []*v1.Pod{waitingPod, runningPod, preemptorPod}) </ins> } func initTestSchedulerForFrameworkTest(t *testing.T, testCtx *testutils.TestContext, nodeCount int, opts ...scheduler.Option) *testutils.TestContext {

Related discussion:
text: <!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via -- We may delete podS though they may be waiting in Do not delete waiting pods if they are not scheduled. Kubernetes version (use ): Cloud provider or hardware configuration: OS (e.g: ): Kernel (e.g. ): Install tools: Network plugin and version (if this is a network-related bug): Others:
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the label and provide further guidance. The label can be by org members by writing in a comment. <detailsInstructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/sig scheduling
/cc WDYT ?
It sounds to me that you prefer to prioritize waiting Pod over other assigned Pods. In that case, you may want to exclude waiting Pods in the earlier Filtering/Sorting Victims step, instead of simply disregard the deletion in PrepareCandidate(). In general, when Permit plugins work along with PostFilter (preemption), the logic could be complicated. There may not be a general preemption implementation (probably in the future we can exercise pluginArgs to provide different options). So for now the best bet is to implement your own PostFilter plugin.
Got it! But for the default preemption plugin, we delete the victims to free resources. If pod has assigned, we should delete it. If pod has not assigned, we just need reject it in WaitingPod because the pod just exists in the cache.
Oh, your point was to verify if it's a waiting pod first, and then delete it? If so, then it makes sense to me. Feel free to raise a PR. /assign
Yes, I will open a PR to do this