@@ -19,7 +19,6 @@ package app
19
19
20
20
import (
21
21
"context"
22
- "errors"
23
22
"fmt"
24
23
"io"
25
24
"net/http"
@@ -59,6 +58,7 @@ import (
59
58
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
60
59
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
61
60
"k8s.io/kubernetes/pkg/scheduler/metrics"
61
+ "k8s.io/kubernetes/pkg/scheduler/profile"
62
62
"k8s.io/kubernetes/pkg/util/configz"
63
63
utilflag "k8s.io/kubernetes/pkg/util/flag"
64
64
)
@@ -172,34 +172,19 @@ func Run(ctx context.Context, cc schedulerserverconfig.CompletedConfig, outOfTre
172
172
}
173
173
}
174
174
175
- if len (cc .ComponentConfig .Profiles ) != 1 {
176
- // TODO(#85737): Support more than one profile.
177
- return errors .New ("multiple scheduling profiles are unsupported" )
178
- }
179
- profile := cc .ComponentConfig .Profiles [0 ]
180
- // Prepare event clients.
181
- if _ , err := cc .Client .Discovery ().ServerResourcesForGroupVersion (eventsv1beta1 .SchemeGroupVersion .String ()); err == nil {
182
- cc .Broadcaster = events .NewBroadcaster (& events.EventSinkImpl {Interface : cc .EventClient .Events ("" )})
183
- cc .Recorder = cc .Broadcaster .NewRecorder (scheme .Scheme , profile .SchedulerName )
184
- } else {
185
- recorder := cc .CoreBroadcaster .NewRecorder (scheme .Scheme , v1.EventSource {Component : profile .SchedulerName })
186
- cc .Recorder = record .NewEventRecorderAdapter (recorder )
187
- }
188
-
175
+ recorderFactory := getRecorderFactory (& cc )
189
176
// Create the scheduler.
190
177
sched , err := scheduler .New (cc .Client ,
191
178
cc .InformerFactory ,
192
179
cc .PodInformer ,
193
- cc . Recorder ,
180
+ recorderFactory ,
194
181
ctx .Done (),
195
- scheduler .WithName ( profile . SchedulerName ),
182
+ scheduler .WithProfiles ( cc . ComponentConfig . Profiles ... ),
196
183
scheduler .WithAlgorithmSource (cc .ComponentConfig .AlgorithmSource ),
197
184
scheduler .WithPreemptionDisabled (cc .ComponentConfig .DisablePreemption ),
198
185
scheduler .WithPercentageOfNodesToScore (cc .ComponentConfig .PercentageOfNodesToScore ),
199
186
scheduler .WithBindTimeoutSeconds (cc .ComponentConfig .BindTimeoutSeconds ),
200
187
scheduler .WithFrameworkOutOfTreeRegistry (outOfTreeRegistry ),
201
- scheduler .WithFrameworkPlugins (profile .Plugins ),
202
- scheduler .WithFrameworkPluginConfig (profile .PluginConfig ),
203
188
scheduler .WithPodMaxBackoffSeconds (cc .ComponentConfig .PodMaxBackoffSeconds ),
204
189
scheduler .WithPodInitialBackoffSeconds (cc .ComponentConfig .PodInitialBackoffSeconds ),
205
190
)
@@ -336,6 +321,17 @@ func newHealthzHandler(config *kubeschedulerconfig.KubeSchedulerConfiguration, s
336
321
return pathRecorderMux
337
322
}
338
323
324
+ func getRecorderFactory (cc * schedulerserverconfig.CompletedConfig ) profile.RecorderFactory {
325
+ if _ , err := cc .Client .Discovery ().ServerResourcesForGroupVersion (eventsv1beta1 .SchemeGroupVersion .String ()); err == nil {
326
+ cc .Broadcaster = events .NewBroadcaster (& events.EventSinkImpl {Interface : cc .EventClient .Events ("" )})
327
+ return profile .NewRecorderFactory (cc .Broadcaster )
328
+ }
329
+ return func (name string ) events.EventRecorder {
330
+ r := cc .CoreBroadcaster .NewRecorder (scheme .Scheme , v1.EventSource {Component : name })
331
+ return record .NewEventRecorderAdapter (r )
332
+ }
333
+ }
334
+
339
335
// WithPlugin creates an Option based on plugin name and factory. This function is used to register out-of-tree plugins.
340
336
func WithPlugin (name string , factory framework.PluginFactory ) Option {
341
337
return func (registry framework.Registry ) error {
0 commit comments