Change:
PLEASE COORDINATE WITH SIG-SCHEDULING BEFORE WORKING ON THIS ISSUE. We want to avoid the situation where two people accidentally start work on the same fix. Main tracking issue: In the function creates a object and populates the field with an anonymous function. At the end of that function, is called, which contains the rest of our startup logic. Rather than split this across two functions, we should put all the startup logic in one named function called (not ) so that constructing the object is much more plain. /sig scheduling /kind cleanup /help /good-first-issue
This request has been marked as suitable for new contributors. Please ensure the request meets the requirements listed . If this request no longer meets these requirements, the label can be removed by commenting with the command. <detailsIn response to : PLEASE COORDINATE WITH SIG-SCHEDULING BEFORE WORKING ON THIS ISSUE. We want to avoid the situation where two people accidentally start work on the same fix. Main tracking issue: Rather than split this across two functions, we should put all the startup logic in one named function called (not ) so that constructing the object is much more plain. /kind cleanup /help /good-first-issue </details
I'll pick this up! /assign

Discussion:
interference, deadlines, and so on. Workload-specific requirements will be exposed through the API as necessary.`, Run: func(cmd *cobra.Command, args []string) { <del> verflag.PrintAndExitIfRequested() utilflag.PrintFlags(cmd.Flags()) if len(args) != 0 { fmt.Fprint(os.Stderr, "arguments are not supportedn") } if errs := opts.Validate(); len(errs) > 0 { fmt.Fprintf(os.Stderr, "%vn", utilerrors.NewAggregate(errs)) os.Exit(1) } if len(opts.WriteConfigTo) > 0 { if err := options.WriteConfigFile(opts.WriteConfigTo, &opts.ComponentConfig); err != nil { fmt.Fprintf(os.Stderr, "%vn", err) os.Exit(1) } glog.Infof("Wrote configuration to: %sn", opts.WriteConfigTo) return } c, err := opts.Config() if err != nil { fmt.Fprintf(os.Stderr, "%vn", err) os.Exit(1) } stopCh := make(chan struct{}) if err := Run(c.Complete(), stopCh); err != nil { </del> <ins> if err := run(cmd, args, opts); err != nil { </ins> fmt.Fprintf(os.Stderr, "%vn", err) os.Exit(1) }

return cmd } <del> // Run runs the Scheduler. func Run(c schedulerserverconfig.CompletedConfig, stopCh <-chan struct{}) error { </del> <ins> // run runs the scheduler. func run(cmd *cobra.Command, args []string, opts *options.Options) error { verflag.PrintAndExitIfRequested() utilflag.PrintFlags(cmd.Flags()) if len(args) != 0 { fmt.Fprint(os.Stderr, "arguments are not supportedn") } if errs := opts.Validate(); len(errs) > 0 { fmt.Fprintf(os.Stderr, "%vn", utilerrors.NewAggregate(errs)) os.Exit(1) } if len(opts.WriteConfigTo) > 0 { if err := options.WriteConfigFile(opts.WriteConfigTo, &opts.ComponentConfig); err != nil { fmt.Fprintf(os.Stderr, "%vn", err) os.Exit(1) } glog.Infof("Wrote configuration to: %sn", opts.WriteConfigTo) } c, err := opts.Config() if err != nil { fmt.Fprintf(os.Stderr, "%vn", err) os.Exit(1) } stopCh := make(chan struct{}) // Get the completed config cc := c.Complete() </ins> // To help debugging, immediately log version glog.Infof("Version: %+v", version.Get())

} // Build a scheduler config from the provided algorithm source. <del> schedulerConfig, err := NewSchedulerConfig(c) </del> <ins> schedulerConfig, err := NewSchedulerConfig(cc) </ins> if err != nil { return err }

sched := scheduler.NewFromConfig(schedulerConfig) // Prepare the event broadcaster. <del> if c.Broadcaster != nil && c.EventClient != nil { c.Broadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: c.EventClient.Events("")}) </del> <ins> if cc.Broadcaster != nil && cc.EventClient != nil { cc.Broadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: cc.EventClient.Events("")}) </ins> } // Start up the healthz server. <del> if c.InsecureServing != nil { separateMetrics := c.InsecureMetricsServing != nil handler := buildHandlerChain(newHealthzHandler(&c.ComponentConfig, separateMetrics), nil, nil) if err := c.InsecureServing.Serve(handler, 0, stopCh); err != nil { </del> <ins> if cc.InsecureServing != nil { separateMetrics := cc.InsecureMetricsServing != nil handler := buildHandlerChain(newHealthzHandler(&cc.ComponentConfig, separateMetrics), nil, nil) if err := cc.InsecureServing.Serve(handler, 0, stopCh); err != nil { </ins> return fmt.Errorf("failed to start healthz server: %v", err) } } <del> if c.InsecureMetricsServing != nil { handler := buildHandlerChain(newMetricsHandler(&c.ComponentConfig), nil, nil) if err := c.InsecureMetricsServing.Serve(handler, 0, stopCh); err != nil { </del> <ins> if cc.InsecureMetricsServing != nil { handler := buildHandlerChain(newMetricsHandler(&cc.ComponentConfig), nil, nil) if err := cc.InsecureMetricsServing.Serve(handler, 0, stopCh); err != nil { </ins> return fmt.Errorf("failed to start metrics server: %v", err) } } <del> if c.SecureServing != nil { handler := buildHandlerChain(newHealthzHandler(&c.ComponentConfig, false), c.Authentication.Authenticator, c.Authorization.Authorizer) if err := c.SecureServing.Serve(handler, 0, stopCh); err != nil { </del> <ins> if cc.SecureServing != nil { handler := buildHandlerChain(newHealthzHandler(&cc.ComponentConfig, false), cc.Authentication.Authenticator, cc.Authorization.Authorizer) if err := cc.SecureServing.Serve(handler, 0, stopCh); err != nil { </ins> // fail early for secure handlers, removing the old error loop from above return fmt.Errorf("failed to start healthz server: %v", err) } } // Start all informers. <del> go c.PodInformer.Informer().Run(stopCh) c.InformerFactory.Start(stopCh) </del> <ins> go cc.PodInformer.Informer().Run(stopCh) cc.InformerFactory.Start(stopCh) </ins> // Wait for all caches to sync before scheduling. <del> c.InformerFactory.WaitForCacheSync(stopCh) controller.WaitForCacheSync("scheduler", stopCh, c.PodInformer.Informer().HasSynced) </del> <ins> cc.InformerFactory.WaitForCacheSync(stopCh) controller.WaitForCacheSync("scheduler", stopCh, cc.PodInformer.Informer().HasSynced) </ins> // Prepare a reusable run function. run := func(ctx context.Context) {

}() // If leader election is enabled, run via LeaderElector until done and exit. <del> if c.LeaderElection != nil { c.LeaderElection.Callbacks = leaderelection.LeaderCallbacks{ </del> <ins> if cc.LeaderElection != nil { cc.LeaderElection.Callbacks = leaderelection.LeaderCallbacks{ </ins> OnStartedLeading: run, OnStoppedLeading: func() { utilruntime.HandleError(fmt.Errorf("lost master")) }, } <del> leaderElector, err := leaderelection.NewLeaderElector(*c.LeaderElection) </del> <ins> leaderElector, err := leaderelection.NewLeaderElector(*cc.LeaderElection) </ins> if err != nil { return fmt.Errorf("couldn't create leader elector: %v", err) }