Skip to content

Commit

Permalink
Merge pull request kubernetes#103031 from ordovicia/automated-cherry-…
Browse files Browse the repository at this point in the history
…pick-of-#103019-upstream-release-1.21

Automated cherry pick of kubernetes#103019: Fix frameworkImpl.extenders being not set
  • Loading branch information
k8s-ci-robot committed Aug 6, 2021
2 parents 7e9c228 + 2fdb62f commit fbf1915
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/scheduler/factory.go
Expand Up @@ -144,6 +144,7 @@ func (c *Configurator) create() (*Scheduler, error) {
frameworkruntime.WithCaptureProfile(frameworkruntime.CaptureProfile(c.frameworkCapturer)),
frameworkruntime.WithClusterEventMap(clusterEventMap),
frameworkruntime.WithParallelism(int(c.parallellism)),
frameworkruntime.WithExtenders(extenders),
)
if err != nil {
return nil, fmt.Errorf("initializing profiles: %v", err)
Expand Down
47 changes: 43 additions & 4 deletions pkg/scheduler/scheduler_test.go
Expand Up @@ -128,10 +128,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: "default scheduler",
Expand Down Expand Up @@ -165,6 +166,18 @@ func TestSchedulerCreation(t *testing.T) {
)},
wantErr: "duplicate profile with scheduler name \"foo\"",
},
{
name: "With extenders",
opts: []Option{
WithExtenders(
schedulerapi.Extender{
URLPrefix: "http://extender.kube-system/",
},
),
},
wantProfiles: []string{"default-scheduler"},
wantExtenders: []string{"http://extender.kube-system/"},
},
}

for _, tc := range cases {
Expand All @@ -183,6 +196,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)
Expand All @@ -192,6 +206,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)
Expand All @@ -200,6 +216,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.Algorithm.Extenders()))
for _, e := range s.Algorithm.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)
}
}
}
})
}
}
Expand Down

0 comments on commit fbf1915

Please sign in to comment.