state

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PodFitsResources                   = "PodFitsResources"
	NoMaxResourceCount                 = "NoMaxResourceCount"
	EvenPodSpread                      = "EvenPodSpread"
	AvailabilityNodePriority           = "AvailabilityNodePriority"
	AvailabilityZonePriority           = "AvailabilityZonePriority"
	LowestOrdinalPriority              = "LowestOrdinalPriority"
	RemoveWithEvenPodSpreadPriority    = "RemoveWithEvenPodSpreadPriority"
	RemoveWithAvailabilityNodePriority = "RemoveWithAvailabilityNodePriority"
	RemoveWithAvailabilityZonePriority = "RemoveWithAvailabilityZonePriority"
	RemoveWithHighestOrdinalPriority   = "RemoveWithHighestOrdinalPriority"
)

Variables

This section is empty.

Functions

func GetVPod

func GetVPod(key types.NamespacedName, vpods []scheduler.VPod) scheduler.VPod

Get retrieves the VPod from the vpods lister for a given namespace and name.

func OrdinalFromPodName

func OrdinalFromPodName(podName string) int32

func PodNameFromOrdinal

func PodNameFromOrdinal(name string, ordinal int32) string

func SatisfyNodeAvailability

func SatisfyNodeAvailability(feasiblePods []int32, states *State) bool

func SatisfyZoneAvailability

func SatisfyZoneAvailability(feasiblePods []int32, states *State) bool

Types

type AvailabilityNodePriorityArgs

type AvailabilityNodePriorityArgs struct {
	MaxSkew int32
}

AvailabilityNodePriorityArgs holds arguments used to configure the AvailabilityNodePriority plugin.

type AvailabilityZonePriorityArgs

type AvailabilityZonePriorityArgs struct {
	MaxSkew int32
}

AvailabilityZonePriorityArgs holds arguments used to configure the AvailabilityZonePriority plugin.

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 pod schedulable.
	Success Code = iota
	// Unschedulable is used when a plugin finds a pod unschedulable due to not satisying the predicate.
	Unschedulable
	// Error is used for internal plugin errors, unexpected input, etc.
	Error
)

These are predefined codes used in a Status.

type EvenPodSpreadArgs

type EvenPodSpreadArgs struct {
	MaxSkew int32
}

EvenPodSpreadArgs holds arguments used to configure the EvenPodSpread plugin.

type FilterPlugin

type FilterPlugin interface {
	Plugin
	// Filter is called by the scheduler.
	// All FilterPlugins should return "Success" to declare that
	// the given pod fits the vreplica.
	Filter(ctx context.Context, args interface{}, state *State, key types.NamespacedName, podID int32) *Status
}

type NoMaxResourceCountArgs

type NoMaxResourceCountArgs struct {
	NumPartitions int
}

NoMaxResourceCountArgs holds arguments used to configure the NoMaxResourceCount plugin.

type Plugin

type Plugin interface {
	Name() string
}

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

type PluginToPodScores

type PluginToPodScores map[string]PodScoreList

PluginToPodScores declares a map from plugin name to its PodScoreList.

type PluginToStatus

type PluginToStatus map[string]*Status

PluginToStatus maps plugin name to status. Currently used to identify which Filter plugin returned which status.

func (PluginToStatus) Merge

func (p PluginToStatus) Merge() *Status

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

type PodScore

type PodScore struct {
	ID    int32
	Score uint64
}

type PodScoreList

type PodScoreList []PodScore

type ScoreExtensions

type ScoreExtensions interface {
	// NormalizeScore is called for all pod scores produced by the same plugin's "Score"
	// method. A successful run of NormalizeScore will update the scores list and return
	// a success status.
	NormalizeScore(ctx context.Context, state *State, scores PodScoreList) *Status
}

ScoreExtensions is an interface for Score extended functionality.

type ScorePlugin

