@@ -29,7 +29,6 @@ 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"
33
32
"k8s.io/kubernetes/pkg/scheduler"
34
33
schedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
35
34
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultbinder"
@@ -217,14 +216,6 @@ func (sp *ScoreWithNormalizePlugin) ScoreExtensions() framework.ScoreExtensions
217
216
return sp
218
217
}
219
218
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
-
228
219
// Name returns name of the plugin.
229
220
func (fp * FilterPlugin ) Name () string {
230
221
return filterPluginName
@@ -239,9 +230,7 @@ func (fp *FilterPlugin) reset() {
239
230
// Filter is a test function that returns an error or nil, depending on the
240
231
// value of "failFilter".
241
232
func (fp * FilterPlugin ) Filter (ctx context.Context , state * framework.CycleState , pod * v1.Pod , nodeInfo * framework.NodeInfo ) * framework.Status {
242
- if ! schedAttempted (pod ) {
243
- fp .numFilterCalled ++
244
- }
233
+ fp .numFilterCalled ++
245
234
246
235
if fp .failFilter {
247
236
return framework .NewStatus (framework .Error , fmt .Sprintf ("injecting failure for pod %v" , pod .Name ))
@@ -413,10 +402,7 @@ func (pp *PostFilterPlugin) Name() string {
413
402
}
414
403
415
404
func (pp * PostFilterPlugin ) PostFilter (ctx context.Context , state * framework.CycleState , pod * v1.Pod , _ framework.NodeToStatusMap ) (* framework.PostFilterResult , * framework.Status ) {
416
- if ! schedAttempted (pod ) {
417
- pp .numPostFilterCalled ++
418
- }
419
-
405
+ pp .numPostFilterCalled ++
420
406
nodeInfos , err := pp .fh .SnapshotSharedLister ().NodeInfos ().List ()
421
407
if err != nil {
422
408
return nil , framework .NewStatus (framework .Error , err .Error ())
@@ -676,17 +662,22 @@ func TestPostFilterPlugin(t *testing.T) {
676
662
if err = wait .Poll (10 * time .Millisecond , 10 * time .Second , podUnschedulable (testCtx .ClientSet , pod .Namespace , pod .Name )); err != nil {
677
663
t .Errorf ("Didn't expect the pod to be scheduled." )
678
664
}
665
+ if filterPlugin .numFilterCalled < tt .expectFilterNumCalled {
666
+ t .Errorf ("Expected the filter plugin to be called at least %v times, but got %v." , tt .expectFilterNumCalled , filterPlugin .numFilterCalled )
667
+ }
668
+ if postFilterPlugin .numPostFilterCalled < tt .expectPostFilterNumCalled {
669
+ t .Errorf ("Expected the postfilter plugin to be called at least %v times, but got %v." , tt .expectPostFilterNumCalled , postFilterPlugin .numPostFilterCalled )
670
+ }
679
671
} else {
680
672
if err = testutils .WaitForPodToSchedule (testCtx .ClientSet , pod ); err != nil {
681
673
t .Errorf ("Expected the pod to be scheduled. error: %v" , err )
682
674
}
683
- }
684
-
685
- if filterPlugin .numFilterCalled != tt .expectFilterNumCalled {
686
- t .Errorf ("Expected the filter plugin to be called %v times, but got %v." , tt .expectFilterNumCalled , filterPlugin .numFilterCalled )
687
- }
688
- if postFilterPlugin .numPostFilterCalled != tt .expectPostFilterNumCalled {
689
- t .Errorf ("Expected the postfilter plugin to be called %v times, but got %v." , tt .expectPostFilterNumCalled , postFilterPlugin .numPostFilterCalled )
675
+ if filterPlugin .numFilterCalled != tt .expectFilterNumCalled {
676
+ t .Errorf ("Expected the filter plugin to be called %v times, but got %v." , tt .expectFilterNumCalled , filterPlugin .numFilterCalled )
677
+ }
678
+ if postFilterPlugin .numPostFilterCalled != tt .expectPostFilterNumCalled {
679
+ t .Errorf ("Expected the postfilter plugin to be called %v times, but got %v." , tt .expectPostFilterNumCalled , postFilterPlugin .numPostFilterCalled )
680
+ }
690
681
}
691
682
})
692
683
}
@@ -1688,14 +1679,16 @@ func TestFilterPlugin(t *testing.T) {
1688
1679
if err = wait .Poll (10 * time .Millisecond , 30 * time .Second , podUnschedulable (testCtx .ClientSet , pod .Namespace , pod .Name )); err != nil {
1689
1680
t .Errorf ("Didn't expect the pod to be scheduled." )
1690
1681
}
1682
+ if filterPlugin .numFilterCalled < 1 {
1683
+ t .Errorf ("Expected the filter plugin to be called at least 1 time, but got %v." , filterPlugin .numFilterCalled )
1684
+ }
1691
1685
} else {
1692
1686
if err = testutils .WaitForPodToSchedule (testCtx .ClientSet , pod ); err != nil {
1693
1687
t .Errorf ("Expected the pod to be scheduled. error: %v" , err )
1694
1688
}
1695
- }
1696
-
1697
- if filterPlugin .numFilterCalled != 1 {
1698
- t .Errorf ("Expected the filter plugin to be called 1 time, but got %v." , filterPlugin .numFilterCalled )
1689
+ if filterPlugin .numFilterCalled != 1 {
1690
+ t .Errorf ("Expected the filter plugin to be called 1 time, but got %v." , filterPlugin .numFilterCalled )
1691
+ }
1699
1692
}
1700
1693
1701
1694
filterPlugin .reset ()
0 commit comments