Repository: kubernetes/kubernetes
File: pkg/scheduler/framework/interface.go (Go)

Code before:
	HasFilterPlugins() bool

	// HasPostFilterPlugins returns true if at least one PostFilter plugin is defined.
	HasPostFilterPlugins() bool

	// HasScorePlugins returns true if at least one Score plugin is defined.
	HasScorePlugins() bool

	// ListPlugins returns a map of extension point name to list of configured Plugins.
	ListPlugins() *config.Plugins

	// PercentageOfNodesToScore returns percentageOfNodesToScore associated to a profile.
	PercentageOfNodesToScore() *int32

	// SetPodNominator sets the PodNominator
	SetPodNominator(nominator fwk.PodNominator)
	// SetPodActivator sets the PodActivator
	SetPodActivator(activator fwk.PodActivator)
	// SetAPICacher sets the APICacher
	SetAPICacher(apiCacher fwk.APICacher)

	// Close calls Close method of each plugin.
	Close() error
}

func NewPostFilterResult(nodeName string, pods []*v1.Pod) *fwk.PostFilterResult {
	return &fwk.PostFilterResult{
		NominatingInfo: &fwk.NominatingInfo{
			NominatedNodeName: nodeName,
			NominatingMode:    fwk.ModeOverride,
		},
		Victims: pods,
	}
}


Review comment (suggestion):
I don't think we can rename the framework function as out of tree plugins may still use it (unless we want to force them to adapt).

Shouldn't we add a new method instead to make the interface itself backward compatible (even though other plugins may not use it properly)?

Whatever we decide, the interface changes should be described in the KEP, so will comment there as well.

Code after:
	// whether or not to handle the given Pod. If a Bind plugin chooses to skip the
	// binding, it should return code=5("skip") status. Otherwise, it should return "Error"
	// or "Success". If none of the plugins handled binding, RunBindPlugins returns
	// code=5("skip") status.
	RunBindPlugins(ctx context.Context, state fwk.CycleState, pod *v1.Pod, nodeName string) *fwk.Status

	// HasFilterPlugins returns true if at least one Filter plugin is defined.
	HasFilterPlugins() bool

	// HasPostFilterPlugins returns true if at least one PostFilter plugin is defined.
	HasPostFilterPlugins() bool

	// HasScorePlugins returns true if at least one Score plugin is defined.
	HasScorePlugins() bool

	// ListPlugins returns a map of extension point name to list of configured Plugins.
	ListPlugins() *config.Plugins

	// PercentageOfNodesToScore returns percentageOfNodesToScore associated to a profile.
	PercentageOfNodesToScore() *int32

	// SetPodNominator sets the PodNominator
	SetPodNominator(nominator fwk.PodNominator)
	// SetPodActivator sets the PodActivator
	SetPodActivator(activator fwk.PodActivator)
	// SetAPICacher sets the APICacher
	SetAPICacher(apiCacher fwk.APICacher)

	// Close calls Close method of each plugin.
	Close() error
}

// NewPostFilterResult creates PostFilterResult with a provided nominated node
// and a list of victims (if any) that need to be preempted to make the pod schedulable.
func NewPostFilterResult(nodeName string, victims []*v1.Pod) *fwk.PostFilterResult {
	return &fwk.PostFilterResult{
		NominatingInfo: &fwk.NominatingInfo{
			NominatedNodeName: nodeName,
			NominatingMode:    fwk.ModeOverride,
		},
		Victims: victims,
	}
}

// Deprecated: use NewPostFilterResult instead, even if no victims were identified.
// Deprecated in Kubernetes 1.36 and will be removed in 1.38.
func NewPostFilterResultWithNominatedNode(nodeName string) *fwk.PostFilterResult {
	return NewPostFilterResult(nodeName, nil)
}