scheduler

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Name of the scheduling plugin.
	Name = "PodSetPlanner"
)

Variables

View Source
var (
	// ErrNotFound is returned when a resource is not found.
	ErrNotFound = errors.New("not-found")

	// ErrNoPodSetFound returned when podset is not found.
	ErrNoPodSetFound = errors.New("no-podset-found")

	// ErrNoPlannersFound returned when no planners are present for pod.
	ErrNoPlannersFound = errors.New("no-planners")

	// ErrNilAssignmentState returned when a pod has a nil assignment.
	ErrNilAssignmentState = errors.New("nil-assignment-state")

	// ErrInvalidAssignmentState returned when the assignment is not of a
	// valid type.
	ErrInvalidAssignmentState = errors.New("invalid-assignment-state")

	// ErrBuildingPlan returned when there was an error trying to build schedule plan.
	ErrBuildingPlan = errors.New("plan-build-failure")

	// ErrPodNotAssignable returned when a pod cannot be scheduled to a node.
	ErrPodNotAssignable = errors.New("pod-cannot-be-assigned")
)

Functions

func New

func New(
	obj runtime.Object, handle framework.Handle) (framework.Plugin, error,
)

New create a new framework plugin intance. nolint:ireturn

Types

type Planner

type Planner struct {
	Service       v1.Service
	Namespace     string
	Podset        string
	ScheduledPod  string
	EligibleNodes []string
	Log           logr.Logger
	CallTimeout   time.Duration
	DialOptions   []grpc.DialOption
}

Planner is used to store info to lookup podset planner service.

func (*Planner) BuildSchedulePlan

func (p *Planner) BuildSchedulePlan(parentCtx context.Context) (map[string]string, error)

BuildSchedulePlan is used to build a podset assignment plan by talking to the podset planner service.

type PlannerList

type PlannerList []*Planner

PlannerList is a list of references to Planner.

func (PlannerList) Invoke

func (planners PlannerList) Invoke(parentCtx context.Context,
	trigger *plannerv1alpha1.ScheduleTrigger) (map[string]string, error)

Invoke is used to invoke all the podset planners.

type PlannerService

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

PlannerService is used to lookup a podset planner service.

func NewPlannerService

func NewPlannerService(clnt *client.SchedulePlannerClient, handle framework.Handle,
	log logr.Logger, callTimeout time.Duration,
) *PlannerService

NewPlannerService is used to create a new planner service for the podset.

func (*PlannerService) Delete

func (s *PlannerService) Delete(parentCtx context.Context,
	pod *v1.Pod,
	podset string,
	_ string,
) error

Delete is used to delete the assignment for the pod from the planspec.

func (*PlannerService) Lookup

func (s *PlannerService) Lookup(parentCtx context.Context,
	namespace, podset, scheduledPod string, eligibleNodes []string) (PlannerList, error,
)

Lookup is used to lookup a podset planner service.

func (*PlannerService) Update

func (s *PlannerService) Update(parentCtx context.Context, pod *v1.Pod,
	podset string,
	assignments map[string]string,
) error

Update is used to create or update the plan spec for the podset planner.

func (*PlannerService) UpdateAssignment

func (s *PlannerService) UpdateAssignment(parentCtx context.Context, pod *v1.Pod,
	podset string,
	nodeName string,
) error

UpdateAssignment is used to update plan spec with the pod and node assignment.

type PodSetPlanner

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

PodSetPlanner instance state for the the policy scheduling plugin.

func (*PodSetPlanner) Name

func (p *PodSetPlanner) Name() string

Name returns the name of the scheduler.

func (*PodSetPlanner) PostFilter

func (p *PodSetPlanner) PostFilter(ctx context.Context,
	state *framework.CycleState, pod *v1.Pod,
	filteredNodeStatusMap framework.NodeToStatusMap) (*framework.PostFilterResult, *framework.Status,
)

PostFilter is called when no node can be assigned to the pod.

func (*PodSetPlanner) PreFilter

func (p *PodSetPlanner) PreFilter(
	parentCtx context.Context,
	_ *framework.CycleState,
	pod *v1.Pod) *framework.Status

PreFilter pre-filters the pods to be placed.

func (*PodSetPlanner) PreFilterExtensions

func (p *PodSetPlanner) PreFilterExtensions() framework.PreFilterExtensions

PreFilterExtensions returns prefilter extensions, pod add and remove. nolint:ireturn

func (*PodSetPlanner) PreScore

func (p *PodSetPlanner) PreScore(
	parentCtx context.Context,
	state *framework.CycleState,
	pod *v1.Pod,
	nodes []*v1.Node) *framework.Status

PreScore uses the filtered node list and selects the node for the pod using the planner.

func (*PodSetPlanner) Reserve

func (p *PodSetPlanner) Reserve(parentCtx context.Context,
	state *framework.CycleState,
	pod *v1.Pod,
	nodeName string,
) *framework.Status

Reserve is called when the scheduler cache is updated with the nodename for the pod. We do planner assignment state validations for the pod.

func (*PodSetPlanner) Score

func (p *PodSetPlanner) Score(
	ctx context.Context,
	state *framework.CycleState,
	pod *v1.Pod, nodeName string) (int64, *framework.Status)

Score scores the eligible nodes.

func (*PodSetPlanner) ScoreExtensions

func (p *PodSetPlanner) ScoreExtensions() framework.ScoreExtensions

ScoreExtensions calcuates scores for the extensions. nolint:ireturn

func (*PodSetPlanner) Unreserve

func (p *PodSetPlanner) Unreserve(parentCtx context.Context, state *framework.CycleState,
	pod *v1.Pod,
	nodeName string,
)

Unreserve is called when reserved pod was rejected or on reserve error. We undo the assignment and update planner spec by removing the pod assignment.

type PodSetPlannerArgs

type PodSetPlannerArgs struct {
	// nolint:tagliatelle
	metav1.TypeMeta `json:",inline"`
	Debug           bool   `json:"debug,omitempty"`
	CallTimeout     string `json:"callTimeout,omitempty"`
	UpdatePeriod    string `json:"updatePeriod,omitempty"`
}

PodSetPlannerArgs defines the parameters for the scheduling plugin +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func (*PodSetPlannerArgs) DeepCopy

func (in *PodSetPlannerArgs) DeepCopy() *PodSetPlannerArgs

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSetPlannerArgs.

func (*PodSetPlannerArgs) DeepCopyInto

func (in *PodSetPlannerArgs) DeepCopyInto(out *PodSetPlannerArgs)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*PodSetPlannerArgs) DeepCopyObject

func (in *PodSetPlannerArgs) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type PodSetPlannerOptions

type PodSetPlannerOptions struct {
	Debug        bool
	CallTimeout  time.Duration
	UpdatePeriod time.Duration
}

PodSetPlannerOptions is a set of options used while initializing a podset scheduler.

func DefaultPodSetPlannerConfig

func DefaultPodSetPlannerConfig() *PodSetPlannerOptions

DefaultPodSetPlannerConfig returns the default options for podset scheduler.

Jump to

Keyboard shortcuts

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