Merge pull request #121469 from sanposhiho/renamerename

cleanup: rename failedPlugin to plugin in framework.Status
This commit is contained in:
Kubernetes Prow Robot 2023-10-25 20:16:43 +02:00 committed by GitHub
commit 2749509f35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 115 additions and 115 deletions

View File

@ -111,7 +111,7 @@ const (
// - when a PreScore plugin returns Skip so that coupled Score plugin will be skipped. // - when a PreScore plugin returns Skip so that coupled Score plugin will be skipped.
Skip Skip
// Pending means that the scheduling process is finished successfully, // Pending means that the scheduling process is finished successfully,
// but the plugin wants to abort the scheduling cycle/binding cycle here. // but the plugin wants to stop the scheduling cycle/binding cycle here.
// //
// For example, the DRA plugin sometimes needs to wait for the external device driver // For example, the DRA plugin sometimes needs to wait for the external device driver
// to provision the resource for the Pod. // to provision the resource for the Pod.
@ -180,9 +180,9 @@ type Status struct {
code Code code Code
reasons []string reasons []string
err error err error
// failedPlugin is an optional field that records the plugin name a Pod failed by. // plugin is an optional field that records the plugin name causes this status.
// It's set by the framework when code is Unschedulable, UnschedulableAndUnresolvable or Pending. // It's set by the framework when code is Unschedulable, UnschedulableAndUnresolvable or Pending.
failedPlugin string plugin string
} }
func (s *Status) WithError(err error) *Status { func (s *Status) WithError(err error) *Status {
@ -206,21 +206,21 @@ func (s *Status) Message() string {
return strings.Join(s.Reasons(), ", ") return strings.Join(s.Reasons(), ", ")
} }
// SetFailedPlugin sets the given plugin name to s.failedPlugin. // SetPlugin sets the given plugin name to s.plugin.
func (s *Status) SetFailedPlugin(plugin string) { func (s *Status) SetPlugin(plugin string) {
s.failedPlugin = plugin s.plugin = plugin
} }
// WithFailedPlugin sets the given plugin name to s.failedPlugin, // WithPlugin sets the given plugin name to s.plugin,
// and returns the given status object. // and returns the given status object.
func (s *Status) WithFailedPlugin(plugin string) *Status { func (s *Status) WithPlugin(plugin string) *Status {
s.SetFailedPlugin(plugin) s.SetPlugin(plugin)
return s return s
} }
// FailedPlugin returns the failed plugin name. // Plugin returns the plugin name which caused this status.
func (s *Status) FailedPlugin() string { func (s *Status) Plugin() string {
return s.failedPlugin return s.plugin
} }
// Reasons returns reasons of the Status. // Reasons returns reasons of the Status.
@ -251,10 +251,10 @@ func (s *Status) IsSkip() bool {
return s.Code() == Skip return s.Code() == Skip
} }
// IsUnschedulable returns true if "Status" is Unschedulable (Unschedulable or UnschedulableAndUnresolvable). // IsRejected returns true if "Status" is Unschedulable (Unschedulable, UnschedulableAndUnresolvable, or Pending).
func (s *Status) IsUnschedulable() bool { func (s *Status) IsRejected() bool {
code := s.Code() code := s.Code()
return code == Unschedulable || code == UnschedulableAndUnresolvable return code == Unschedulable || code == UnschedulableAndUnresolvable || code == Pending
} }
// AsError returns nil if the status is a success, a wait or a skip; otherwise returns an "error" object // AsError returns nil if the status is a success, a wait or a skip; otherwise returns an "error" object
@ -284,7 +284,7 @@ func (s *Status) Equal(x *Status) bool {
if !cmp.Equal(s.reasons, x.reasons) { if !cmp.Equal(s.reasons, x.reasons) {
return false return false
} }
return cmp.Equal(s.failedPlugin, x.failedPlugin) return cmp.Equal(s.plugin, x.plugin)
} }
// NewStatus makes a Status out of the given arguments and returns its pointer. // NewStatus makes a Status out of the given arguments and returns its pointer.

View File

@ -1773,7 +1773,7 @@ func TestPreempt(t *testing.T) {
Interface: &pl, Interface: &pl,
} }
res, status := pe.Preempt(ctx, test.pod, make(framework.NodeToStatusMap)) res, status := pe.Preempt(ctx, test.pod, make(framework.NodeToStatusMap))
if !status.IsSuccess() && !status.IsUnschedulable() { if !status.IsSuccess() && !status.IsRejected() {
t.Errorf("unexpected error in preemption: %v", status.AsError()) t.Errorf("unexpected error in preemption: %v", status.AsError())
} }
if diff := cmp.Diff(test.want, res); diff != "" { if diff := cmp.Diff(test.want, res); diff != "" {
@ -1812,7 +1812,7 @@ func TestPreempt(t *testing.T) {
// Call preempt again and make sure it doesn't preempt any more pods. // Call preempt again and make sure it doesn't preempt any more pods.
res, status = pe.Preempt(ctx, test.pod, make(framework.NodeToStatusMap)) res, status = pe.Preempt(ctx, test.pod, make(framework.NodeToStatusMap))
if !status.IsSuccess() && !status.IsUnschedulable() { if !status.IsSuccess() && !status.IsRejected() {
t.Errorf("unexpected error in preemption: %v", status.AsError()) t.Errorf("unexpected error in preemption: %v", status.AsError())
} }
if res != nil && res.NominatingInfo != nil && len(deletedPodNames) > 0 { if res != nil && res.NominatingInfo != nil && len(deletedPodNames) > 0 {

View File

@ -176,7 +176,7 @@ func (ev *Evaluator) Preempt(ctx context.Context, pod *v1.Pod, m framework.NodeT
NumAllNodes: len(nodeToStatusMap), NumAllNodes: len(nodeToStatusMap),
Diagnosis: framework.Diagnosis{ Diagnosis: framework.Diagnosis{
NodeToStatusMap: nodeToStatusMap, NodeToStatusMap: nodeToStatusMap,
// Leave FailedPlugins as nil as it won't be used on moving Pods. // Leave UnschedulablePlugins or PendingPlugins as nil as it won't be used on moving Pods.
}, },
} }
// Specify nominatedNodeName to clear the pod's nominatedNodeName status, if applicable. // Specify nominatedNodeName to clear the pod's nominatedNodeName status, if applicable.

View File

@ -654,11 +654,11 @@ func (f *frameworkImpl) RunPreFilterPlugins(ctx context.Context, state *framewor
continue continue
} }
if !s.IsSuccess() { if !s.IsSuccess() {
s.SetFailedPlugin(pl.Name()) s.SetPlugin(pl.Name())
if s.IsUnschedulable() { if s.IsRejected() {
return nil, s return nil, s
} }
return nil, framework.AsStatus(fmt.Errorf("running PreFilter plugin %q: %w", pl.Name(), s.AsError())).WithFailedPlugin(pl.Name()) return nil, framework.AsStatus(fmt.Errorf("running PreFilter plugin %q: %w", pl.Name(), s.AsError())).WithPlugin(pl.Name())
} }
if !r.AllNodes() { if !r.AllNodes() {
pluginsWithNodes = append(pluginsWithNodes, pl.Name()) pluginsWithNodes = append(pluginsWithNodes, pl.Name())
@ -795,12 +795,12 @@ func (f *frameworkImpl) RunFilterPlugins(
continue continue
} }
if status := f.runFilterPlugin(ctx, pl, state, pod, nodeInfo); !status.IsSuccess() { if status := f.runFilterPlugin(ctx, pl, state, pod, nodeInfo); !status.IsSuccess() {
if !status.IsUnschedulable() { if !status.IsRejected() {
// Filter plugins are not supposed to return any status other than // Filter plugins are not supposed to return any status other than
// Success or Unschedulable. // Success or Unschedulable.
status = framework.AsStatus(fmt.Errorf("running %q filter plugin: %w", pl.Name(), status.AsError())) status = framework.AsStatus(fmt.Errorf("running %q filter plugin: %w", pl.Name(), status.AsError()))
} }
status.SetFailedPlugin(pl.Name()) status.SetPlugin(pl.Name())
return status return status
} }
} }
@ -836,7 +836,7 @@ func (f *frameworkImpl) RunPostFilterPlugins(ctx context.Context, state *framewo
// `result` records the last meaningful(non-noop) PostFilterResult. // `result` records the last meaningful(non-noop) PostFilterResult.
var result *framework.PostFilterResult var result *framework.PostFilterResult
var reasons []string var reasons []string
var failedPlugin string var rejectorPlugin string
for _, pl := range f.postFilterPlugins { for _, pl := range f.postFilterPlugins {
logger := klog.LoggerWithName(logger, pl.Name()) logger := klog.LoggerWithName(logger, pl.Name())
ctx := klog.NewContext(ctx, logger) ctx := klog.NewContext(ctx, logger)
@ -844,10 +844,10 @@ func (f *frameworkImpl) RunPostFilterPlugins(ctx context.Context, state *framewo
if s.IsSuccess() { if s.IsSuccess() {
return r, s return r, s
} else if s.Code() == framework.UnschedulableAndUnresolvable { } else if s.Code() == framework.UnschedulableAndUnresolvable {
return r, s.WithFailedPlugin(pl.Name()) return r, s.WithPlugin(pl.Name())
} else if !s.IsUnschedulable() { } else if !s.IsRejected() {
// Any status other than Success, Unschedulable or UnschedulableAndUnresolvable is Error. // Any status other than Success, Unschedulable or UnschedulableAndUnresolvable is Error.
return nil, framework.AsStatus(s.AsError()).WithFailedPlugin(pl.Name()) return nil, framework.AsStatus(s.AsError()).WithPlugin(pl.Name())
} else if r != nil && r.Mode() != framework.ModeNoop { } else if r != nil && r.Mode() != framework.ModeNoop {
result = r result = r
} }
@ -855,12 +855,12 @@ func (f *frameworkImpl) RunPostFilterPlugins(ctx context.Context, state *framewo
reasons = append(reasons, s.Reasons()...) reasons = append(reasons, s.Reasons()...)
// Record the first failed plugin unless we proved that // Record the first failed plugin unless we proved that
// the latter is more relevant. // the latter is more relevant.
if len(failedPlugin) == 0 { if len(rejectorPlugin) == 0 {
failedPlugin = pl.Name() rejectorPlugin = pl.Name()
} }
} }
return result, framework.NewStatus(framework.Unschedulable, reasons...).WithFailedPlugin(failedPlugin) return result, framework.NewStatus(framework.Unschedulable, reasons...).WithPlugin(rejectorPlugin)
} }
func (f *frameworkImpl) runPostFilterPlugin(ctx context.Context, pl framework.PostFilterPlugin, state *framework.CycleState, pod *v1.Pod, filteredNodeStatusMap framework.NodeToStatusMap) (*framework.PostFilterResult, *framework.Status) { func (f *frameworkImpl) runPostFilterPlugin(ctx context.Context, pl framework.PostFilterPlugin, state *framework.CycleState, pod *v1.Pod, filteredNodeStatusMap framework.NodeToStatusMap) (*framework.PostFilterResult, *framework.Status) {
@ -922,7 +922,7 @@ func (f *frameworkImpl) RunFilterPluginsWithNominatedPods(ctx context.Context, s
} }
status = f.RunFilterPlugins(ctx, stateToUse, pod, nodeInfoToUse) status = f.RunFilterPlugins(ctx, stateToUse, pod, nodeInfoToUse)
if !status.IsSuccess() && !status.IsUnschedulable() { if !status.IsSuccess() && !status.IsRejected() {
return status return status
} }
} }
@ -1151,9 +1151,9 @@ func (f *frameworkImpl) RunPreBindPlugins(ctx context.Context, state *framework.
ctx := klog.NewContext(ctx, logger) ctx := klog.NewContext(ctx, logger)
status = f.runPreBindPlugin(ctx, pl, state, pod, nodeName) status = f.runPreBindPlugin(ctx, pl, state, pod, nodeName)
if !status.IsSuccess() { if !status.IsSuccess() {
if status.IsUnschedulable() { if status.IsRejected() {
logger.V(4).Info("Pod rejected by PreBind plugin", "pod", klog.KObj(pod), "node", nodeName, "plugin", pl.Name(), "status", status.Message()) logger.V(4).Info("Pod rejected by PreBind plugin", "pod", klog.KObj(pod), "node", nodeName, "plugin", pl.Name(), "status", status.Message())
status.SetFailedPlugin(pl.Name()) status.SetPlugin(pl.Name())
return status return status
} }
err := status.AsError() err := status.AsError()
@ -1197,9 +1197,9 @@ func (f *frameworkImpl) RunBindPlugins(ctx context.Context, state *framework.Cyc
continue continue
} }
if !status.IsSuccess() { if !status.IsSuccess() {
if status.IsUnschedulable() { if status.IsRejected() {
logger.V(4).Info("Pod rejected by Bind plugin", "pod", klog.KObj(pod), "node", nodeName, "plugin", pl.Name(), "status", status.Message()) logger.V(4).Info("Pod rejected by Bind plugin", "pod", klog.KObj(pod), "node", nodeName, "plugin", pl.Name(), "status", status.Message())
status.SetFailedPlugin(pl.Name()) status.SetPlugin(pl.Name())
return status return status
} }
err := status.AsError() err := status.AsError()
@ -1271,9 +1271,9 @@ func (f *frameworkImpl) RunReservePluginsReserve(ctx context.Context, state *fra
ctx := klog.NewContext(ctx, logger) ctx := klog.NewContext(ctx, logger)
status = f.runReservePluginReserve(ctx, pl, state, pod, nodeName) status = f.runReservePluginReserve(ctx, pl, state, pod, nodeName)
if !status.IsSuccess() { if !status.IsSuccess() {
if status.IsUnschedulable() { if status.IsRejected() {
logger.V(4).Info("Pod rejected by plugin", "pod", klog.KObj(pod), "plugin", pl.Name(), "status", status.Message()) logger.V(4).Info("Pod rejected by plugin", "pod", klog.KObj(pod), "plugin", pl.Name(), "status", status.Message())
status.SetFailedPlugin(pl.Name()) status.SetPlugin(pl.Name())
return status return status
} }
err := status.AsError() err := status.AsError()
@ -1350,9 +1350,9 @@ func (f *frameworkImpl) RunPermitPlugins(ctx context.Context, state *framework.C
ctx := klog.NewContext(ctx, logger) ctx := klog.NewContext(ctx, logger)
status, timeout := f.runPermitPlugin(ctx, pl, state, pod, nodeName) status, timeout := f.runPermitPlugin(ctx, pl, state, pod, nodeName)
if !status.IsSuccess() { if !status.IsSuccess() {
if status.IsUnschedulable() { if status.IsRejected() {
logger.V(4).Info("Pod rejected by plugin", "pod", klog.KObj(pod), "plugin", pl.Name(), "status", status.Message()) logger.V(4).Info("Pod rejected by plugin", "pod", klog.KObj(pod), "plugin", pl.Name(), "status", status.Message())
return status.WithFailedPlugin(pl.Name()) return status.WithPlugin(pl.Name())
} }
if status.IsWait() { if status.IsWait() {
// Not allowed to be greater than maxTimeout. // Not allowed to be greater than maxTimeout.
@ -1364,7 +1364,7 @@ func (f *frameworkImpl) RunPermitPlugins(ctx context.Context, state *framework.C
} else { } else {
err := status.AsError() err := status.AsError()
logger.Error(err, "Plugin failed", "plugin", pl.Name(), "pod", klog.KObj(pod)) logger.Error(err, "Plugin failed", "plugin", pl.Name(), "pod", klog.KObj(pod))
return framework.AsStatus(fmt.Errorf("running Permit plugin %q: %w", pl.Name(), err)).WithFailedPlugin(pl.Name()) return framework.AsStatus(fmt.Errorf("running Permit plugin %q: %w", pl.Name(), err)).WithPlugin(pl.Name())
} }
} }
} }
@ -1404,13 +1404,13 @@ func (f *frameworkImpl) WaitOnPermit(ctx context.Context, pod *v1.Pod) *framewor
metrics.PermitWaitDuration.WithLabelValues(s.Code().String()).Observe(metrics.SinceInSeconds(startTime)) metrics.PermitWaitDuration.WithLabelValues(s.Code().String()).Observe(metrics.SinceInSeconds(startTime))
if !s.IsSuccess() { if !s.IsSuccess() {
if s.IsUnschedulable() { if s.IsRejected() {
logger.V(4).Info("Pod rejected while waiting on permit", "pod", klog.KObj(pod), "status", s.Message()) logger.V(4).Info("Pod rejected while waiting on permit", "pod", klog.KObj(pod), "status", s.Message())
return s return s
} }
err := s.AsError() err := s.AsError()
logger.Error(err, "Failed waiting on permit for pod", "pod", klog.KObj(pod)) logger.Error(err, "Failed waiting on permit for pod", "pod", klog.KObj(pod))
return framework.AsStatus(fmt.Errorf("waiting on permit for pod: %w", err)).WithFailedPlugin(s.FailedPlugin()) return framework.AsStatus(fmt.Errorf("waiting on permit for pod: %w", err)).WithPlugin(s.Plugin())
} }
return nil return nil
} }

View File

@ -72,7 +72,7 @@ var cmpOpts = []cmp.Option{
if s1 == nil || s2 == nil { if s1 == nil || s2 == nil {
return s1.IsSuccess() && s2.IsSuccess() return s1.IsSuccess() && s2.IsSuccess()
} }
return s1.Code() == s2.Code() && s1.FailedPlugin() == s2.FailedPlugin() && s1.Message() == s2.Message() return s1.Code() == s2.Code() && s1.Plugin() == s2.Plugin() && s1.Message() == s2.Message()
}), }),
} }
@ -1793,7 +1793,7 @@ func TestFilterPlugins(t *testing.T) {
inj: injectedResult{FilterStatus: int(framework.Error)}, inj: injectedResult{FilterStatus: int(framework.Error)},
}, },
}, },
wantStatus: framework.AsStatus(fmt.Errorf(`running "TestPlugin" filter plugin: %w`, errInjectedFilterStatus)).WithFailedPlugin("TestPlugin"), wantStatus: framework.AsStatus(fmt.Errorf(`running "TestPlugin" filter plugin: %w`, errInjectedFilterStatus)).WithPlugin("TestPlugin"),
}, },
{ {
name: "UnschedulableFilter", name: "UnschedulableFilter",
@ -1803,7 +1803,7 @@ func TestFilterPlugins(t *testing.T) {
inj: injectedResult{FilterStatus: int(framework.Unschedulable)}, inj: injectedResult{FilterStatus: int(framework.Unschedulable)},
}, },
}, },
wantStatus: framework.NewStatus(framework.Unschedulable, injectFilterReason).WithFailedPlugin("TestPlugin"), wantStatus: framework.NewStatus(framework.Unschedulable, injectFilterReason).WithPlugin("TestPlugin"),
}, },
{ {
name: "UnschedulableAndUnresolvableFilter", name: "UnschedulableAndUnresolvableFilter",
@ -1814,7 +1814,7 @@ func TestFilterPlugins(t *testing.T) {
FilterStatus: int(framework.UnschedulableAndUnresolvable)}, FilterStatus: int(framework.UnschedulableAndUnresolvable)},
}, },
}, },
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectFilterReason).WithFailedPlugin("TestPlugin"), wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectFilterReason).WithPlugin("TestPlugin"),
}, },
// following tests cover multiple-plugins scenarios // following tests cover multiple-plugins scenarios
{ {
@ -1829,7 +1829,7 @@ func TestFilterPlugins(t *testing.T) {
inj: injectedResult{FilterStatus: int(framework.Error)}, inj: injectedResult{FilterStatus: int(framework.Error)},
}, },
}, },
wantStatus: framework.AsStatus(fmt.Errorf(`running "TestPlugin1" filter plugin: %w`, errInjectedFilterStatus)).WithFailedPlugin("TestPlugin1"), wantStatus: framework.AsStatus(fmt.Errorf(`running "TestPlugin1" filter plugin: %w`, errInjectedFilterStatus)).WithPlugin("TestPlugin1"),
}, },
{ {
name: "UnschedulableAndUnschedulableFilters", name: "UnschedulableAndUnschedulableFilters",
@ -1843,7 +1843,7 @@ func TestFilterPlugins(t *testing.T) {
inj: injectedResult{FilterStatus: int(framework.Unschedulable)}, inj: injectedResult{FilterStatus: int(framework.Unschedulable)},
}, },
}, },
wantStatus: framework.NewStatus(framework.Unschedulable, injectFilterReason).WithFailedPlugin("TestPlugin1"), wantStatus: framework.NewStatus(framework.Unschedulable, injectFilterReason).WithPlugin("TestPlugin1"),
}, },
{ {
name: "UnschedulableAndUnschedulableAndUnresolvableFilters", name: "UnschedulableAndUnschedulableAndUnresolvableFilters",
@ -1857,7 +1857,7 @@ func TestFilterPlugins(t *testing.T) {
inj: injectedResult{FilterStatus: int(framework.Unschedulable)}, inj: injectedResult{FilterStatus: int(framework.Unschedulable)},
}, },
}, },
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectFilterReason).WithFailedPlugin("TestPlugin1"), wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectFilterReason).WithPlugin("TestPlugin1"),
}, },
{ {
name: "SuccessAndSuccessFilters", name: "SuccessAndSuccessFilters",
@ -1901,7 +1901,7 @@ func TestFilterPlugins(t *testing.T) {
inj: injectedResult{FilterStatus: int(framework.Success)}, inj: injectedResult{FilterStatus: int(framework.Success)},
}, },
}, },
wantStatus: framework.AsStatus(fmt.Errorf(`running "TestPlugin1" filter plugin: %w`, errInjectedFilterStatus)).WithFailedPlugin("TestPlugin1"), wantStatus: framework.AsStatus(fmt.Errorf(`running "TestPlugin1" filter plugin: %w`, errInjectedFilterStatus)).WithPlugin("TestPlugin1"),
}, },
{ {
name: "SuccessAndErrorFilters", name: "SuccessAndErrorFilters",
@ -1916,7 +1916,7 @@ func TestFilterPlugins(t *testing.T) {
inj: injectedResult{FilterStatus: int(framework.Error)}, inj: injectedResult{FilterStatus: int(framework.Error)},
}, },
}, },
wantStatus: framework.AsStatus(fmt.Errorf(`running "TestPlugin2" filter plugin: %w`, errInjectedFilterStatus)).WithFailedPlugin("TestPlugin2"), wantStatus: framework.AsStatus(fmt.Errorf(`running "TestPlugin2" filter plugin: %w`, errInjectedFilterStatus)).WithPlugin("TestPlugin2"),
}, },
{ {
name: "SuccessAndUnschedulableFilters", name: "SuccessAndUnschedulableFilters",
@ -1930,7 +1930,7 @@ func TestFilterPlugins(t *testing.T) {
inj: injectedResult{FilterStatus: int(framework.Unschedulable)}, inj: injectedResult{FilterStatus: int(framework.Unschedulable)},
}, },
}, },
wantStatus: framework.NewStatus(framework.Unschedulable, injectFilterReason).WithFailedPlugin("TestPlugin2"), wantStatus: framework.NewStatus(framework.Unschedulable, injectFilterReason).WithPlugin("TestPlugin2"),
}, },
} }
@ -2026,7 +2026,7 @@ func TestPostFilterPlugins(t *testing.T) {
inj: injectedResult{PostFilterStatus: int(framework.Success)}, inj: injectedResult{PostFilterStatus: int(framework.Success)},
}, },
}, },
wantStatus: framework.AsStatus(fmt.Errorf(injectReason)).WithFailedPlugin("TestPlugin1"), wantStatus: framework.AsStatus(fmt.Errorf(injectReason)).WithPlugin("TestPlugin1"),
}, },
{ {
name: "plugin1 failed to make a Pod schedulable, followed by plugin2 which makes the Pod unresolvable", name: "plugin1 failed to make a Pod schedulable, followed by plugin2 which makes the Pod unresolvable",
@ -2040,7 +2040,7 @@ func TestPostFilterPlugins(t *testing.T) {
inj: injectedResult{PostFilterStatus: int(framework.UnschedulableAndUnresolvable)}, inj: injectedResult{PostFilterStatus: int(framework.UnschedulableAndUnresolvable)},
}, },
}, },
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithFailedPlugin("TestPlugin2"), wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithPlugin("TestPlugin2"),
}, },
{ {
name: "both plugins failed to make a Pod schedulable", name: "both plugins failed to make a Pod schedulable",
@ -2054,7 +2054,7 @@ func TestPostFilterPlugins(t *testing.T) {
inj: injectedResult{PostFilterStatus: int(framework.Unschedulable)}, inj: injectedResult{PostFilterStatus: int(framework.Unschedulable)},
}, },
}, },
wantStatus: framework.NewStatus(framework.Unschedulable, []string{injectReason, injectReason}...).WithFailedPlugin("TestPlugin1"), wantStatus: framework.NewStatus(framework.Unschedulable, []string{injectReason, injectReason}...).WithPlugin("TestPlugin1"),
}, },
} }
@ -2166,7 +2166,7 @@ func TestFilterPluginsWithNominatedPods(t *testing.T) {
nominatedPod: highPriorityPod, nominatedPod: highPriorityPod,
node: node, node: node,
nodeInfo: framework.NewNodeInfo(pod), nodeInfo: framework.NewNodeInfo(pod),
wantStatus: framework.AsStatus(fmt.Errorf(`running "TestPlugin2" filter plugin: %w`, errInjectedFilterStatus)).WithFailedPlugin("TestPlugin2"), wantStatus: framework.AsStatus(fmt.Errorf(`running "TestPlugin2" filter plugin: %w`, errInjectedFilterStatus)).WithPlugin("TestPlugin2"),
}, },
{ {
name: "node has a low-priority nominated pod and pre filters return unschedulable", name: "node has a low-priority nominated pod and pre filters return unschedulable",
@ -2273,7 +2273,7 @@ func TestPreBindPlugins(t *testing.T) {
inj: injectedResult{PreBindStatus: int(framework.Unschedulable)}, inj: injectedResult{PreBindStatus: int(framework.Unschedulable)},
}, },
}, },
wantStatus: framework.NewStatus(framework.Unschedulable, injectReason).WithFailedPlugin("TestPlugin"), wantStatus: framework.NewStatus(framework.Unschedulable, injectReason).WithPlugin("TestPlugin"),
}, },
{ {
name: "ErrorPreBindPlugin", name: "ErrorPreBindPlugin",
@ -2293,7 +2293,7 @@ func TestPreBindPlugins(t *testing.T) {
inj: injectedResult{PreBindStatus: int(framework.UnschedulableAndUnresolvable)}, inj: injectedResult{PreBindStatus: int(framework.UnschedulableAndUnresolvable)},
}, },
}, },
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithFailedPlugin("TestPlugin"), wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithPlugin("TestPlugin"),
}, },
{ {
name: "SuccessErrorPreBindPlugins", name: "SuccessErrorPreBindPlugins",
@ -2363,7 +2363,7 @@ func TestPreBindPlugins(t *testing.T) {
inj: injectedResult{PreBindStatus: int(framework.Success)}, inj: injectedResult{PreBindStatus: int(framework.Success)},
}, },
}, },
wantStatus: framework.NewStatus(framework.Unschedulable, injectReason).WithFailedPlugin("TestPlugin"), wantStatus: framework.NewStatus(framework.Unschedulable, injectReason).WithPlugin("TestPlugin"),
}, },
} }
@ -2431,7 +2431,7 @@ func TestReservePlugins(t *testing.T) {
inj: injectedResult{ReserveStatus: int(framework.Unschedulable)}, inj: injectedResult{ReserveStatus: int(framework.Unschedulable)},
}, },
}, },
wantStatus: framework.NewStatus(framework.Unschedulable, injectReason).WithFailedPlugin("TestPlugin"), wantStatus: framework.NewStatus(framework.Unschedulable, injectReason).WithPlugin("TestPlugin"),
}, },
{ {
name: "ErrorReservePlugin", name: "ErrorReservePlugin",
@ -2451,7 +2451,7 @@ func TestReservePlugins(t *testing.T) {
inj: injectedResult{ReserveStatus: int(framework.UnschedulableAndUnresolvable)}, inj: injectedResult{ReserveStatus: int(framework.UnschedulableAndUnresolvable)},
}, },
}, },
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithFailedPlugin("TestPlugin"), wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithPlugin("TestPlugin"),
}, },
{ {
name: "SuccessSuccessReservePlugins", name: "SuccessSuccessReservePlugins",
@ -2521,7 +2521,7 @@ func TestReservePlugins(t *testing.T) {
inj: injectedResult{ReserveStatus: int(framework.Success)}, inj: injectedResult{ReserveStatus: int(framework.Success)},
}, },
}, },
wantStatus: framework.NewStatus(framework.Unschedulable, injectReason).WithFailedPlugin("TestPlugin"), wantStatus: framework.NewStatus(framework.Unschedulable, injectReason).WithPlugin("TestPlugin"),
}, },
} }
@ -2589,7 +2589,7 @@ func TestPermitPlugins(t *testing.T) {
inj: injectedResult{PermitStatus: int(framework.Unschedulable)}, inj: injectedResult{PermitStatus: int(framework.Unschedulable)},
}, },
}, },
want: framework.NewStatus(framework.Unschedulable, injectReason).WithFailedPlugin("TestPlugin"), want: framework.NewStatus(framework.Unschedulable, injectReason).WithPlugin("TestPlugin"),
}, },
{ {
name: "ErrorPermitPlugin", name: "ErrorPermitPlugin",
@ -2599,7 +2599,7 @@ func TestPermitPlugins(t *testing.T) {
inj: injectedResult{PermitStatus: int(framework.Error)}, inj: injectedResult{PermitStatus: int(framework.Error)},
}, },
}, },
want: framework.AsStatus(fmt.Errorf(`running Permit plugin "TestPlugin": %w`, errInjectedStatus)).WithFailedPlugin("TestPlugin"), want: framework.AsStatus(fmt.Errorf(`running Permit plugin "TestPlugin": %w`, errInjectedStatus)).WithPlugin("TestPlugin"),
}, },
{ {
name: "UnschedulableAndUnresolvablePermitPlugin", name: "UnschedulableAndUnresolvablePermitPlugin",
@ -2609,7 +2609,7 @@ func TestPermitPlugins(t *testing.T) {
inj: injectedResult{PermitStatus: int(framework.UnschedulableAndUnresolvable)}, inj: injectedResult{PermitStatus: int(framework.UnschedulableAndUnresolvable)},
}, },
}, },
want: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithFailedPlugin("TestPlugin"), want: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithPlugin("TestPlugin"),
}, },
{ {
name: "WaitPermitPlugin", name: "WaitPermitPlugin",
@ -2647,7 +2647,7 @@ func TestPermitPlugins(t *testing.T) {
inj: injectedResult{PermitStatus: int(framework.Error)}, inj: injectedResult{PermitStatus: int(framework.Error)},
}, },
}, },
want: framework.AsStatus(fmt.Errorf(`running Permit plugin "TestPlugin": %w`, errInjectedStatus)).WithFailedPlugin("TestPlugin"), want: framework.AsStatus(fmt.Errorf(`running Permit plugin "TestPlugin": %w`, errInjectedStatus)).WithPlugin("TestPlugin"),
}, },
} }
@ -3051,7 +3051,7 @@ func TestWaitOnPermit(t *testing.T) {
action: func(f framework.Framework) { action: func(f framework.Framework) {
f.GetWaitingPod(pod.UID).Reject(permitPlugin, "reject message") f.GetWaitingPod(pod.UID).Reject(permitPlugin, "reject message")
}, },
want: framework.NewStatus(framework.Unschedulable, "reject message").WithFailedPlugin(permitPlugin), want: framework.NewStatus(framework.Unschedulable, "reject message").WithPlugin(permitPlugin),
}, },
{ {
name: "Allow Waiting Pod", name: "Allow Waiting Pod",

View File

@ -21,7 +21,7 @@ import (
"sync" "sync"
"time" "time"
"k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/scheduler/framework" "k8s.io/kubernetes/pkg/scheduler/framework"
) )
@ -159,7 +159,7 @@ func (w *waitingPod) Reject(pluginName, msg string) {
// The select clause works as a non-blocking send. // The select clause works as a non-blocking send.
// If there is no receiver, it's a no-op (default case). // If there is no receiver, it's a no-op (default case).
select { select {
case w.s <- framework.NewStatus(framework.Unschedulable, msg).WithFailedPlugin(pluginName): case w.s <- framework.NewStatus(framework.Unschedulable, msg).WithPlugin(pluginName):
default: default:
} }
} }

