@@ -29,6 +29,7 @@ import (
29
29
"k8s.io/apimachinery/pkg/runtime"
30
30
"k8s.io/apimachinery/pkg/util/wait"
31
31
clientset "k8s.io/client-go/kubernetes"
32
+ podutil "k8s.io/kubernetes/pkg/api/v1/pod"
32
33
"k8s.io/kubernetes/pkg/scheduler"
33
34
schedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
34
35
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultbinder"
@@ -216,6 +217,14 @@ func (sp *ScoreWithNormalizePlugin) ScoreExtensions() framework.ScoreExtensions
216
217
return sp
217
218
}
218
219
220
+ // schedAttempted returns true if the scheduler already attempted to schedule the pod.
221
+ // Note that the logic used here works only for our integration tests because kubelet is not running,
222
+ // and so the condition will continue to exist even if the pod eventually got scheduled.
223
+ func schedAttempted (pod * v1.Pod ) bool {
224
+ _ , cond := podutil .GetPodCondition (& pod .Status , v1 .PodScheduled )
225
+ return cond != nil && cond .Status == v1 .ConditionFalse && cond .Reason == v1 .PodReasonUnschedulable
226
+ }
227
+
219
228
// Name returns name of the plugin.
220
229
func (fp * FilterPlugin ) Name () string {
221
230
return filterPluginName
@@ -230,7 +239,9 @@ func (fp *FilterPlugin) reset() {
230
239
// Filter is a test function that returns an error or nil, depending on the
231
240
// value of "failFilter".
232
241
func (fp * FilterPlugin ) Filter (ctx context.Context , state * framework.CycleState , pod * v1.Pod , nodeInfo * framework.NodeInfo ) * framework.Status {
233
- fp .numFilterCalled ++
242
+ if ! schedAttempted (pod ) {
243
+ fp .numFilterCalled ++
244
+ }
234
245
235
246
if fp .failFilter {
236
247
return framework .NewStatus (framework .Error , fmt .Sprintf ("injecting failure for pod %v" , pod .Name ))
@@ -402,7 +413,10 @@ func (pp *PostFilterPlugin) Name() string {
402
413
}
403
414
404
415
func (pp * PostFilterPlugin ) PostFilter (ctx context.Context , state * framework.CycleState , pod * v1.Pod , _ framework.NodeToStatusMap ) (* framework.PostFilterResult , * framework.Status ) {
405
- pp .numPostFilterCalled ++
416
+ if ! schedAttempted (pod ) {
417
+ pp .numPostFilterCalled ++
418
+ }
419
+
406
420
nodeInfos , err := pp .fh .SnapshotSharedLister ().NodeInfos ().List ()
407
421
if err != nil {
408
422
return nil , framework .NewStatus (framework .Error , err .Error ())
0 commit comments