@@ -58,10 +58,13 @@ import (
58
58
"k8s.io/klog"
59
59
)
60
60
61
- var frameworkRegistry = framework .NewRegistry ()
62
-
63
61
// NewSchedulerCommand creates a *cobra.Command object with default parameters
64
62
func NewSchedulerCommand () * cobra.Command {
63
+ return NewSchedulerCommandWithRegistry (nil )
64
+ }
65
+
66
+ // NewSchedulerCommandWithRegistry creates a *cobra.Command object with registry and default parameters
67
+ func NewSchedulerCommandWithRegistry (registry framework.Registry ) * cobra.Command {
65
68
opts , err := options .NewOptions ()
66
69
if err != nil {
67
70
klog .Fatalf ("unable to initialize command options: %v" , err )
@@ -77,7 +80,7 @@ constraints, affinity and anti-affinity specifications, data locality, inter-wor
77
80
interference, deadlines, and so on. Workload-specific requirements will be exposed
78
81
through the API as necessary.` ,
79
82
Run : func (cmd * cobra.Command , args []string ) {
80
- if err := runCommand (cmd , args , opts ); err != nil {
83
+ if err := runCommand (cmd , args , opts , registry ); err != nil {
81
84
fmt .Fprintf (os .Stderr , "%v\n " , err )
82
85
os .Exit (1 )
83
86
}
@@ -108,7 +111,7 @@ through the API as necessary.`,
108
111
}
109
112
110
113
// runCommand runs the scheduler.
111
- func runCommand (cmd * cobra.Command , args []string , opts * options.Options ) error {
114
+ func runCommand (cmd * cobra.Command , args []string , opts * options.Options , registry framework. Registry ) error {
112
115
verflag .PrintAndExitIfRequested ()
113
116
utilflag .PrintFlags (cmd .Flags ())
114
117
@@ -137,6 +140,10 @@ func runCommand(cmd *cobra.Command, args []string, opts *options.Options) error
137
140
138
141
stopCh := make (chan struct {})
139
142
143
+ if registry != nil {
144
+ c .Registry = registry
145
+ }
146
+
140
147
// Get the completed config
141
148
cc := c .Complete ()
142
149
@@ -177,7 +184,7 @@ func Run(cc schedulerserverconfig.CompletedConfig, stopCh <-chan struct{}) error
177
184
cc .Recorder ,
178
185
cc .ComponentConfig .AlgorithmSource ,
179
186
stopCh ,
180
- frameworkRegistry ,
187
+ cc . Registry ,
181
188
cc .ComponentConfig .Plugins ,
182
189
cc .ComponentConfig .PluginConfig ,
183
190
scheduler .WithName (cc .ComponentConfig .SchedulerName ),
@@ -328,9 +335,3 @@ func newHealthzHandler(config *kubeschedulerconfig.KubeSchedulerConfiguration, s
328
335
}
329
336
return pathRecorderMux
330
337
}
331
-
332
- // RegisterFrameworkPlugin adds a new plugin to the registry. If a plugin with the same name
333
- // exists, it returns an error.
334
- func RegisterFrameworkPlugin (name string , factory framework.PluginFactory ) error {
335
- return frameworkRegistry .Register (name , factory )
336
- }
0 commit comments