View File

@ -305,20 +305,20 @@ const (
) )
func (d *Diagnosis) AddPluginStatus(sts *Status) { func (d *Diagnosis) AddPluginStatus(sts *Status) {
if sts.FailedPlugin() == "" { if sts.Plugin() == "" {
return return
} }
if sts.IsUnschedulable() { if sts.IsRejected() {
if d.UnschedulablePlugins == nil { if d.UnschedulablePlugins == nil {
d.UnschedulablePlugins = sets.New[string]() d.UnschedulablePlugins = sets.New[string]()
} }
d.UnschedulablePlugins.Insert(sts.FailedPlugin()) d.UnschedulablePlugins.Insert(sts.Plugin())
} }
if sts.Code() == Pending { if sts.Code() == Pending {
if d.PendingPlugins == nil { if d.PendingPlugins == nil {
d.PendingPlugins = sets.New[string]() d.PendingPlugins = sets.New[string]()
} }
d.PendingPlugins.Insert(sts.FailedPlugin()) d.PendingPlugins.Insert(sts.Plugin())
} }
} }

View File

@ -418,8 +418,8 @@ const (
// If all QueueingHintFns returns Skip, the scheduling queue enqueues the Pod back to unschedulable Pod pool // If all QueueingHintFns returns Skip, the scheduling queue enqueues the Pod back to unschedulable Pod pool
// because no plugin changes the scheduling result via the event. // because no plugin changes the scheduling result via the event.
func (p *PriorityQueue) isPodWorthRequeuing(logger klog.Logger, pInfo *framework.QueuedPodInfo, event framework.ClusterEvent, oldObj, newObj interface{}) queueingStrategy { func (p *PriorityQueue) isPodWorthRequeuing(logger klog.Logger, pInfo *framework.QueuedPodInfo, event framework.ClusterEvent, oldObj, newObj interface{}) queueingStrategy {
failedPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins) rejectorPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins)
if failedPlugins.Len() == 0 { if rejectorPlugins.Len() == 0 {
logger.V(6).Info("Worth requeuing because no failed plugins", "pod", klog.KObj(pInfo.Pod)) logger.V(6).Info("Worth requeuing because no failed plugins", "pod", klog.KObj(pInfo.Pod))
return queueAfterBackoff return queueAfterBackoff
} }
@ -446,8 +446,8 @@ func (p *PriorityQueue) isPodWorthRequeuing(logger klog.Logger, pInfo *framework
} }
for _, hintfn := range hintfns { for _, hintfn := range hintfns {
if !failedPlugins.Has(hintfn.PluginName) { if !rejectorPlugins.Has(hintfn.PluginName) {
// skip if it's not hintfn from failedPlugins. // skip if it's not hintfn from rejectorPlugins.
continue continue
} }
@ -671,8 +671,8 @@ func (p *PriorityQueue) determineSchedulingHintForInFlightPod(logger klog.Logger
return queueSkip return queueSkip
} }
failedPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins) rejectorPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins)
if len(failedPlugins) == 0 { if len(rejectorPlugins) == 0 {
// No failed plugins are associated with this Pod. // No failed plugins are associated with this Pod.
// Meaning something unusual (a temporal failure on kube-apiserver, etc) happened and this Pod gets moved back to the queue. // Meaning something unusual (a temporal failure on kube-apiserver, etc) happened and this Pod gets moved back to the queue.
// In this case, we should retry scheduling it because this Pod may not be retried until the next flush. // In this case, we should retry scheduling it because this Pod may not be retried until the next flush.
@ -722,14 +722,14 @@ func (p *PriorityQueue) addUnschedulableWithoutQueueingHint(logger klog.Logger,
// When the queueing hint is enabled, they are used differently. // When the queueing hint is enabled, they are used differently.
// But, we use all of them as UnschedulablePlugins when the queueing hint isn't enabled so that we don't break the old behaviour. // But, we use all of them as UnschedulablePlugins when the queueing hint isn't enabled so that we don't break the old behaviour.
failedPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins) rejectorPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins)
// If a move request has been received, move it to the BackoffQ, otherwise move // If a move request has been received, move it to the BackoffQ, otherwise move
// it to unschedulablePods. // it to unschedulablePods.
for plugin := range failedPlugins { for plugin := range rejectorPlugins {
metrics.UnschedulableReason(plugin, pInfo.Pod.Spec.SchedulerName).Inc() metrics.UnschedulableReason(plugin, pInfo.Pod.Spec.SchedulerName).Inc()
} }
if p.moveRequestCycle >= podSchedulingCycle || len(failedPlugins) == 0 { if p.moveRequestCycle >= podSchedulingCycle || len(rejectorPlugins) == 0 {
// Two cases to move a Pod to the active/backoff queue: // Two cases to move a Pod to the active/backoff queue:
// - The Pod is rejected by some plugins, but a move request is received after this Pod's scheduling cycle is started. // - The Pod is rejected by some plugins, but a move request is received after this Pod's scheduling cycle is started.
// In this case, the received event may be make Pod schedulable and we should retry scheduling it. // In this case, the received event may be make Pod schedulable and we should retry scheduling it.
@ -784,8 +784,8 @@ func (p *PriorityQueue) AddUnschedulableIfNotPresent(logger klog.Logger, pInfo *
// If a move request has been received, move it to the BackoffQ, otherwise move // If a move request has been received, move it to the BackoffQ, otherwise move
// it to unschedulablePods. // it to unschedulablePods.
failedPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins) rejectorPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins)
for plugin := range failedPlugins { for plugin := range rejectorPlugins {
metrics.UnschedulableReason(plugin, pInfo.Pod.Spec.SchedulerName).Inc() metrics.UnschedulableReason(plugin, pInfo.Pod.Spec.SchedulerName).Inc()
} }
@ -794,7 +794,7 @@ func (p *PriorityQueue) AddUnschedulableIfNotPresent(logger klog.Logger, pInfo *
// In this case, we try to requeue this Pod to activeQ/backoffQ. // In this case, we try to requeue this Pod to activeQ/backoffQ.
queue := p.requeuePodViaQueueingHint(logger, pInfo, schedulingHint, ScheduleAttemptFailure) queue := p.requeuePodViaQueueingHint(logger, pInfo, schedulingHint, ScheduleAttemptFailure)
logger.V(3).Info("Pod moved to an internal scheduling queue", "pod", klog.KObj(pod), "event", ScheduleAttemptFailure, "queue", queue, "schedulingCycle", podSchedulingCycle, "hint", schedulingHint, "unschedulable plugins", failedPlugins) logger.V(3).Info("Pod moved to an internal scheduling queue", "pod", klog.KObj(pod), "event", ScheduleAttemptFailure, "queue", queue, "schedulingCycle", podSchedulingCycle, "hint", schedulingHint, "unschedulable plugins", rejectorPlugins)
if queue == activeQ { if queue == activeQ {
// When the Pod is moved to activeQ, need to let p.cond know so that the Pod will be pop()ed out. // When the Pod is moved to activeQ, need to let p.cond know so that the Pod will be pop()ed out.
p.cond.Broadcast() p.cond.Broadcast()

View File

@ -206,7 +206,7 @@ func (sched *Scheduler) schedulingCycle(
logger.Error(forgetErr, "Scheduler cache ForgetPod failed") logger.Error(forgetErr, "Scheduler cache ForgetPod failed")
} }
if sts.IsUnschedulable() { if sts.IsRejected() {
fitErr := &framework.FitError{ fitErr := &framework.FitError{
NumAllNodes: 1, NumAllNodes: 1,
Pod: pod, Pod: pod,
@ -229,7 +229,7 @@ func (sched *Scheduler) schedulingCycle(
logger.Error(forgetErr, "Scheduler cache ForgetPod failed") logger.Error(forgetErr, "Scheduler cache ForgetPod failed")
} }
if runPermitStatus.IsUnschedulable() { if runPermitStatus.IsRejected() {
fitErr := &framework.FitError{ fitErr := &framework.FitError{
NumAllNodes: 1, NumAllNodes: 1,
Pod: pod, Pod: pod,
@ -269,13 +269,13 @@ func (sched *Scheduler) bindingCycle(
// Run "permit" plugins. // Run "permit" plugins.
if status := fwk.WaitOnPermit(ctx, assumedPod); !status.IsSuccess() { if status := fwk.WaitOnPermit(ctx, assumedPod); !status.IsSuccess() {
if status.IsUnschedulable() { if status.IsRejected() {
fitErr := &framework.FitError{ fitErr := &framework.FitError{
NumAllNodes: 1, NumAllNodes: 1,
Pod: assumedPodInfo.Pod, Pod: assumedPodInfo.Pod,
Diagnosis: framework.Diagnosis{ Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{scheduleResult.SuggestedHost: status}, NodeToStatusMap: framework.NodeToStatusMap{scheduleResult.SuggestedHost: status},
UnschedulablePlugins: sets.New(status.FailedPlugin()), UnschedulablePlugins: sets.New(status.Plugin()),
}, },
} }
return framework.NewStatus(status.Code()).WithError(fitErr) return framework.NewStatus(status.Code()).WithError(fitErr)
@ -336,7 +336,7 @@ func (sched *Scheduler) handleBindingCycleError(
// Avoid moving the assumed Pod itself as it's always Unschedulable. // Avoid moving the assumed Pod itself as it's always Unschedulable.
// It's intentional to "defer" this operation; otherwise MoveAllToActiveOrBackoffQueue() would // It's intentional to "defer" this operation; otherwise MoveAllToActiveOrBackoffQueue() would
// update `q.moveRequest` and thus move the assumed pod to backoffQ anyways. // update `q.moveRequest` and thus move the assumed pod to backoffQ anyways.
if status.IsUnschedulable() { if status.IsRejected() {
defer sched.SchedulingQueue.MoveAllToActiveOrBackoffQueue(logger, internalqueue.AssignedPodDelete, assumedPod, nil, func(pod *v1.Pod) bool { defer sched.SchedulingQueue.MoveAllToActiveOrBackoffQueue(logger, internalqueue.AssignedPodDelete, assumedPod, nil, func(pod *v1.Pod) bool {
return assumedPod.UID != pod.UID return assumedPod.UID != pod.UID
}) })
@ -445,7 +445,7 @@ func (sched *Scheduler) findNodesThatFitPod(ctx context.Context, fwk framework.F
// Run "prefilter" plugins. // Run "prefilter" plugins.
preRes, s := fwk.RunPreFilterPlugins(ctx, state, pod) preRes, s := fwk.RunPreFilterPlugins(ctx, state, pod)
if !s.IsSuccess() { if !s.IsSuccess() {
if !s.IsUnschedulable() { if !s.IsRejected() {
return nil, diagnosis, s.AsError() return nil, diagnosis, s.AsError()
} }
// All nodes in NodeToStatusMap will have the same status so that they can be handled in the preemption. // All nodes in NodeToStatusMap will have the same status so that they can be handled in the preemption.
@ -959,7 +959,7 @@ func (sched *Scheduler) handleSchedulingFailure(ctx context.Context, fwk framewo
logger := klog.FromContext(ctx) logger := klog.FromContext(ctx)
reason := v1.PodReasonSchedulerError reason := v1.PodReasonSchedulerError
if status.IsUnschedulable() { if status.IsRejected() {
reason = v1.PodReasonUnschedulable reason = v1.PodReasonUnschedulable
} }

View File

@ -913,7 +913,7 @@ func TestSchedulerNoPhantomPodAfterDelete(t *testing.T) {
NumAllNodes: 1, NumAllNodes: 1,
Diagnosis: framework.Diagnosis{ Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{ NodeToStatusMap: framework.NodeToStatusMap{
node.Name: framework.NewStatus(framework.Unschedulable, nodeports.ErrReason).WithFailedPlugin(nodeports.Name), node.Name: framework.NewStatus(framework.Unschedulable, nodeports.ErrReason).WithPlugin(nodeports.Name),
}, },
UnschedulablePlugins: sets.New(nodeports.Name), UnschedulablePlugins: sets.New(nodeports.Name),
}, },
@ -1002,7 +1002,7 @@ func TestSchedulerFailedSchedulingReasons(t *testing.T) {
framework.Unschedulable, framework.Unschedulable,
fmt.Sprintf("Insufficient %v", v1.ResourceCPU), fmt.Sprintf("Insufficient %v", v1.ResourceCPU),
fmt.Sprintf("Insufficient %v", v1.ResourceMemory), fmt.Sprintf("Insufficient %v", v1.ResourceMemory),
).WithFailedPlugin(noderesources.Name) ).WithPlugin(noderesources.Name)
} }
fns := []tf.RegisterPluginFunc{ fns := []tf.RegisterPluginFunc{
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New), tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
@ -1793,8 +1793,8 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 2, NumAllNodes: 2,
Diagnosis: framework.Diagnosis{ Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{ NodeToStatusMap: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("FalseFilter"), "node1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
"node2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("FalseFilter"), "node2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
}, },
UnschedulablePlugins: sets.New("FalseFilter"), UnschedulablePlugins: sets.New("FalseFilter"),
}, },
@ -1881,9 +1881,9 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 3, NumAllNodes: 3,
Diagnosis: framework.Diagnosis{ Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{ NodeToStatusMap: framework.NodeToStatusMap{
"3": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("FalseFilter"), "3": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
"2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("FalseFilter"), "2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
"1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("FalseFilter"), "1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
}, },
UnschedulablePlugins: sets.New("FalseFilter"), UnschedulablePlugins: sets.New("FalseFilter"),
}, },
@ -1908,8 +1908,8 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 2, NumAllNodes: 2,
Diagnosis: framework.Diagnosis{ Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{ NodeToStatusMap: framework.NodeToStatusMap{
"1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("MatchFilter"), "1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("MatchFilter"),
"2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("NoPodsFilter"), "2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("NoPodsFilter"),
}, },
UnschedulablePlugins: sets.New("MatchFilter", "NoPodsFilter"), UnschedulablePlugins: sets.New("MatchFilter", "NoPodsFilter"),
}, },
@ -1951,8 +1951,8 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 2, NumAllNodes: 2,
Diagnosis: framework.Diagnosis{ Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{ NodeToStatusMap: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.UnschedulableAndUnresolvable, `persistentvolumeclaim "unknownPVC" not found`).WithFailedPlugin("VolumeBinding"), "node1": framework.NewStatus(framework.UnschedulableAndUnresolvable, `persistentvolumeclaim "unknownPVC" not found`).WithPlugin("VolumeBinding"),
"node2": framework.NewStatus(framework.UnschedulableAndUnresolvable, `persistentvolumeclaim "unknownPVC" not found`).WithFailedPlugin("VolumeBinding"), "node2": framework.NewStatus(framework.UnschedulableAndUnresolvable, `persistentvolumeclaim "unknownPVC" not found`).WithPlugin("VolumeBinding"),
}, },
PreFilterMsg: `persistentvolumeclaim "unknownPVC" not found`, PreFilterMsg: `persistentvolumeclaim "unknownPVC" not found`,
UnschedulablePlugins: sets.New(volumebinding.Name), UnschedulablePlugins: sets.New(volumebinding.Name),
@ -1976,8 +1976,8 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 2, NumAllNodes: 2,
Diagnosis: framework.Diagnosis{ Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{ NodeToStatusMap: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.UnschedulableAndUnresolvable, `persistentvolumeclaim "existingPVC" is being deleted`).WithFailedPlugin("VolumeBinding"), "node1": framework.NewStatus(framework.UnschedulableAndUnresolvable, `persistentvolumeclaim "existingPVC" is being deleted`).WithPlugin("VolumeBinding"),
"node2": framework.NewStatus(framework.UnschedulableAndUnresolvable, `persistentvolumeclaim "existingPVC" is being deleted`).WithFailedPlugin("VolumeBinding"), "node2": framework.NewStatus(framework.UnschedulableAndUnresolvable, `persistentvolumeclaim "existingPVC" is being deleted`).WithPlugin("VolumeBinding"),
}, },
PreFilterMsg: `persistentvolumeclaim "existingPVC" is being deleted`, PreFilterMsg: `persistentvolumeclaim "existingPVC" is being deleted`,
UnschedulablePlugins: sets.New(volumebinding.Name), UnschedulablePlugins: sets.New(volumebinding.Name),
@ -2072,7 +2072,7 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 1, NumAllNodes: 1,
Diagnosis: framework.Diagnosis{ Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{ NodeToStatusMap: framework.NodeToStatusMap{
"3": framework.NewStatus(framework.Unschedulable, "injecting failure for pod test-filter").WithFailedPlugin("FakeFilter"), "3": framework.NewStatus(framework.Unschedulable, "injecting failure for pod test-filter").WithPlugin("FakeFilter"),
}, },
UnschedulablePlugins: sets.New("FakeFilter"), UnschedulablePlugins: sets.New("FakeFilter"),
}, },
@ -2097,7 +2097,7 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 1, NumAllNodes: 1,
Diagnosis: framework.Diagnosis{ Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{ NodeToStatusMap: framework.NodeToStatusMap{
"3": framework.NewStatus(framework.UnschedulableAndUnresolvable, "injecting failure for pod test-filter").WithFailedPlugin("FakeFilter"), "3": framework.NewStatus(framework.UnschedulableAndUnresolvable, "injecting failure for pod test-filter").WithPlugin("FakeFilter"),
}, },
UnschedulablePlugins: sets.New("FakeFilter"), UnschedulablePlugins: sets.New("FakeFilter"),
}, },
@ -2137,8 +2137,8 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 2, NumAllNodes: 2,
Diagnosis: framework.Diagnosis{ Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{ NodeToStatusMap: framework.NodeToStatusMap{
"1": framework.NewStatus(framework.UnschedulableAndUnresolvable, "injected unschedulable status").WithFailedPlugin("FakePreFilter"), "1": framework.NewStatus(framework.UnschedulableAndUnresolvable, "injected unschedulable status").WithPlugin("FakePreFilter"),
"2": framework.NewStatus(framework.UnschedulableAndUnresolvable, "injected unschedulable status").WithFailedPlugin("FakePreFilter"), "2": framework.NewStatus(framework.UnschedulableAndUnresolvable, "injected unschedulable status").WithPlugin("FakePreFilter"),
}, },
PreFilterMsg: "injected unschedulable status", PreFilterMsg: "injected unschedulable status",
UnschedulablePlugins: sets.New("FakePreFilter"), UnschedulablePlugins: sets.New("FakePreFilter"),
@ -2401,9 +2401,9 @@ func TestFindFitAllError(t *testing.T) {
expected := framework.Diagnosis{ expected := framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{ NodeToStatusMap: framework.NodeToStatusMap{
"1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("MatchFilter"), "1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("MatchFilter"),
"2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("MatchFilter"), "2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("MatchFilter"),
"3": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("MatchFilter"), "3": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("MatchFilter"),
}, },
UnschedulablePlugins: sets.New("MatchFilter"), UnschedulablePlugins: sets.New("MatchFilter"),
} }

View File

@ -223,7 +223,7 @@ func (f *FakeExtender) selectVictimsOnNodeByExtender(pod *v1.Pod, node *v1.Node)
err := f.runPredicate(pod, node) err := f.runPredicate(pod, node)
if err.IsSuccess() { if err.IsSuccess() {
return []*v1.Pod{}, 0, true, nil return []*v1.Pod{}, 0, true, nil
} else if err.IsUnschedulable() { } else if err.IsRejected() {
return nil, 0, false, nil return nil, 0, false, nil
} else { } else {
return nil, 0, false, err.AsError() return nil, 0, false, err.AsError()
@ -258,7 +258,7 @@ func (f *FakeExtender) selectVictimsOnNodeByExtender(pod *v1.Pod, node *v1.Node)
status := f.runPredicate(pod, nodeInfoCopy.Node()) status := f.runPredicate(pod, nodeInfoCopy.Node())
if status.IsSuccess() { if status.IsSuccess() {
// pass // pass
} else if status.IsUnschedulable() { } else if status.IsRejected() {
// does not fit // does not fit
return nil, 0, false, nil return nil, 0, false, nil
} else { } else {