framework

package
v1.11.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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
	// Nooperation is used when a plugin is disabled or the plugin list are empty
	Noopperation
	// Error is used for internal plugin errors, unexpected input, etc.
	Error
)

These are predefined codes used in a Status.

func (Code) String

func (c Code) String() string

type EstimateReplicasPlugin

type EstimateReplicasPlugin interface {
	Plugin
	// Estimate is called for each MaxAvailableReplicas request.
	// It returns an integer and an error
	// The integer representing the number of calculated replica for the given replicaRequirements
	// The Result contains code, reasons and error
	// it is merged from all plugins returned result codes
	Estimate(ctx context.Context, snapshot *schedcache.Snapshot, replicaRequirements *pb.ReplicaRequirements) (int32, *Result)
}

EstimateReplicasPlugin is an interface for replica estimation plugins. These estimators are used to estimate the replicas for a given pb.ReplicaRequirements

type Framework

type Framework interface {
	Handle
	// RunEstimateReplicasPlugins runs the set of configured EstimateReplicasPlugins
	// for estimating replicas based on the given replicaRequirements.
	// It returns an integer and an Result.
	// The integer represents the minimum calculated value of estimated replicas from each EstimateReplicasPlugin.
	// The Result contains code, reasons and error
	// it is merged from all plugins returned result codes
	RunEstimateReplicasPlugins(ctx context.Context, snapshot *schedcache.Snapshot, replicaRequirements *pb.ReplicaRequirements) (int32, *Result)
}

Framework manages the set of plugins in use by the estimator.

type Handle

type Handle interface {
	ClientSet() clientset.Interface
	SharedInformerFactory() informers.SharedInformerFactory
}

Handle provides data and some tools that plugins can use. It is passed to the plugin factories at the time of plugin initialization. Plugins must store and use this handle to call framework functions. We follow the design pattern as kubernetes scheduler framework

type Plugin

type Plugin interface {
	Name() string
}

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

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, Disabled.

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

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

func (s *Result) Code() Code

Code returns code of the Result.

func (*Result) IsNoOperation

func (s *Result) IsNoOperation() bool

IsNoOperation return true if "Result" is not nil and Code is "Nooperation" ToDo (wengyao04): we can remove it once we include node resource estimation as the default plugin in the future

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

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

Reasons returns reasons of the Result.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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