mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 02:11:09 +00:00
Fix the wrong status returned from RunPreFilterPlugins
event msg will be impacted due to the wrong status is returned. e.g. Warning FailedScheduling ... running PreFilter plugin "PodTopologySpread": %!!(MISSING)w(<nil>) Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
parent
a1128e380c
commit
8a288d6406
@ -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())
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user