type ScorePlugin interface {
	Plugin
	// Score is called by the scheduler.
	// All ScorePlugins should return "Success" unless the args are invalid.
	Score(ctx context.Context, args interface{}, state *State, feasiblePods []int32, key types.NamespacedName, podID int32) (uint64, *Status)

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

type State

type State struct {
	// free tracks the free capacity of each pod.
	FreeCap []int32

	// schedulable pods tracks the pods that aren't being evicted.
	SchedulablePods []int32

	// LastOrdinal is the ordinal index corresponding to the last statefulset replica
	// with placed vpods.
	LastOrdinal int32

	// Pod capacity.
	Capacity int32

	// Replicas is the (cached) number of statefulset replicas.
	Replicas int32

	// Number of available zones in cluster
	NumZones int32

	// Number of available nodes in cluster
	NumNodes int32

	// Scheduling policy type for placing vreplicas on pods
	SchedulerPolicy scheduler.SchedulerPolicyType

	// Scheduling policy plugin for placing vreplicas on pods
	SchedPolicy *scheduler.SchedulerPolicy

	// De-scheduling policy plugin for removing vreplicas from pods
	DeschedPolicy *scheduler.SchedulerPolicy

	// Mapping node names of nodes currently in cluster to their zone info
	NodeToZoneMap map[string]string

	StatefulSetName string

	PodLister corev1.PodNamespaceLister

	// Stores for each vpod, a map of podname to number of vreplicas placed on that pod currently
	PodSpread map[types.NamespacedName]map[string]int32

	// Stores for each vpod, a map of nodename to total number of vreplicas placed on all pods running on that node currently
	NodeSpread map[types.NamespacedName]map[string]int32

	// Stores for each vpod, a map of zonename to total number of vreplicas placed on all pods located in that zone currently
	ZoneSpread map[types.NamespacedName]map[string]int32
}

state provides information about the current scheduling of all vpods It is used by for the scheduler and the autoscaler

func (*State) Free

func (s *State) Free(ordinal int32) int32

Free safely returns the free capacity at the given ordinal

func (*State) FreeCapacity

func (s *State) FreeCapacity() int32

freeCapacity returns the number of vreplicas that can be used, up to the last ordinal

func (*State) GetPodInfo

func (s *State) GetPodInfo(podName string) (zoneName string, nodeName string, err error)

func (*State) SetFree

func (s *State) SetFree(ordinal int32, value int32)

SetFree safely sets the free capacity at the given ordinal

type StateAccessor

type StateAccessor interface {
	// State returns the current state (snapshot) about placed vpods
	// Take into account reserved vreplicas and update `reserved` to reflect
	// the current state.
	State(reserved map[types.NamespacedName]map[string]int32) (*State, error)
}

func NewStateBuilder

func NewStateBuilder(ctx context.Context, namespace, sfsname string, lister scheduler.VPodLister, podCapacity int32, schedulerPolicy scheduler.SchedulerPolicyType, schedPolicy *scheduler.SchedulerPolicy, deschedPolicy *scheduler.SchedulerPolicy, podlister corev1.PodNamespaceLister, nodeLister corev1.NodeLister) StateAccessor

NewStateBuilder returns a StateAccessor recreating the state from scratch each time it is requested

type Status

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

Status indicates the result of running a plugin.

func AsStatus

func AsStatus(err error) *Status

AsStatus wraps an error in a Status.

func NewStatus

func NewStatus(code Code, reasons ...string) *Status

NewStatus makes a Status out of the given arguments and returns its pointer.

func (*Status) AsError

func (s *Status) AsError() error

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

func (*Status) Code

func (s *Status) Code() Code

Code returns code of the Status.

func (*Status) IsError

func (s *Status) IsError() bool

IsError returns true if and only if "Status" is "Error".

func (*Status) IsSuccess

func (s *Status) IsSuccess() bool

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

func (*Status) IsUnschedulable

func (s *Status) IsUnschedulable() bool

IsUnschedulable returns true if "Status" is Unschedulable

func (*Status) Message

func (s *Status) Message() string

Message returns a concatenated message on reasons of the Status.

Jump to

Keyboard shortcuts

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