mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Fix frameworkImpl.extenders being not set
This commit is contained in:
parent
2ff70c77c9
commit
e371b27e6c
@ -160,6 +160,7 @@ func (c *Configurator) create() (*Scheduler, error) {
|
||||
frameworkruntime.WithCaptureProfile(frameworkruntime.CaptureProfile(c.frameworkCapturer)),
|
||||
frameworkruntime.WithClusterEventMap(c.clusterEventMap),
|
||||
frameworkruntime.WithParallelism(int(c.parallellism)),
|
||||
frameworkruntime.WithExtenders(extenders),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("initializing profiles: %v", err)
|
||||
|
@ -126,10 +126,11 @@ func TestSchedulerCreation(t *testing.T) {
|
||||
"Foo": defaultbinder.New,
|
||||
}
|
||||
cases := []struct {
|
||||
name string
|
||||
opts []Option
|
||||
wantErr string
|
||||
wantProfiles []string
|
||||
name string
|
||||
opts []Option
|
||||
wantErr string
|
||||
wantProfiles []string
|
||||
wantExtenders []string
|
||||
}{
|
||||
{
|
||||
name: "valid out-of-tree registry",
|
||||
@ -211,6 +212,27 @@ func TestSchedulerCreation(t *testing.T) {
|
||||
)},
|
||||
wantErr: "duplicate profile with scheduler name \"foo\"",
|
||||
},
|
||||
{
|
||||
name: "With extenders",
|
||||
opts: []Option{
|
||||
WithProfiles(
|
||||
schedulerapi.KubeSchedulerProfile{
|
||||
SchedulerName: "default-scheduler",
|
||||
Plugins: &schedulerapi.Plugins{
|
||||
QueueSort: schedulerapi.PluginSet{Enabled: []schedulerapi.Plugin{{Name: "PrioritySort"}}},
|
||||
Bind: schedulerapi.PluginSet{Enabled: []schedulerapi.Plugin{{Name: "DefaultBinder"}}},
|
||||
},
|
||||
},
|
||||
),
|
||||
WithExtenders(
|
||||
schedulerapi.Extender{
|
||||
URLPrefix: "http://extender.kube-system/",
|
||||
},
|
||||
),
|
||||
},
|
||||
wantProfiles: []string{"default-scheduler"},
|
||||
wantExtenders: []string{"http://extender.kube-system/"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
@ -230,6 +252,7 @@ func TestSchedulerCreation(t *testing.T) {
|
||||
tc.opts...,
|
||||
)
|
||||
|
||||
// Errors
|
||||
if len(tc.wantErr) != 0 {
|
||||
if err == nil || !strings.Contains(err.Error(), tc.wantErr) {
|
||||
t.Errorf("got error %q, want %q", err, tc.wantErr)
|
||||
@ -239,6 +262,8 @@ func TestSchedulerCreation(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create scheduler: %v", err)
|
||||
}
|
||||
|
||||
// Profiles
|
||||
profiles := make([]string, 0, len(s.Profiles))
|
||||
for name := range s.Profiles {
|
||||
profiles = append(profiles, name)
|
||||
@ -247,6 +272,29 @@ func TestSchedulerCreation(t *testing.T) {
|
||||
if diff := cmp.Diff(tc.wantProfiles, profiles); diff != "" {
|
||||
t.Errorf("unexpected profiles (-want, +got):\n%s", diff)
|
||||
}
|
||||
|
||||
// Extenders
|
||||
if len(tc.wantExtenders) != 0 {
|
||||
// Scheduler.Extenders
|
||||
extenders := make([]string, 0, len(s.Extenders))
|
||||
for _, e := range s.Extenders {
|
||||
extenders = append(extenders, e.Name())
|
||||
}
|
||||
if diff := cmp.Diff(tc.wantExtenders, extenders); diff != "" {
|
||||
t.Errorf("unexpected extenders (-want, +got):\n%s", diff)
|
||||
}
|
||||
|
||||
// framework.Handle.Extenders()
|
||||
for _, p := range s.Profiles {
|
||||
extenders := make([]string, 0, len(p.Extenders()))
|
||||
for _, e := range p.Extenders() {
|
||||
extenders = append(extenders, e.Name())
|
||||
}
|
||||
if diff := cmp.Diff(tc.wantExtenders, extenders); diff != "" {
|
||||
t.Errorf("unexpected extenders (-want, +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user