mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
scheduler: remove FrameworkFactory.
This commit is contained in:
parent
bf5382a53e
commit
3341023664
@ -84,24 +84,6 @@ type Configurator struct {
|
|||||||
frameworkCapturer FrameworkCapturer
|
frameworkCapturer FrameworkCapturer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Configurator) buildFramework(p schedulerapi.KubeSchedulerProfile, opts ...frameworkruntime.Option) (framework.Framework, error) {
|
|
||||||
if c.frameworkCapturer != nil {
|
|
||||||
c.frameworkCapturer(p)
|
|
||||||
}
|
|
||||||
opts = append([]frameworkruntime.Option{
|
|
||||||
frameworkruntime.WithClientSet(c.client),
|
|
||||||
frameworkruntime.WithInformerFactory(c.informerFactory),
|
|
||||||
frameworkruntime.WithSnapshotSharedLister(c.nodeInfoSnapshot),
|
|
||||||
frameworkruntime.WithRunAllFilters(c.alwaysCheckAllPredicates),
|
|
||||||
}, opts...)
|
|
||||||
return frameworkruntime.NewFramework(
|
|
||||||
c.registry,
|
|
||||||
p.Plugins,
|
|
||||||
p.PluginConfig,
|
|
||||||
opts...,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// create a scheduler from a set of registered plugins.
|
// create a scheduler from a set of registered plugins.
|
||||||
func (c *Configurator) create() (*Scheduler, error) {
|
func (c *Configurator) create() (*Scheduler, error) {
|
||||||
var extenders []framework.Extender
|
var extenders []framework.Extender
|
||||||
@ -149,8 +131,18 @@ func (c *Configurator) create() (*Scheduler, error) {
|
|||||||
|
|
||||||
// The nominator will be passed all the way to framework instantiation.
|
// The nominator will be passed all the way to framework instantiation.
|
||||||
nominator := internalqueue.NewPodNominator()
|
nominator := internalqueue.NewPodNominator()
|
||||||
profiles, err := profile.NewMap(c.profiles, c.buildFramework, c.recorderFactory,
|
profiles, err := profile.NewMap(c.profiles, c.registry, c.recorderFactory,
|
||||||
frameworkruntime.WithPodNominator(nominator))
|
frameworkruntime.WithClientSet(c.client),
|
||||||
|
frameworkruntime.WithInformerFactory(c.informerFactory),
|
||||||
|
frameworkruntime.WithSnapshotSharedLister(c.nodeInfoSnapshot),
|
||||||
|
frameworkruntime.WithRunAllFilters(c.alwaysCheckAllPredicates),
|
||||||
|
frameworkruntime.WithPodNominator(nominator),
|
||||||
|
)
|
||||||
|
for _, p := range c.profiles {
|
||||||
|
if c.frameworkCapturer != nil {
|
||||||
|
c.frameworkCapturer(p)
|
||||||
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("initializing profiles: %v", err)
|
return nil, fmt.Errorf("initializing profiles: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -33,15 +33,12 @@ import (
|
|||||||
// RecorderFactory builds an EventRecorder for a given scheduler name.
|
// RecorderFactory builds an EventRecorder for a given scheduler name.
|
||||||
type RecorderFactory func(string) events.EventRecorder
|
type RecorderFactory func(string) events.EventRecorder
|
||||||
|
|
||||||
// FrameworkFactory builds a Framework for a given profile configuration.
|
|
||||||
type FrameworkFactory func(config.KubeSchedulerProfile, ...frameworkruntime.Option) (framework.Framework, error)
|
|
||||||
|
|
||||||
// newProfile builds a Profile for the given configuration.
|
// newProfile builds a Profile for the given configuration.
|
||||||
func newProfile(cfg config.KubeSchedulerProfile, frameworkFact FrameworkFactory, recorderFact RecorderFactory,
|
func newProfile(cfg config.KubeSchedulerProfile, r frameworkruntime.Registry, recorderFact RecorderFactory,
|
||||||
opts ...frameworkruntime.Option) (framework.Framework, error) {
|
opts ...frameworkruntime.Option) (framework.Framework, error) {
|
||||||
recorder := recorderFact(cfg.SchedulerName)
|
recorder := recorderFact(cfg.SchedulerName)
|
||||||
opts = append(opts, frameworkruntime.WithEventRecorder(recorder), frameworkruntime.WithProfileName(cfg.SchedulerName))
|
opts = append(opts, frameworkruntime.WithEventRecorder(recorder), frameworkruntime.WithProfileName(cfg.SchedulerName))
|
||||||
fwk, err := frameworkFact(cfg, opts...)
|
fwk, err := frameworkruntime.NewFramework(r, cfg.Plugins, cfg.PluginConfig, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -52,7 +49,7 @@ func newProfile(cfg config.KubeSchedulerProfile, frameworkFact FrameworkFactory,
|
|||||||
type Map map[string]framework.Framework
|
type Map map[string]framework.Framework
|
||||||
|
|
||||||
// NewMap builds the frameworks given by the configuration, indexed by name.
|
// NewMap builds the frameworks given by the configuration, indexed by name.
|
||||||
func NewMap(cfgs []config.KubeSchedulerProfile, frameworkFact FrameworkFactory, recorderFact RecorderFactory,
|
func NewMap(cfgs []config.KubeSchedulerProfile, r frameworkruntime.Registry, recorderFact RecorderFactory,
|
||||||
opts ...frameworkruntime.Option) (Map, error) {
|
opts ...frameworkruntime.Option) (Map, error) {
|
||||||
m := make(Map)
|
m := make(Map)
|
||||||
v := cfgValidator{m: m}
|
v := cfgValidator{m: m}
|
||||||
@ -61,7 +58,7 @@ func NewMap(cfgs []config.KubeSchedulerProfile, frameworkFact FrameworkFactory,
|
|||||||
if err := v.validate(cfg); err != nil {
|
if err := v.validate(cfg); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
p, err := newProfile(cfg, frameworkFact, recorderFact, opts...)
|
p, err := newProfile(cfg, r, recorderFact, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("creating profile for scheduler name %s: %v", cfg.SchedulerName, err)
|
return nil, fmt.Errorf("creating profile for scheduler name %s: %v", cfg.SchedulerName, err)
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ func TestNewMap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
m, err := NewMap(tc.cfgs, fakeFrameworkFactory, nilRecorderFactory)
|
m, err := NewMap(tc.cfgs, fakeRegistry, nilRecorderFactory)
|
||||||
if err := checkErr(err, tc.wantErr); err != nil {
|
if err := checkErr(err, tc.wantErr); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -278,10 +278,6 @@ func newFakePlugin(_ runtime.Object, _ framework.Handle) (framework.Plugin, erro
|
|||||||
return &fakePlugin{}, nil
|
return &fakePlugin{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func fakeFrameworkFactory(cfg config.KubeSchedulerProfile, opts ...frameworkruntime.Option) (framework.Framework, error) {
|
|
||||||
return frameworkruntime.NewFramework(fakeRegistry, cfg.Plugins, cfg.PluginConfig, opts...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func nilRecorderFactory(_ string) events.EventRecorder {
|
func nilRecorderFactory(_ string) events.EventRecorder {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user