mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +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.WithCaptureProfile(frameworkruntime.CaptureProfile(c.frameworkCapturer)),
|
||||||
frameworkruntime.WithClusterEventMap(c.clusterEventMap),
|
frameworkruntime.WithClusterEventMap(c.clusterEventMap),
|
||||||
frameworkruntime.WithParallelism(int(c.parallellism)),
|
frameworkruntime.WithParallelism(int(c.parallellism)),
|
||||||
|
frameworkruntime.WithExtenders(extenders),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("initializing profiles: %v", err)
|
return nil, fmt.Errorf("initializing profiles: %v", err)
|
||||||
|
@ -126,10 +126,11 @@ func TestSchedulerCreation(t *testing.T) {
|
|||||||
"Foo": defaultbinder.New,
|
"Foo": defaultbinder.New,
|
||||||
}
|
}
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
name string
|
name string
|
||||||
opts []Option
|
opts []Option
|
||||||
wantErr string
|
wantErr string
|
||||||
wantProfiles []string
|
wantProfiles []string
|
||||||
|
wantExtenders []string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "valid out-of-tree registry",
|
name: "valid out-of-tree registry",
|
||||||
@ -211,6 +212,27 @@ func TestSchedulerCreation(t *testing.T) {
|
|||||||
)},
|
)},
|
||||||
wantErr: "duplicate profile with scheduler name \"foo\"",
|
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 {
|
for _, tc := range cases {
|
||||||
@ -230,6 +252,7 @@ func TestSchedulerCreation(t *testing.T) {
|
|||||||
tc.opts...,
|
tc.opts...,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Errors
|
||||||
if len(tc.wantErr) != 0 {
|
if len(tc.wantErr) != 0 {
|
||||||
if err == nil || !strings.Contains(err.Error(), tc.wantErr) {
|
if err == nil || !strings.Contains(err.Error(), tc.wantErr) {
|
||||||
t.Errorf("got error %q, want %q", err, tc.wantErr)
|
t.Errorf("got error %q, want %q", err, tc.wantErr)
|
||||||
@ -239,6 +262,8 @@ func TestSchedulerCreation(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create scheduler: %v", err)
|
t.Fatalf("Failed to create scheduler: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Profiles
|
||||||
profiles := make([]string, 0, len(s.Profiles))
|
profiles := make([]string, 0, len(s.Profiles))
|
||||||
for name := range s.Profiles {
|
for name := range s.Profiles {
|
||||||
profiles = append(profiles, name)
|
profiles = append(profiles, name)
|
||||||
@ -247,6 +272,29 @@ func TestSchedulerCreation(t *testing.T) {
|
|||||||
if diff := cmp.Diff(tc.wantProfiles, profiles); diff != "" {
|
if diff := cmp.Diff(tc.wantProfiles, profiles); diff != "" {
|
||||||
t.Errorf("unexpected profiles (-want, +got):\n%s", 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