1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
   |  func Setup() { 	 	sched, err := scheduler.New(cc.Client, 		cc.InformerFactory, 		cc.PodInformer, 		recorderFactory, 		ctx.Done(), 		scheduler.WithProfiles(cc.ComponentConfig.Profiles...), 		scheduler.WithAlgorithmSource(cc.ComponentConfig.AlgorithmSource), 		scheduler.WithPercentageOfNodesToScore(cc.ComponentConfig.PercentageOfNodesToScore), 		scheduler.WithFrameworkOutOfTreeRegistry(outOfTreeRegistry), 		scheduler.WithPodMaxBackoffSeconds(cc.ComponentConfig.PodMaxBackoffSeconds), 		scheduler.WithPodInitialBackoffSeconds(cc.ComponentConfig.PodInitialBackoffSeconds), 		scheduler.WithExtenders(cc.ComponentConfig.Extenders...), 	) 	return &cc, sched, nil }
 
  func New() (*Scheduler, error) {      registry := frameworkplugins.NewInTreeRegistry()         var sched *Scheduler 	source := options.schedulerAlgorithmSource 	switch {     	case source.Provider != nil: 		sc, err := configurator.createFromProvider(*source.Provider) 		if err != nil { 			return nil, fmt.Errorf("couldn't create scheduler using provider %q: %v", *source.Provider, err) 		} 		sched = sc    	case source.Policy != nil: 		policy := &schedulerapi.Policy{} 		switch { 		case source.Policy.File != nil: 			if err := initPolicyFromFile(source.Policy.File.Path, policy); err != nil { 				return nil, err 			} 		case source.Policy.ConfigMap != nil: 			if err := initPolicyFromConfigMap(client, source.Policy.ConfigMap, policy); err != nil { 				return nil, err 			} 		} 		configurator.extenders = policy.Extenders 		sc, err := configurator.createFromConfig(*policy) 		if err != nil { 			return nil, fmt.Errorf("couldn't create scheduler from policy: %v", err) 		} 		sched = sc 	default: 		return nil, fmt.Errorf("unsupported algorithm source: %v", source) 	} }
 
  func (c *Configurator) createFromProvider(providerName string) (*Scheduler, error) { 	klog.V(2).Infof("Creating scheduler from algorithm provider '%v'", providerName)    	r := algorithmprovider.NewRegistry() 	defaultPlugins, exist := r[providerName] 	if !exist { 		return nil, fmt.Errorf("algorithm provider %q is not registered", providerName) 	}
     	for i := range c.profiles { 		prof := &c.profiles[i] 		plugins := &schedulerapi.Plugins{} 		plugins.Append(defaultPlugins) 		plugins.Apply(prof.Plugins) 		prof.Plugins = plugins 	} 	return c.create() }
 
  func NewRegistry() Registry {    	defaultConfig := getDefaultConfig() 	applyFeatureGates(defaultConfig) 	 	caConfig := getClusterAutoscalerConfig() 	applyFeatureGates(caConfig)
  	return Registry{ 		schedulerapi.SchedulerDefaultProviderName: defaultConfig, 		ClusterAutoscalerProvider:                 caConfig, 	} }
 
 
 
 
 
  |