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

Code before:
	}

	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 were preempted to make room for the preemptor pod.
	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.
type QueueSortPlugin interface {
	Plugin
	// Less are used to sort pods in the scheduling queue.
	Less(QueuedPodInfo, QueuedPodInfo) bool
}


Review comment (bug):
We need to remember that victims identified by previously considered gang pods accumulate. I think we should clarify here whether the victims that were already considered for removal should be listed here or skipped.

If we skip them, we assume that previously identified victims will be "executed" before this one is considered. This assumption sounds true for processing within the workload scheduling cycle, so as long as we "execute" and enforce the preemption at the end of this cycle we should not have problems.

If we ever think about skipping some of the gang scheduled pods in the pod-by-pod scheduling WaitOnPermit gate (as long as minCount is still satisfied), we might want to remember which pods really need to be preempted for this particular preemptor, so that we don't preempt other unnecessarily. It however would get quite complicated, so I'd take it out-of-scope and for now assume the previously identified victims are not listed here.

Code after:
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.
// 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.