Updated the scheduler framework's PreFilter interface to return a PreFilterResult
This commit is contained in:
@@ -30,6 +30,7 @@ import (
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/client-go/informers"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
@@ -337,8 +338,10 @@ type PreFilterExtensions interface {
|
||||
type PreFilterPlugin interface {
|
||||
Plugin
|
||||
// PreFilter is called at the beginning of the scheduling cycle. All PreFilter
|
||||
// plugins must return success or the pod will be rejected.
|
||||
PreFilter(ctx context.Context, state *CycleState, p *v1.Pod) *Status
|
||||
// plugins must return success or the pod will be rejected. PreFilter could optionally
|
||||
// return a PreFilterResult to influence which nodes to evaluate downstream. This is useful
|
||||
// for cases where it is possible to determine the subset of nodes to process in O(1) time.
|
||||
PreFilter(ctx context.Context, state *CycleState, p *v1.Pod) (*PreFilterResult, *Status)
|
||||
// PreFilterExtensions returns a PreFilterExtensions interface if the plugin implements one,
|
||||
// or nil if it does not. A Pre-filter plugin can provide extensions to incrementally
|
||||
// modify its pre-processed info. The framework guarantees that the extensions
|
||||
@@ -498,7 +501,9 @@ type Framework interface {
|
||||
// *Status and its code is set to non-success if any of the plugins returns
|
||||
// anything but Success. If a non-success status is returned, then the scheduling
|
||||
// cycle is aborted.
|
||||
RunPreFilterPlugins(ctx context.Context, state *CycleState, pod *v1.Pod) *Status
|
||||
// It also returns a PreFilterResult, which may influence what or how many nodes to
|
||||
// evaluate downstream.
|
||||
RunPreFilterPlugins(ctx context.Context, state *CycleState, pod *v1.Pod) (*PreFilterResult, *Status)
|
||||
|
||||
// RunPostFilterPlugins runs the set of configured PostFilter plugins.
|
||||
// PostFilter plugins can either be informational, in which case should be configured
|
||||
@@ -608,6 +613,36 @@ type Handle interface {
|
||||
Parallelizer() parallelize.Parallelizer
|
||||
}
|
||||
|
||||
// PreFilterResult wraps needed info for scheduler framework to act upon PreFilter phase.
|
||||
type PreFilterResult struct {
|
||||
// The set of nodes that should be considered downstream; if nil then
|
||||
// all nodes are eligible.
|
||||
NodeNames sets.String
|
||||
}
|
||||
|
||||
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 = sets.NewString(in.NodeNames.UnsortedList()...)
|
||||
return &r
|
||||
}
|
||||
if in.AllNodes() {
|
||||
r.NodeNames = sets.NewString(p.NodeNames.UnsortedList()...)
|
||||
return &r
|
||||
}
|
||||
|
||||
r.NodeNames = p.NodeNames.Intersection(in.NodeNames)
|
||||
return &r
|
||||
}
|
||||
|
||||
type NominatingMode int
|
||||
|
||||
const (
|
||||
|
Reference in New Issue
Block a user