Skip to content

Commit 437ac6d

Browse files
committed
New() interface change; pkg/scheduler/testing -> scheduler/testing/framework
1 parent 99de67d commit 437ac6d

File tree

25 files changed

+174
-162
lines changed

25 files changed

+174
-162
lines changed

pkg/capacityscheduling/capacity_scheduling.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (c *CapacityScheduling) Name() string {
118118
}
119119

120120
// New initializes a new plugin and returns it.
121-
func New(obj runtime.Object, handle framework.Handle) (framework.Plugin, error) {
121+
func New(_ context.Context, obj runtime.Object, handle framework.Handle) (framework.Plugin, error) {
122122
c := &CapacityScheduling{
123123
fh: handle,
124124
elasticQuotaInfos: NewElasticQuotaInfos(),

pkg/capacityscheduling/capacity_scheduling_test.go

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"k8s.io/kubernetes/pkg/scheduler/framework/preemption"
4242
frameworkruntime "k8s.io/kubernetes/pkg/scheduler/framework/runtime"
4343
st "k8s.io/kubernetes/pkg/scheduler/testing"
44+
tf "k8s.io/kubernetes/pkg/scheduler/testing/framework"
4445
imageutils "k8s.io/kubernetes/test/utils/image"
4546

4647
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -143,14 +144,14 @@ func TestPreFilter(t *testing.T) {
143144
ctx, cancel := context.WithCancel(context.Background())
144145
defer cancel()
145146

146-
var registerPlugins []st.RegisterPluginFunc
147+
var registerPlugins []tf.RegisterPluginFunc
147148
registeredPlugins := append(
148149
registerPlugins,
149-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
150-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
150+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
151+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
151152
)
152153

153-
fwk, err := st.NewFramework(
154+
fwk, err := tf.NewFramework(
154155
ctx, registeredPlugins, "",
155156
frameworkruntime.WithPodNominator(testutil.NewPodNominator(nil)),
156157
frameworkruntime.WithSnapshotSharedLister(testutil.NewFakeSharedLister(make([]*v1.Pod, 0), make([]*v1.Node, 0))),
@@ -317,7 +318,7 @@ func TestPostFilter(t *testing.T) {
317318
ctx, cancel := context.WithCancel(context.Background())
318319
defer cancel()
319320

320-
fwk, err := st.NewFramework(
321+
fwk, err := tf.NewFramework(
321322
ctx,
322323
registeredPlugins,
323324
"default-scheduler",
@@ -444,14 +445,14 @@ func TestReserve(t *testing.T) {
444445
ctx, cancel := context.WithCancel(context.Background())
445446
defer cancel()
446447

447-
var registerPlugins []st.RegisterPluginFunc
448+
var registerPlugins []tf.RegisterPluginFunc
448449
registeredPlugins := append(
449450
registerPlugins,
450-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
451-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
451+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
452+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
452453
)
453454

454-
fwk, err := st.NewFramework(
455+
fwk, err := tf.NewFramework(
455456
ctx, registeredPlugins, "",
456457
frameworkruntime.WithPodNominator(testutil.NewPodNominator(nil)),
457458
frameworkruntime.WithSnapshotSharedLister(testutil.NewFakeSharedLister(make([]*v1.Pod, 0), make([]*v1.Node, 0))),
@@ -566,14 +567,14 @@ func TestUnreserve(t *testing.T) {
566567
ctx, cancel := context.WithCancel(context.Background())
567568
defer cancel()
568569

569-
var registerPlugins []st.RegisterPluginFunc
570+
var registerPlugins []tf.RegisterPluginFunc
570571
registeredPlugins := append(
571572
registerPlugins,
572-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
573-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
573+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
574+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
574575
)
575576

576-
fwk, err := st.NewFramework(
577+
fwk, err := tf.NewFramework(
577578
ctx, registeredPlugins, "",
578579
frameworkruntime.WithPodNominator(testutil.NewPodNominator(nil)),
579580
frameworkruntime.WithSnapshotSharedLister(testutil.NewFakeSharedLister(make([]*v1.Pod, 0), make([]*v1.Node, 0))),
@@ -723,7 +724,7 @@ func TestDryRunPreemption(t *testing.T) {
723724
cs := clientsetfake.NewSimpleClientset()
724725
ctx, cancel := context.WithCancel(context.Background())
725726
defer cancel()
726-
fwk, err := st.NewFramework(
727+
fwk, err := tf.NewFramework(
727728
ctx,
728729
registeredPlugins,
729730
"default-scheduler",
@@ -972,7 +973,7 @@ func TestPodEligibleToPreemptOthers(t *testing.T) {
972973
ctx, cancel := context.WithCancel(context.Background())
973974
defer cancel()
974975

975-
fwk, err := st.NewFramework(
976+
fwk, err := tf.NewFramework(
976977
ctx,
977978
registeredPlugins,
978979
"default-scheduler",
@@ -1129,14 +1130,14 @@ func TestAddElasticQuota(t *testing.T) {
11291130
ctx, cancel := context.WithCancel(context.Background())
11301131
defer cancel()
11311132

1132-
var registerPlugins []st.RegisterPluginFunc
1133+
var registerPlugins []tf.RegisterPluginFunc
11331134
registeredPlugins := append(
11341135
registerPlugins,
1135-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1136-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
1136+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1137+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
11371138
)
11381139

1139-
fwk, err := st.NewFramework(
1140+
fwk, err := tf.NewFramework(
11401141
ctx, registeredPlugins, "",
11411142
frameworkruntime.WithPodNominator(testutil.NewPodNominator(nil)),
11421143
frameworkruntime.WithSnapshotSharedLister(testutil.NewFakeSharedLister(make([]*v1.Pod, 0), make([]*v1.Node, 0))),
@@ -1202,14 +1203,14 @@ func TestUpdateElasticQuota(t *testing.T) {
12021203
ctx, cancel := context.WithCancel(context.Background())
12031204
defer cancel()
12041205

1205-
var registerPlugins []st.RegisterPluginFunc
1206+
var registerPlugins []tf.RegisterPluginFunc
12061207
registeredPlugins := append(
12071208
registerPlugins,
1208-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1209-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
1209+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1210+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
12101211
)
12111212

1212-
fwk, err := st.NewFramework(
1213+
fwk, err := tf.NewFramework(
12131214
ctx, registeredPlugins, "",
12141215
frameworkruntime.WithPodNominator(testutil.NewPodNominator(nil)),
12151216
frameworkruntime.WithSnapshotSharedLister(testutil.NewFakeSharedLister(make([]*v1.Pod, 0), make([]*v1.Node, 0))),
@@ -1254,14 +1255,14 @@ func TestDeleteElasticQuota(t *testing.T) {
12541255
ctx, cancel := context.WithCancel(context.Background())
12551256
defer cancel()
12561257

1257-
var registerPlugins []st.RegisterPluginFunc
1258+
var registerPlugins []tf.RegisterPluginFunc
12581259
registeredPlugins := append(
12591260
registerPlugins,
1260-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1261-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
1261+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1262+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
12621263
)
12631264

1264-
fwk, err := st.NewFramework(
1265+
fwk, err := tf.NewFramework(
12651266
ctx, registeredPlugins, "",
12661267
frameworkruntime.WithPodNominator(testutil.NewPodNominator(nil)),
12671268
frameworkruntime.WithSnapshotSharedLister(testutil.NewFakeSharedLister(make([]*v1.Pod, 0), make([]*v1.Node, 0))),
@@ -1332,14 +1333,14 @@ func TestAddPod(t *testing.T) {
13321333
ctx, cancel := context.WithCancel(context.Background())
13331334
defer cancel()
13341335

1335-
var registerPlugins []st.RegisterPluginFunc
1336+
var registerPlugins []tf.RegisterPluginFunc
13361337
registeredPlugins := append(
13371338
registerPlugins,
1338-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1339-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
1339+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1340+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
13401341
)
13411342

1342-
fwk, err := st.NewFramework(
1343+
fwk, err := tf.NewFramework(
13431344
ctx, registeredPlugins, "",
13441345
frameworkruntime.WithPodNominator(testutil.NewPodNominator(nil)),
13451346
frameworkruntime.WithSnapshotSharedLister(testutil.NewFakeSharedLister(make([]*v1.Pod, 0), make([]*v1.Node, 0))),
@@ -1444,14 +1445,14 @@ func TestUpdatePod(t *testing.T) {
14441445
ctx, cancel := context.WithCancel(context.Background())
14451446
defer cancel()
14461447

1447-
var registerPlugins []st.RegisterPluginFunc
1448+
var registerPlugins []tf.RegisterPluginFunc
14481449
registeredPlugins := append(
14491450
registerPlugins,
1450-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1451-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
1451+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1452+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
14521453
)
14531454

1454-
fwk, err := st.NewFramework(
1455+
fwk, err := tf.NewFramework(
14551456
ctx, registeredPlugins, "",
14561457
frameworkruntime.WithPodNominator(testutil.NewPodNominator(nil)),
14571458
frameworkruntime.WithSnapshotSharedLister(testutil.NewFakeSharedLister(make([]*v1.Pod, 0), make([]*v1.Node, 0))),
@@ -1561,14 +1562,14 @@ func TestDeletePod(t *testing.T) {
15611562
ctx, cancel := context.WithCancel(context.Background())
15621563
defer cancel()
15631564

1564-
var registerPlugins []st.RegisterPluginFunc
1565+
var registerPlugins []tf.RegisterPluginFunc
15651566
registeredPlugins := append(
15661567
registerPlugins,
1567-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1568-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
1568+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1569+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
15691570
)
15701571

1571-
fwk, err := st.NewFramework(
1572+
fwk, err := tf.NewFramework(
15721573
ctx, registeredPlugins, "",
15731574
frameworkruntime.WithPodNominator(testutil.NewPodNominator(nil)),
15741575
frameworkruntime.WithSnapshotSharedLister(testutil.NewFakeSharedLister(make([]*v1.Pod, 0), make([]*v1.Node, 0))),
@@ -1637,12 +1638,12 @@ func makeResourceList(cpu, mem int64) v1.ResourceList {
16371638
}
16381639
}
16391640

1640-
func makeRegisteredPlugin() []st.RegisterPluginFunc {
1641-
registeredPlugins := []st.RegisterPluginFunc{
1642-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1643-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
1644-
st.RegisterPluginAsExtensions(noderesources.Name, func(plArgs apiruntime.Object, fh framework.Handle) (framework.Plugin, error) {
1645-
return noderesources.NewFit(plArgs, fh, plfeature.Features{})
1641+
func makeRegisteredPlugin() []tf.RegisterPluginFunc {
1642+
registeredPlugins := []tf.RegisterPluginFunc{
1643+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
1644+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
1645+
tf.RegisterPluginAsExtensions(noderesources.Name, func(ctx context.Context, plArgs apiruntime.Object, fh framework.Handle) (framework.Plugin, error) {
1646+
return noderesources.NewFit(ctx, plArgs, fh, plfeature.Features{})
16461647
}, "Filter", "PreFilter"),
16471648
}
16481649
return registeredPlugins

pkg/coscheduling/coscheduling.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const (
6060
)
6161

6262
// New initializes and returns a new Coscheduling plugin.
63-
func New(obj runtime.Object, handle framework.Handle) (framework.Plugin, error) {
63+
func New(_ context.Context, obj runtime.Object, handle framework.Handle) (framework.Plugin, error) {
6464
args, ok := obj.(*config.CoschedulingArgs)
6565
if !ok {
6666
return nil, fmt.Errorf("want args to be of type CoschedulingArgs, got %T", obj)

pkg/coscheduling/coscheduling_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/queuesort"
3636
fwkruntime "k8s.io/kubernetes/pkg/scheduler/framework/runtime"
3737
st "k8s.io/kubernetes/pkg/scheduler/testing"
38+
tf "k8s.io/kubernetes/pkg/scheduler/testing/framework"
3839
"k8s.io/utils/pointer"
3940

4041
_ "sigs.k8s.io/scheduler-plugins/apis/config/scheme"
@@ -97,11 +98,11 @@ func TestPodGroupBackoffTime(t *testing.T) {
9798
cs := clientsetfake.NewSimpleClientset()
9899
informerFactory := informers.NewSharedInformerFactory(cs, 0)
99100
podInformer := informerFactory.Core().V1().Pods()
100-
registeredPlugins := []st.RegisterPluginFunc{
101-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
102-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
101+
registeredPlugins := []tf.RegisterPluginFunc{
102+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
103+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
103104
}
104-
f, err := st.NewFramework(ctx, registeredPlugins, "default-scheduler", fwkruntime.WithInformerFactory(informerFactory))
105+
f, err := tf.NewFramework(ctx, registeredPlugins, "default-scheduler", fwkruntime.WithInformerFactory(informerFactory))
105106
if err != nil {
106107
t.Fatal(err)
107108
}
@@ -490,11 +491,11 @@ func TestPermit(t *testing.T) {
490491
}
491492

492493
// Compose a fake framework handle.
493-
registeredPlugins := []st.RegisterPluginFunc{
494-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
495-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
494+
registeredPlugins := []tf.RegisterPluginFunc{
495+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
496+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
496497
}
497-
f, err := st.NewFramework(ctx, registeredPlugins, "default-scheduler")
498+
f, err := tf.NewFramework(ctx, registeredPlugins, "default-scheduler")
498499
if err != nil {
499500
t.Fatal(err)
500501
}
@@ -593,11 +594,11 @@ func TestPostFilter(t *testing.T) {
593594
}
594595

595596
// Compose a fake framework handle.
596-
registeredPlugins := []st.RegisterPluginFunc{
597-
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
598-
st.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
597+
registeredPlugins := []tf.RegisterPluginFunc{
598+
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
599+
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
599600
}
600-
f, err := st.NewFramework(ctx, registeredPlugins, "default-scheduler")
601+
f, err := tf.NewFramework(ctx, registeredPlugins, "default-scheduler")
601602
if err != nil {
602603
t.Fatal(err)
603604
}

pkg/networkaware/networkoverhead/networkoverhead.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (no *NetworkOverhead) ScoreExtensions() framework.ScoreExtensions {
139139
}
140140

141141
// New : create an instance of a NetworkOverhead plugin
142-
func New(obj runtime.Object, handle framework.Handle) (framework.Plugin, error) {
142+
func New(_ context.Context, obj runtime.Object, handle framework.Handle) (framework.Plugin, error) {
143143
klog.V(4).InfoS("Creating new instance of the NetworkOverhead plugin")
144144

145145
args, err := getArgs(obj)

0 commit comments

Comments
 (0)