Repository: kubernetes/kubernetes
File: staging/src/k8s.io/kube-scheduler/framework/interface.go (Go)

Code before:

func (p *PreFilterResult) Merge(in *PreFilterResult) *PreFilterResult {
	if p.AllNodes() && in.AllNodes() {
		return nil
	}

	r := PreFilterResult{}
	if p.AllNodes() {
		r.NodeNames = in.NodeNames.Clone()
		return &r
	}
	if in.AllNodes() {
		r.NodeNames = p.NodeNames.Clone()
		return &r
	}

	r.NodeNames = p.NodeNames.Intersection(in.NodeNames)
	return &r
}

// PostFilterResult wraps needed info for scheduler framework to act upon PostFilter phase.
type PostFilterResult struct {
	*NominatingInfo
	// Victims are the pods that need to be preempted to make room for the preemptor pod.
	// For a preemptor that is a member of a gang, this field skips the pods that were
	// identified as victims for other members of the gang.
	Victims []*v1.Pod
}

// Plugin is the parent type for all the scheduling framework plugins.
type Plugin interface {
	Name() string
}

// PreEnqueuePlugin is an interface that must be implemented by "PreEnqueue" plugins.
// These plugins are called prior to adding Pods to activeQ or backoffQ.
// Note: an preEnqueue plugin is expected to be lightweight and efficient, so it's not expected to
// involve expensive calls like accessing external endpoints; otherwise it'd block other
// Pods' enqueuing in event handlers.
type PreEnqueuePlugin interface {
	Plugin
	// PreEnqueue is called prior to adding Pods to activeQ or backoffQ.
	PreEnqueue(ctx context.Context, p *v1.Pod) *Status
}

// LessFunc is the function to sort pod info
type LessFunc func(podInfo1, podInfo2 QueuedPodInfo) bool

// QueueSortPlugin is an interface that must be implemented by "QueueSort" plugins.
// These plugins are used to sort pods in the scheduling queue. Only one queue sort
// plugin may be enabled at a time.

Review comment (suggestion):
```suggestion
	// Victims are the pods that need to be preempted to make room for the preemptor pod.
	// For a preemptor that is a member of a pod group, this field skips the pods that were
	// identified as victims for other members of the pod group.
```

Code after:
func (p *PreFilterResult) AllNodes() bool {
	return p == nil || p.NodeNames == nil
}

func (p *PreFilterResult) Merge(in *PreFilterResult) *PreFilterResult {
	if p.AllNodes() && in.AllNodes() {
		return nil
	}

	r := PreFilterResult{}
	if p.AllNodes() {
		r.NodeNames = in.NodeNames.Clone()
		return &r
	}
	if in.AllNodes() {
		r.NodeNames = p.NodeNames.Clone()
		return &r
	}

	r.NodeNames = p.NodeNames.Intersection(in.NodeNames)
	return &r
}

// PostFilterResult wraps needed info for scheduler framework to act upon PostFilter phase.
type PostFilterResult struct {
	*NominatingInfo
	// Victims are the pods that need to be preempted to make room for the preemptor pod.
	// For a preemptor that is a member of a pod group, this field skips the pods that were
	// identified as victims for other members of the pod group.
	Victims []*v1.Pod
}

// PreBindPreFlightResult wraps needed info for scheduler framework to act upon PreBindPreFlight phase.
type PreBindPreFlightResult struct {
	// AllowParallel indicates whether this plugin's PreBind method can be run
	// in parallel with other plugins during PreBind phase.
	// The scheduler groups consecutive plugins that return AllowParallel: true
	// and runs them in parallel.
	// A plugin that returns AllowParallel: false breaks the parallel group
	// and runs sequentially.
	// Note: skipped plugins are effectively ignored, but if a skipped plugin returns
	// AllowParallel: false, it still breaks the parallel group of adjacent plugins.
	AllowParallel bool
}

// Plugin is the parent type for all the scheduling framework plugins.
type Plugin interface {
	Name() string
}

// PreEnqueuePlugin is an interface that must be implemented by "PreEnqueue" plugins.