Move NominatedPodsForNode to scheduling queue directly

This commit is contained in:
Maciej Skoczeń
2024-07-22 11:53:08 +00:00
parent b8dcc2c983
commit 33815db3c1
7 changed files with 70 additions and 58 deletions

View File

@@ -793,13 +793,14 @@ func TestSchedulerScheduleOne(t *testing.T) {
t.Fatal(err)
}
informerFactory := informers.NewSharedInformerFactory(client, 0)
sched := &Scheduler{
Cache: cache,
client: client,
NextPod: func(logger klog.Logger) (*framework.QueuedPodInfo, error) {
return &framework.QueuedPodInfo{PodInfo: mustNewPodInfo(t, item.sendPod)}, nil
},
SchedulingQueue: internalqueue.NewTestQueue(ctx, nil),
SchedulingQueue: internalqueue.NewSchedulingQueue(nil, informerFactory),
Profiles: profile.Map{testSchedulerName: fwk},
}
@@ -2472,7 +2473,7 @@ func TestSchedulerSchedulePod(t *testing.T) {
test.registerPlugins, "",
frameworkruntime.WithSnapshotSharedLister(snapshot),
frameworkruntime.WithInformerFactory(informerFactory),
frameworkruntime.WithPodNominator(internalqueue.NewTestPodNominator(informerFactory.Core().V1().Pods().Lister())),
frameworkruntime.WithPodNominator(internalqueue.NewSchedulingQueue(nil, informerFactory)),
)
if err != nil {
t.Fatal(err)
@@ -2538,7 +2539,7 @@ func TestFindFitAllError(t *testing.T) {
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
},
"",
frameworkruntime.WithPodNominator(internalqueue.NewTestPodNominator(nil)),
frameworkruntime.WithPodNominator(internalqueue.NewTestQueue(ctx, nil)),
)
if err != nil {
t.Fatal(err)
@@ -2581,7 +2582,7 @@ func TestFindFitSomeError(t *testing.T) {
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
},
"",
frameworkruntime.WithPodNominator(internalqueue.NewTestPodNominator(nil)),
frameworkruntime.WithPodNominator(internalqueue.NewTestQueue(ctx, nil)),
)
if err != nil {
t.Fatal(err)
@@ -2652,10 +2653,18 @@ func TestFindFitPredicateCallCounts(t *testing.T) {
logger, ctx := ktesting.NewTestContext(t)
ctx, cancel := context.WithCancel(ctx)
defer cancel()
informerFactory := informers.NewSharedInformerFactory(clientsetfake.NewClientset(), 0)
podInformer := informerFactory.Core().V1().Pods().Informer()
err := podInformer.GetStore().Add(test.pod)
if err != nil {
t.Fatalf("Error adding pod to podInformer: %s", err)
}
fwk, err := tf.NewFramework(
ctx,
registerPlugins, "",
frameworkruntime.WithPodNominator(internalqueue.NewTestPodNominator(nil)),
frameworkruntime.WithPodNominator(internalqueue.NewSchedulingQueue(nil, informerFactory)),
)
if err != nil {
t.Fatal(err)
@@ -2669,6 +2678,10 @@ func TestFindFitPredicateCallCounts(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = podInformer.GetStore().Add(podinfo.Pod)
if err != nil {
t.Fatalf("Error adding nominated pod to podInformer: %s", err)
}
fwk.AddNominatedPod(logger, podinfo, &framework.NominatingInfo{NominatingMode: framework.ModeOverride, NominatedNodeName: "1"})
_, _, err = scheduler.findNodesThatFitPod(ctx, fwk, framework.NewCycleState(), test.pod)
@@ -2796,7 +2809,7 @@ func TestZeroRequest(t *testing.T) {
frameworkruntime.WithInformerFactory(informerFactory),
frameworkruntime.WithSnapshotSharedLister(snapshot),
frameworkruntime.WithClientSet(client),
frameworkruntime.WithPodNominator(internalqueue.NewTestPodNominator(informerFactory.Core().V1().Pods().Lister())),
frameworkruntime.WithPodNominator(internalqueue.NewSchedulingQueue(nil, informerFactory)),
)
if err != nil {
t.Fatalf("error creating framework: %+v", err)
@@ -3199,7 +3212,7 @@ func Test_prioritizeNodes(t *testing.T) {
frameworkruntime.WithInformerFactory(informerFactory),
frameworkruntime.WithSnapshotSharedLister(snapshot),
frameworkruntime.WithClientSet(client),
frameworkruntime.WithPodNominator(internalqueue.NewTestPodNominator(informerFactory.Core().V1().Pods().Lister())),
frameworkruntime.WithPodNominator(internalqueue.NewSchedulingQueue(nil, informerFactory)),
)
if err != nil {
t.Fatalf("error creating framework: %+v", err)
@@ -3317,7 +3330,7 @@ func TestFairEvaluationForNodes(t *testing.T) {
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
},
"",
frameworkruntime.WithPodNominator(internalqueue.NewTestPodNominator(nil)),
frameworkruntime.WithPodNominator(internalqueue.NewTestQueue(ctx, nil)),
)
if err != nil {
t.Fatal(err)
@@ -3399,7 +3412,7 @@ func TestPreferNominatedNodeFilterCallCounts(t *testing.T) {
ctx,
registerPlugins, "",
frameworkruntime.WithClientSet(client),
frameworkruntime.WithPodNominator(internalqueue.NewTestPodNominator(informerFactory.Core().V1().Pods().Lister())),
frameworkruntime.WithPodNominator(internalqueue.NewSchedulingQueue(nil, informerFactory)),
)
if err != nil {
t.Fatal(err)
@@ -3557,7 +3570,7 @@ func setupTestScheduler(ctx context.Context, t *testing.T, queuedPodStore *clien
frameworkruntime.WithClientSet(client),
frameworkruntime.WithEventRecorder(recorder),
frameworkruntime.WithInformerFactory(informerFactory),
frameworkruntime.WithPodNominator(internalqueue.NewTestPodNominator(informerFactory.Core().V1().Pods().Lister())),
frameworkruntime.WithPodNominator(schedulingQueue),
frameworkruntime.WithWaitingPods(waitingPods),
)