framework

package
v1.9.0-preview3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MinClusterScore is the minimum score a Score plugin is expected to return.
	MinClusterScore int64 = 0

	// MaxClusterScore is the maximum score a Score plugin is expected to return.
	MaxClusterScore int64 = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterInfo

type ClusterInfo struct {
	// contains filtered or unexported fields
}

ClusterInfo is cluster level aggregated information.

func NewClusterInfo

func NewClusterInfo(cluster *clusterv1alpha1.Cluster) *ClusterInfo

NewClusterInfo creates a ClusterInfo object.

func (*ClusterInfo) Cluster

func (n *ClusterInfo) Cluster() *clusterv1alpha1.Cluster

Cluster returns overall information about this cluster.

type ClusterScore

type ClusterScore struct {
	Cluster *clusterv1alpha1.Cluster
	Score   int64
}

ClusterScore represent the cluster score.

type ClusterScoreList

type ClusterScoreList []ClusterScore

ClusterScoreList declares a list of clusters and their scores.

type ClusterToResultMap added in v1.4.0

type ClusterToResultMap map[string]*Result

ClusterToResultMap declares map from cluster name to its Result.

type Code

type Code int

Code is the Status code/type which is returned from plugins.

const (
	// Success means that plugin ran correctly and found resource schedulable.
	// NOTE: A nil status is also considered as "Success".
	Success Code = iota
	// Unschedulable is used when a plugin finds the resource unschedulable.
	// The accompanying status message should explain why the it is unschedulable.
	Unschedulable
	// Error is used for internal plugin errors, unexpected input, etc.
	Error
)

These are predefined codes used in a Status.

func (Code) String added in v1.4.0

func (c Code) String() string

type Diagnosis added in v1.4.0

type Diagnosis struct {
	ClusterToResultMap ClusterToResultMap
}

Diagnosis records the details to diagnose a scheduling failure.

type FilterPlugin

type FilterPlugin interface {
	Plugin
	// Filter is called by the scheduling framework.
	Filter(ctx context.Context, bindingSpec *workv1alpha2.ResourceBindingSpec, bindingStatus *workv1alpha2.ResourceBindingStatus, cluster *clusterv1alpha1.Cluster) *Result
}

FilterPlugin is an interface for filter plugins. These filters are used to filter out clusters that are not fit for the resource.

type FitError added in v1.4.0

type FitError struct {
	NumAllClusters int
	Diagnosis      Diagnosis
}

FitError describes a fit error of a object.

func (*FitError) Error added in v1.4.0

func (f *FitError) Error() string

Error returns detailed information of why the object failed to fit on each cluster

type Framework

type Framework interface {

	// RunFilterPlugins runs the set of configured Filter plugins for resources on
	// the given cluster.
	RunFilterPlugins(ctx context.Context, bindingSpec *workv1alpha2.ResourceBindingSpec, bindingStatus *workv1alpha2.ResourceBindingStatus, cluster *clusterv1alpha1.Cluster) *Result

	// RunScorePlugins runs the set of configured Score plugins, it returns a map of plugin name to cores
	RunScorePlugins(ctx context.Context, spec *workv1alpha2.ResourceBindingSpec, clusters []*clusterv1alpha1.Cluster) (PluginToClusterScores, *Result)
}

Framework manages the set of plugins in use by the scheduling framework. Configured plugins are called at specified points in a scheduling context.

type Plugin

type Plugin interface {
	Name() string
}

Plugin is the parent type for all the scheduling framework plugins.

type PluginToClusterScores

type PluginToClusterScores map[string]ClusterScoreList

PluginToClusterScores declares a map from plugin name to its ClusterScoreList.

type PluginToResult

type PluginToResult map[string]*Result

PluginToResult maps plugin name to Result.

func (PluginToResult) Merge

func (p PluginToResult) Merge() *Result

Merge merges the statuses in the map into one. The resulting status code have the following precedence: Error, Unschedulable.

type Result

type Result struct {
	// contains filtered or unexported fields
}

Result indicates the result of running a plugin. It consists of a code, a message and (optionally) an error. When the status code is not `Success`, the reasons should explain why.

func AsResult added in v1.4.0

func AsResult(err error) *Result

AsResult wraps an error in a Result.

func NewResult

func NewResult(code Code, reasons ...string) *Result

NewResult makes a result out of the given arguments and returns its pointer.

func (*Result) AsError

func (s *Result) AsError() error

AsError returns nil if the Result is a success; otherwise returns an "error" object with a concatenated message on reasons of the Result.

func (*Result) Code added in v1.4.0

func (s *Result) Code() Code

Code returns code of the Result.

func (*Result) IsSuccess

func (s *Result) IsSuccess() bool

IsSuccess returns true if and only if "Result" is nil or Code is "Success".

func (*Result) Reasons added in v1.4.0

func (s *Result) Reasons() []string

Reasons returns reasons of the Result.

type ScoreExtensions added in v1.2.0

type ScoreExtensions interface {
	// NormalizeScore is called for all cluster scores produced
	// by the same plugin's "Score"
	NormalizeScore(ctx context.Context, scores ClusterScoreList) *Result
}

ScoreExtensions is an interface for Score extended functionality.

type ScorePlugin

type ScorePlugin interface {
	Plugin
	// Score is called on each filtered cluster. It must return success and an integer
	// indicating the rank of the cluster. All scoring plugins must return success or
	// the resource will be rejected.
	Score(ctx context.Context, spec *workv1alpha2.ResourceBindingSpec, cluster *clusterv1alpha1.Cluster) (int64, *Result)

	// ScoreExtensions returns a ScoreExtensions interface
	// if it implements one, or nil if does not.
	ScoreExtensions() ScoreExtensions
}

ScorePlugin is an interface that must be implemented by "Score" plugins to rank clusters that passed the filtering phase.

type UnschedulableError added in v1.7.0

type UnschedulableError struct {
	Message string
}

UnschedulableError describes a unschedulable error, for example due to insufficient resources.

func (*UnschedulableError) Error added in v1.7.0

func (u *UnschedulableError) Error() string

Directories

Path Synopsis
Package testing is a generated GoMock package.
Package testing is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL