cleanup: rename failedPlugin to plugin in framework.Status

This commit is contained in:
Kensei Nakada 2023-10-25 12:01:07 +00:00
parent 2f270bd996
commit 27bb66fd7b
11 changed files with 115 additions and 115 deletions

View File

@ -110,7 +110,7 @@ const (
// - when a PreScore plugin returns Skip so that coupled Score plugin will be skipped.
Skip
// 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
// to provision the resource for the Pod.
@ -179,9 +179,9 @@ type Status struct {
code Code
reasons []string
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.
failedPlugin string
plugin string
}
func (s *Status) WithError(err error) *Status {
@ -205,21 +205,21 @@ func (s *Status) Message() string {
return strings.Join(s.Reasons(), ", ")
}
// SetFailedPlugin sets the given plugin name to s.failedPlugin.
func (s *Status) SetFailedPlugin(plugin string) {
s.failedPlugin = plugin
// SetPlugin sets the given plugin name to s.plugin.
func (s *Status) SetPlugin(plugin string) {
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.
func (s *Status) WithFailedPlugin(plugin string) *Status {
s.SetFailedPlugin(plugin)
func (s *Status) WithPlugin(plugin string) *Status {
s.SetPlugin(plugin)
return s
}
// FailedPlugin returns the failed plugin name.
func (s *Status) FailedPlugin() string {
return s.failedPlugin
// Plugin returns the plugin name which caused this status.
func (s *Status) Plugin() string {
return s.plugin
}
// Reasons returns reasons of the Status.
@ -250,10 +250,10 @@ func (s *Status) IsSkip() bool {
return s.Code() == Skip
}
// IsUnschedulable returns true if "Status" is Unschedulable (Unschedulable or UnschedulableAndUnresolvable).
func (s *Status) IsUnschedulable() bool {
// IsRejected returns true if "Status" is Unschedulable (Unschedulable, UnschedulableAndUnresolvable, or Pending).
func (s *Status) IsRejected() bool {
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
@ -283,7 +283,7 @@ func (s *Status) Equal(x *Status) bool {
if !cmp.Equal(s.reasons, x.reasons) {
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.

View File

@ -1773,7 +1773,7 @@ func TestPreempt(t *testing.T) {
Interface: &pl,
}
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())
}
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.
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())
}
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),
Diagnosis: framework.Diagnosis{
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.

View File

@ -654,11 +654,11 @@ func (f *frameworkImpl) RunPreFilterPlugins(ctx context.Context, state *framewor
continue
}
if !s.IsSuccess() {
s.SetFailedPlugin(pl.Name())
if s.IsUnschedulable() {
s.SetPlugin(pl.Name())
if s.IsRejected() {
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() {
pluginsWithNodes = append(pluginsWithNodes, pl.Name())
@ -795,12 +795,12 @@ func (f *frameworkImpl) RunFilterPlugins(
continue
}
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
// Success or Unschedulable.
status = framework.AsStatus(fmt.Errorf("running %q filter plugin: %w", pl.Name(), status.AsError()))
}
status.SetFailedPlugin(pl.Name())
status.SetPlugin(pl.Name())
return status
}
}
@ -836,7 +836,7 @@ func (f *frameworkImpl) RunPostFilterPlugins(ctx context.Context, state *framewo
// `result` records the last meaningful(non-noop) PostFilterResult.
var result *framework.PostFilterResult
var reasons []string
var failedPlugin string
var rejectorPlugin string
for _, pl := range f.postFilterPlugins {
logger := klog.LoggerWithName(logger, pl.Name())
ctx := klog.NewContext(ctx, logger)
@ -844,10 +844,10 @@ func (f *frameworkImpl) RunPostFilterPlugins(ctx context.Context, state *framewo
if s.IsSuccess() {
return r, s
} else if s.Code() == framework.UnschedulableAndUnresolvable {
return r, s.WithFailedPlugin(pl.Name())
} else if !s.IsUnschedulable() {
return r, s.WithPlugin(pl.Name())
} else if !s.IsRejected() {
// 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 {
result = r
}
@ -855,12 +855,12 @@ func (f *frameworkImpl) RunPostFilterPlugins(ctx context.Context, state *framewo
reasons = append(reasons, s.Reasons()...)
// Record the first failed plugin unless we proved that
// the latter is more relevant.
if len(failedPlugin) == 0 {
failedPlugin = pl.Name()
if len(rejectorPlugin) == 0 {
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) {
@ -922,7 +922,7 @@ func (f *frameworkImpl) RunFilterPluginsWithNominatedPods(ctx context.Context, s
}
status = f.RunFilterPlugins(ctx, stateToUse, pod, nodeInfoToUse)
if !status.IsSuccess() && !status.IsUnschedulable() {
if !status.IsSuccess() && !status.IsRejected() {
return status
}
}
@ -1151,9 +1151,9 @@ func (f *frameworkImpl) RunPreBindPlugins(ctx context.Context, state *framework.
ctx := klog.NewContext(ctx, logger)
status = f.runPreBindPlugin(ctx, pl, state, pod, nodeName)
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())
status.SetFailedPlugin(pl.Name())
status.SetPlugin(pl.Name())
return status
}
err := status.AsError()
@ -1197,9 +1197,9 @@ func (f *frameworkImpl) RunBindPlugins(ctx context.Context, state *framework.Cyc
continue
}
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())
status.SetFailedPlugin(pl.Name())
status.SetPlugin(pl.Name())
return status
}
err := status.AsError()
@ -1271,9 +1271,9 @@ func (f *frameworkImpl) RunReservePluginsReserve(ctx context.Context, state *fra
ctx := klog.NewContext(ctx, logger)
status = f.runReservePluginReserve(ctx, pl, state, pod, nodeName)
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())
status.SetFailedPlugin(pl.Name())
status.SetPlugin(pl.Name())
return status
}
err := status.AsError()
@ -1350,9 +1350,9 @@ func (f *frameworkImpl) RunPermitPlugins(ctx context.Context, state *framework.C
ctx := klog.NewContext(ctx, logger)
status, timeout := f.runPermitPlugin(ctx, pl, state, pod, nodeName)
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())
return status.WithFailedPlugin(pl.Name())
return status.WithPlugin(pl.Name())
}
if status.IsWait() {
// Not allowed to be greater than maxTimeout.
@ -1364,7 +1364,7 @@ func (f *frameworkImpl) RunPermitPlugins(ctx context.Context, state *framework.C
} else {
err := status.AsError()
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))
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())
return s
}
err := s.AsError()
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
}

View File

@ -72,7 +72,7 @@ var cmpOpts = []cmp.Option{
if s1 == nil || s2 == nil {
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)},
},
},
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",
@ -1803,7 +1803,7 @@ func TestFilterPlugins(t *testing.T) {
inj: injectedResult{FilterStatus: int(framework.Unschedulable)},
},
},
wantStatus: framework.NewStatus(framework.Unschedulable, injectFilterReason).WithFailedPlugin("TestPlugin"),
wantStatus: framework.NewStatus(framework.Unschedulable, injectFilterReason).WithPlugin("TestPlugin"),
},
{
name: "UnschedulableAndUnresolvableFilter",
@ -1814,7 +1814,7 @@ func TestFilterPlugins(t *testing.T) {
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
{
@ -1829,7 +1829,7 @@ func TestFilterPlugins(t *testing.T) {
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",
@ -1843,7 +1843,7 @@ func TestFilterPlugins(t *testing.T) {
inj: injectedResult{FilterStatus: int(framework.Unschedulable)},
},
},
wantStatus: framework.NewStatus(framework.Unschedulable, injectFilterReason).WithFailedPlugin("TestPlugin1"),
wantStatus: framework.NewStatus(framework.Unschedulable, injectFilterReason).WithPlugin("TestPlugin1"),
},
{
name: "UnschedulableAndUnschedulableAndUnresolvableFilters",
@ -1857,7 +1857,7 @@ func TestFilterPlugins(t *testing.T) {
inj: injectedResult{FilterStatus: int(framework.Unschedulable)},
},
},
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectFilterReason).WithFailedPlugin("TestPlugin1"),
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectFilterReason).WithPlugin("TestPlugin1"),
},
{
name: "SuccessAndSuccessFilters",
@ -1901,7 +1901,7 @@ func TestFilterPlugins(t *testing.T) {
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",
@ -1916,7 +1916,7 @@ func TestFilterPlugins(t *testing.T) {
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",
@ -1930,7 +1930,7 @@ func TestFilterPlugins(t *testing.T) {
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)},
},
},
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",
@ -2040,7 +2040,7 @@ func TestPostFilterPlugins(t *testing.T) {
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",
@ -2054,7 +2054,7 @@ func TestPostFilterPlugins(t *testing.T) {
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,
node: node,
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",
@ -2273,7 +2273,7 @@ func TestPreBindPlugins(t *testing.T) {
inj: injectedResult{PreBindStatus: int(framework.Unschedulable)},
},
},
wantStatus: framework.NewStatus(framework.Unschedulable, injectReason).WithFailedPlugin("TestPlugin"),
wantStatus: framework.NewStatus(framework.Unschedulable, injectReason).WithPlugin("TestPlugin"),
},
{
name: "ErrorPreBindPlugin",
@ -2293,7 +2293,7 @@ func TestPreBindPlugins(t *testing.T) {
inj: injectedResult{PreBindStatus: int(framework.UnschedulableAndUnresolvable)},
},
},
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithFailedPlugin("TestPlugin"),
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithPlugin("TestPlugin"),
},
{
name: "SuccessErrorPreBindPlugins",
@ -2363,7 +2363,7 @@ func TestPreBindPlugins(t *testing.T) {
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)},
},
},
wantStatus: framework.NewStatus(framework.Unschedulable, injectReason).WithFailedPlugin("TestPlugin"),
wantStatus: framework.NewStatus(framework.Unschedulable, injectReason).WithPlugin("TestPlugin"),
},
{
name: "ErrorReservePlugin",
@ -2451,7 +2451,7 @@ func TestReservePlugins(t *testing.T) {
inj: injectedResult{ReserveStatus: int(framework.UnschedulableAndUnresolvable)},
},
},
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithFailedPlugin("TestPlugin"),
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithPlugin("TestPlugin"),
},
{
name: "SuccessSuccessReservePlugins",
@ -2521,7 +2521,7 @@ func TestReservePlugins(t *testing.T) {
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)},
},
},
want: framework.NewStatus(framework.Unschedulable, injectReason).WithFailedPlugin("TestPlugin"),
want: framework.NewStatus(framework.Unschedulable, injectReason).WithPlugin("TestPlugin"),
},
{
name: "ErrorPermitPlugin",
@ -2599,7 +2599,7 @@ func TestPermitPlugins(t *testing.T) {
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",
@ -2609,7 +2609,7 @@ func TestPermitPlugins(t *testing.T) {
inj: injectedResult{PermitStatus: int(framework.UnschedulableAndUnresolvable)},
},
},
want: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithFailedPlugin("TestPlugin"),
want: framework.NewStatus(framework.UnschedulableAndUnresolvable, injectReason).WithPlugin("TestPlugin"),
},
{
name: "WaitPermitPlugin",
@ -2647,7 +2647,7 @@ func TestPermitPlugins(t *testing.T) {
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) {
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",

View File

@ -21,7 +21,7 @@ import (
"sync"
"time"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"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.
// If there is no receiver, it's a no-op (default case).
select {
case w.s <- framework.NewStatus(framework.Unschedulable, msg).WithFailedPlugin(pluginName):
case w.s <- framework.NewStatus(framework.Unschedulable, msg).WithPlugin(pluginName):
default:
}
}

View File

@ -305,20 +305,20 @@ const (
)
func (d *Diagnosis) AddPluginStatus(sts *Status) {
if sts.FailedPlugin() == "" {
if sts.Plugin() == "" {
return
}
if sts.IsUnschedulable() {
if sts.IsRejected() {
if d.UnschedulablePlugins == nil {
d.UnschedulablePlugins = sets.New[string]()
}
d.UnschedulablePlugins.Insert(sts.FailedPlugin())
d.UnschedulablePlugins.Insert(sts.Plugin())
}
if sts.Code() == Pending {
if d.PendingPlugins == nil {
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
// 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 {
failedPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins)
if failedPlugins.Len() == 0 {
rejectorPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins)
if rejectorPlugins.Len() == 0 {
logger.V(6).Info("Worth requeuing because no failed plugins", "pod", klog.KObj(pInfo.Pod))
return queueAfterBackoff
}
@ -446,8 +446,8 @@ func (p *PriorityQueue) isPodWorthRequeuing(logger klog.Logger, pInfo *framework
}
for _, hintfn := range hintfns {
if !failedPlugins.Has(hintfn.PluginName) {
// skip if it's not hintfn from failedPlugins.
if !rejectorPlugins.Has(hintfn.PluginName) {
// skip if it's not hintfn from rejectorPlugins.
continue
}
@ -671,8 +671,8 @@ func (p *PriorityQueue) determineSchedulingHintForInFlightPod(logger klog.Logger
return queueSkip
}
failedPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins)
if len(failedPlugins) == 0 {
rejectorPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins)
if len(rejectorPlugins) == 0 {
// 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.
// 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.
// 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
// it to unschedulablePods.
for plugin := range failedPlugins {
for plugin := range rejectorPlugins {
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:
// - 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.
@ -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
// it to unschedulablePods.
failedPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins)
for plugin := range failedPlugins {
rejectorPlugins := pInfo.UnschedulablePlugins.Union(pInfo.PendingPlugins)
for plugin := range rejectorPlugins {
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.
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 {
// 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()

View File

@ -206,7 +206,7 @@ func (sched *Scheduler) schedulingCycle(
logger.Error(forgetErr, "Scheduler cache ForgetPod failed")
}
if sts.IsUnschedulable() {
if sts.IsRejected() {
fitErr := &framework.FitError{
NumAllNodes: 1,
Pod: pod,
@ -229,7 +229,7 @@ func (sched *Scheduler) schedulingCycle(
logger.Error(forgetErr, "Scheduler cache ForgetPod failed")
}
if runPermitStatus.IsUnschedulable() {
if runPermitStatus.IsRejected() {
fitErr := &framework.FitError{
NumAllNodes: 1,
Pod: pod,
@ -269,13 +269,13 @@ func (sched *Scheduler) bindingCycle(
// Run "permit" plugins.
if status := fwk.WaitOnPermit(ctx, assumedPod); !status.IsSuccess() {
if status.IsUnschedulable() {
if status.IsRejected() {
fitErr := &framework.FitError{
NumAllNodes: 1,
Pod: assumedPodInfo.Pod,
Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{scheduleResult.SuggestedHost: status},
UnschedulablePlugins: sets.New(status.FailedPlugin()),
UnschedulablePlugins: sets.New(status.Plugin()),
},
}
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.
// It's intentional to "defer" this operation; otherwise MoveAllToActiveOrBackoffQueue() would
// 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 {
return assumedPod.UID != pod.UID
})
@ -445,7 +445,7 @@ func (sched *Scheduler) findNodesThatFitPod(ctx context.Context, fwk framework.F
// Run "prefilter" plugins.
preRes, s := fwk.RunPreFilterPlugins(ctx, state, pod)
if !s.IsSuccess() {
if !s.IsUnschedulable() {
if !s.IsRejected() {
return nil, diagnosis, s.AsError()
}
// 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)
reason := v1.PodReasonSchedulerError
if status.IsUnschedulable() {
if status.IsRejected() {
reason = v1.PodReasonUnschedulable
}

View File

@ -913,7 +913,7 @@ func TestSchedulerNoPhantomPodAfterDelete(t *testing.T) {
NumAllNodes: 1,
Diagnosis: framework.Diagnosis{
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),
},
@ -1002,7 +1002,7 @@ func TestSchedulerFailedSchedulingReasons(t *testing.T) {
framework.Unschedulable,
fmt.Sprintf("Insufficient %v", v1.ResourceCPU),
fmt.Sprintf("Insufficient %v", v1.ResourceMemory),
).WithFailedPlugin(noderesources.Name)
).WithPlugin(noderesources.Name)
}
fns := []tf.RegisterPluginFunc{
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
@ -1793,8 +1793,8 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 2,
Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("FalseFilter"),
"node2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("FalseFilter"),
"node1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
"node2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
},
UnschedulablePlugins: sets.New("FalseFilter"),
},
@ -1881,9 +1881,9 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 3,
Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{
"3": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("FalseFilter"),
"2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("FalseFilter"),
"1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("FalseFilter"),
"3": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
"2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
"1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("FalseFilter"),
},
UnschedulablePlugins: sets.New("FalseFilter"),
},
@ -1908,8 +1908,8 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 2,
Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{
"1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("MatchFilter"),
"2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("NoPodsFilter"),
"1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("MatchFilter"),
"2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("NoPodsFilter"),
},
UnschedulablePlugins: sets.New("MatchFilter", "NoPodsFilter"),
},
@ -1951,8 +1951,8 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 2,
Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.UnschedulableAndUnresolvable, `persistentvolumeclaim "unknownPVC" not found`).WithFailedPlugin("VolumeBinding"),
"node2": 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`).WithPlugin("VolumeBinding"),
},
PreFilterMsg: `persistentvolumeclaim "unknownPVC" not found`,
UnschedulablePlugins: sets.New(volumebinding.Name),
@ -1976,8 +1976,8 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 2,
Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.UnschedulableAndUnresolvable, `persistentvolumeclaim "existingPVC" is being deleted`).WithFailedPlugin("VolumeBinding"),
"node2": 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`).WithPlugin("VolumeBinding"),
},
PreFilterMsg: `persistentvolumeclaim "existingPVC" is being deleted`,
UnschedulablePlugins: sets.New(volumebinding.Name),
@ -2072,7 +2072,7 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 1,
Diagnosis: framework.Diagnosis{
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"),
},
@ -2097,7 +2097,7 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 1,
Diagnosis: framework.Diagnosis{
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"),
},
@ -2137,8 +2137,8 @@ func TestSchedulerSchedulePod(t *testing.T) {
NumAllNodes: 2,
Diagnosis: framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{
"1": framework.NewStatus(framework.UnschedulableAndUnresolvable, "injected unschedulable status").WithFailedPlugin("FakePreFilter"),
"2": 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").WithPlugin("FakePreFilter"),
},
PreFilterMsg: "injected unschedulable status",
UnschedulablePlugins: sets.New("FakePreFilter"),
@ -2401,9 +2401,9 @@ func TestFindFitAllError(t *testing.T) {
expected := framework.Diagnosis{
NodeToStatusMap: framework.NodeToStatusMap{
"1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("MatchFilter"),
"2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("MatchFilter"),
"3": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithFailedPlugin("MatchFilter"),
"1": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("MatchFilter"),
"2": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("MatchFilter"),
"3": framework.NewStatus(framework.Unschedulable, tf.ErrReasonFake).WithPlugin("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)
if err.IsSuccess() {
return []*v1.Pod{}, 0, true, nil
} else if err.IsUnschedulable() {
} else if err.IsRejected() {
return nil, 0, false, nil
} else {
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())
if status.IsSuccess() {
// pass
} else if status.IsUnschedulable() {
} else if status.IsRejected() {
// does not fit
return nil, 0, false, nil
} else {