diff --git a/pkg/scheduler/framework/runtime/framework.go b/pkg/scheduler/framework/runtime/framework.go index e12ed28c875b..73201c49d5ac 100644 --- a/pkg/scheduler/framework/runtime/framework.go +++ b/pkg/scheduler/framework/runtime/framework.go @@ -605,7 +605,7 @@ func (f *frameworkImpl) RunPreFilterPlugins(ctx context.Context, state *framewor if s.IsUnschedulable() { return nil, s } - return nil, framework.AsStatus(fmt.Errorf("running PreFilter plugin %q: %w", pl.Name(), status.AsError())).WithFailedPlugin(pl.Name()) + return nil, framework.AsStatus(fmt.Errorf("running PreFilter plugin %q: %w", pl.Name(), s.AsError())).WithFailedPlugin(pl.Name()) } if !r.AllNodes() { pluginsWithNodes = append(pluginsWithNodes, pl.Name()) diff --git a/pkg/scheduler/framework/runtime/framework_test.go b/pkg/scheduler/framework/runtime/framework_test.go index c1f6f1d329cd..868889f3820d 100644 --- a/pkg/scheduler/framework/runtime/framework_test.go +++ b/pkg/scheduler/framework/runtime/framework_test.go @@ -1240,6 +1240,34 @@ func TestPreFilterPlugins(t *testing.T) { }) } +func TestRunPreFilterPluginsStatus(t *testing.T) { + preFilter := &TestPlugin{ + name: preFilterPluginName, + inj: injectedResult{PreFilterStatus: int(framework.Error)}, + } + r := make(Registry) + r.Register(preFilterPluginName, + func(_ runtime.Object, fh framework.Handle) (framework.Plugin, error) { + return preFilter, nil + }) + + plugins := &config.Plugins{PreFilter: config.PluginSet{Enabled: []config.Plugin{{Name: preFilterPluginName}}}} + + profile := config.KubeSchedulerProfile{Plugins: plugins} + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + f, err := newFrameworkWithQueueSortAndBind(r, profile, ctx.Done()) + if err != nil { + t.Fatalf("Failed to create framework for testing: %v", err) + } + _, status := f.RunPreFilterPlugins(ctx, nil, nil) + wantStatus := framework.AsStatus(fmt.Errorf("running PreFilter plugin %q: %w", preFilter.Name(), errInjectedStatus)).WithFailedPlugin(preFilter.Name()) + if !reflect.DeepEqual(status, wantStatus) { + t.Errorf("wrong status. got: %v, want:%v", status, wantStatus) + } +} + func TestFilterPlugins(t *testing.T) { tests := []struct { name string