Skip to content

Commit a309fad

Browse files
authored
Merge pull request kubernetes#124001 from kerthcet/fix/multi-prifile
Revert: enhancement(scheduler): share waitingPods among profiles
2 parents fe9e469 + 84750fe commit a309fad

File tree

7 files changed

+8
-238
lines changed

7 files changed

+8
-238
lines changed

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ func TestPostFilter(t *testing.T) {
364364
frameworkruntime.WithExtenders(extenders),
365365
frameworkruntime.WithSnapshotSharedLister(internalcache.NewSnapshot(tt.pods, tt.nodes)),
366366
frameworkruntime.WithLogger(logger),
367-
frameworkruntime.WithWaitingPods(frameworkruntime.NewWaitingPodsMap()),
368367
)
369368
if err != nil {
370369
t.Fatal(err)
@@ -1703,8 +1702,6 @@ func TestPreempt(t *testing.T) {
17031702
ctx, cancel := context.WithCancel(ctx)
17041703
defer cancel()
17051704

1706-
waitingPods := frameworkruntime.NewWaitingPodsMap()
1707-
17081705
cache := internalcache.New(ctx, time.Duration(0))
17091706
for _, pod := range test.pods {
17101707
cache.AddPod(logger, pod)
@@ -1748,7 +1745,6 @@ func TestPreempt(t *testing.T) {
17481745
frameworkruntime.WithPodNominator(internalqueue.NewPodNominator(informerFactory.Core().V1().Pods().Lister())),
17491746
frameworkruntime.WithSnapshotSharedLister(internalcache.NewSnapshot(test.pods, nodes)),
17501747
frameworkruntime.WithInformerFactory(informerFactory),
1751-
frameworkruntime.WithWaitingPods(waitingPods),
17521748
frameworkruntime.WithLogger(logger),
17531749
)
17541750
if err != nil {

pkg/scheduler/framework/runtime/framework.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ type frameworkOptions struct {
132132
extenders []framework.Extender
133133
captureProfile CaptureProfile
134134
parallelizer parallelize.Parallelizer
135-
waitingPods *waitingPodsMap
136135
logger *klog.Logger
137136
}
138137

@@ -222,13 +221,6 @@ func WithMetricsRecorder(r *metrics.MetricAsyncRecorder) Option {
222221
}
223222
}
224223

225-
// WithWaitingPods sets waitingPods for the scheduling frameworkImpl.
226-
func WithWaitingPods(wp *waitingPodsMap) Option {
227-
return func(o *frameworkOptions) {
228-
o.waitingPods = wp
229-
}
230-
}
231-
232224
// WithLogger overrides the default logger from k8s.io/klog.
233225
func WithLogger(logger klog.Logger) Option {
234226
return func(o *frameworkOptions) {
@@ -262,7 +254,7 @@ func NewFramework(ctx context.Context, r Registry, profile *config.KubeScheduler
262254
registry: r,
263255
snapshotSharedLister: options.snapshotSharedLister,
264256
scorePluginWeight: make(map[string]int),
265-
waitingPods: options.waitingPods,
257+
waitingPods: newWaitingPodsMap(),
266258
clientSet: options.clientSet,
267259
kubeConfig: options.kubeConfig,
268260
eventRecorder: options.eventRecorder,

pkg/scheduler/framework/runtime/framework_test.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,9 +2808,7 @@ func TestPermitPlugins(t *testing.T) {
28082808
profile := config.KubeSchedulerProfile{Plugins: configPlugins}
28092809
ctx, cancel := context.WithCancel(context.Background())
28102810
defer cancel()
2811-
f, err := newFrameworkWithQueueSortAndBind(ctx, registry, profile,
2812-
WithWaitingPods(NewWaitingPodsMap()),
2813-
)
2811+
f, err := newFrameworkWithQueueSortAndBind(ctx, registry, profile)
28142812
if err != nil {
28152813
t.Fatalf("fail to create framework: %s", err)
28162814
}
@@ -2992,10 +2990,7 @@ func TestRecordingMetrics(t *testing.T) {
29922990
SchedulerName: testProfileName,
29932991
Plugins: plugins,
29942992
}
2995-
f, err := newFrameworkWithQueueSortAndBind(ctx, r, profile,
2996-
withMetricsRecorder(recorder),
2997-
WithWaitingPods(NewWaitingPodsMap()),
2998-
)
2993+
f, err := newFrameworkWithQueueSortAndBind(ctx, r, profile, withMetricsRecorder(recorder))
29992994
if err != nil {
30002995
cancel()
30012996
t.Fatalf("Failed to create framework for testing: %v", err)
@@ -3165,9 +3160,7 @@ func TestPermitWaitDurationMetric(t *testing.T) {
31653160
profile := config.KubeSchedulerProfile{Plugins: plugins}
31663161
ctx, cancel := context.WithCancel(context.Background())
31673162
defer cancel()
3168-
f, err := newFrameworkWithQueueSortAndBind(ctx, r, profile,
3169-
WithWaitingPods(NewWaitingPodsMap()),
3170-
)
3163+
f, err := newFrameworkWithQueueSortAndBind(ctx, r, profile)
31713164
if err != nil {
31723165
t.Fatalf("Failed to create framework for testing: %v", err)
31733166
}
@@ -3223,9 +3216,7 @@ func TestWaitOnPermit(t *testing.T) {
32233216
profile := config.KubeSchedulerProfile{Plugins: plugins}
32243217
ctx, cancel := context.WithCancel(context.Background())
32253218
defer cancel()
3226-
f, err := newFrameworkWithQueueSortAndBind(ctx, r, profile,
3227-
WithWaitingPods(NewWaitingPodsMap()),
3228-
)
3219+
f, err := newFrameworkWithQueueSortAndBind(ctx, r, profile)
32293220
if err != nil {
32303221
t.Fatalf("Failed to create framework for testing: %v", err)
32313222
}

pkg/scheduler/framework/runtime/waiting_pods_map.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ type waitingPodsMap struct {
3232
mu sync.RWMutex
3333
}
3434

35-
// NewWaitingPodsMap returns a new waitingPodsMap.
36-
func NewWaitingPodsMap() *waitingPodsMap {
35+
// newWaitingPodsMap returns a new waitingPodsMap.
36+
func newWaitingPodsMap() *waitingPodsMap {
3737
return &waitingPodsMap{
3838
pods: make(map[types.UID]*waitingPod),
3939
}

pkg/scheduler/schedule_one_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,7 @@ func TestSchedulerScheduleOne(t *testing.T) {
773773
registerPluginFuncs,
774774
testSchedulerName,
775775
frameworkruntime.WithClientSet(client),
776-
frameworkruntime.WithEventRecorder(eventBroadcaster.NewRecorder(scheme.Scheme, testSchedulerName)),
777-
frameworkruntime.WithWaitingPods(frameworkruntime.NewWaitingPodsMap()),
778-
)
776+
frameworkruntime.WithEventRecorder(eventBroadcaster.NewRecorder(scheme.Scheme, testSchedulerName)))
779777
if err != nil {
780778
t.Fatal(err)
781779
}
@@ -3525,7 +3523,6 @@ func setupTestScheduler(ctx context.Context, t *testing.T, queuedPodStore *clien
35253523
informerFactory = informers.NewSharedInformerFactory(clientsetfake.NewSimpleClientset(), 0)
35263524
}
35273525
schedulingQueue := internalqueue.NewTestQueueWithInformerFactory(ctx, nil, informerFactory)
3528-
waitingPods := frameworkruntime.NewWaitingPodsMap()
35293526

35303527
fwk, _ := tf.NewFramework(
35313528
ctx,
@@ -3535,7 +3532,6 @@ func setupTestScheduler(ctx context.Context, t *testing.T, queuedPodStore *clien
35353532
frameworkruntime.WithEventRecorder(recorder),
35363533
frameworkruntime.WithInformerFactory(informerFactory),
35373534
frameworkruntime.WithPodNominator(internalqueue.NewPodNominator(informerFactory.Core().V1().Pods().Lister())),
3538-
frameworkruntime.WithWaitingPods(waitingPods),
35393535
)
35403536

35413537
errChan := make(chan error, 1)

pkg/scheduler/scheduler.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,6 @@ func New(ctx context.Context,
292292

293293
snapshot := internalcache.NewEmptySnapshot()
294294
metricsRecorder := metrics.NewMetricsAsyncRecorder(1000, time.Second, stopEverything)
295-
// waitingPods holds all the pods that are in the scheduler and waiting in the permit stage
296-
waitingPods := frameworkruntime.NewWaitingPodsMap()
297295

298296
profiles, err := profile.NewMap(ctx, options.profiles, registry, recorderFactory,
299297
frameworkruntime.WithComponentConfigVersion(options.componentConfigVersion),
@@ -305,7 +303,6 @@ func New(ctx context.Context,
305303
frameworkruntime.WithParallelism(int(options.parallelism)),
306304
frameworkruntime.WithExtenders(extenders),
307305
frameworkruntime.WithMetricsRecorder(metricsRecorder),
308-
frameworkruntime.WithWaitingPods(waitingPods),
309306
)
310307
if err != nil {
311308
return nil, fmt.Errorf("initializing profiles: %v", err)

0 commit comments

Comments
 (0)