utils

package
v0.0.0-...-3bd4b24 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBestEffortPod

func BuildBestEffortPod(namespace, name, nodeName string, p corev1.PodPhase, groupName string, labels map[string]string, selector map[string]string) *corev1.Pod

func BuildNode

func BuildNode(name string, alloc corev1.ResourceList, labels map[string]string) *corev1.Node

func BuildPod

func BuildPod(namespace, name, nodeName string, p corev1.PodPhase, req corev1.ResourceList,
	groupName string, labels map[string]string, selector map[string]string) *corev1.Pod

func BuildPodWithPVC

func BuildPodWithPVC(namespace, name, nodeName string, p corev1.PodPhase, req corev1.ResourceList, pvc *corev1.PersistentVolumeClaim,
	groupName string, labels map[string]string, selector map[string]string) *corev1.Pod

func BuildPodWithPriority

func BuildPodWithPriority(namespace, name, nodeName string, p corev1.PodPhase, req corev1.ResourceList, groupName string, labels map[string]string, selector map[string]string, priority *int32) *corev1.Pod

func BuildResourceList

func BuildResourceList(cpu string, memory string) corev1.ResourceList

func BuildResourceListWithGPU

func BuildResourceListWithGPU(cpu string, memory string, GPU string) corev1.ResourceList

func CalculateNumOfFeasibleNodesToFind

func CalculateNumOfFeasibleNodesToFind(numAllNodes int32) (numNodes int32)

CalculateNumOfFeasibleNodesToFind returns the number of feasible nodes to find based on server options. Once found, the scheduler stops its search for more feasible nodes.

func GetMinInt

func GetMinInt(values ...int) int

GetMinInt returns the minimal value from the input slice.

func GetNodeList

func GetNodeList(nodes map[string]*apis.NodeInfo, nodeList []string) []*apis.NodeInfo

GetNodeList returns the nodes denoted by nodeList from `nodes`.

func PrioritizeNodes

func PrioritizeNodes(task *apis.TaskInfo, nodes []*apis.NodeInfo, batchFn apis.BatchNodeOrderFn, mapFn apis.NodeOrderMapFn,
	reduceFn apis.NodeOrderReduceFn) map[float64][]*apis.NodeInfo

PrioritizeNodes returns a map whose key is node's score and value are corresponding nodes.

func SelectBestNode

func SelectBestNode(nodeScores map[float64][]*apis.NodeInfo) *apis.NodeInfo

SelectBestNode returns the best node whose score is the highest. It picks one node randomly if there are many nodes with same score.

func SortNodes

func SortNodes(nodeScores map[float64][]*apis.NodeInfo) []*apis.NodeInfo

SortNodes returns nodes by order of score.

func ValidateVictims

func ValidateVictims(preemptor *apis.TaskInfo, node *apis.NodeInfo, victims []*apis.TaskInfo) error

ValidateVictims returns an error if the resources of the victims can't satisfy the preemptor.

Types

type FakeBinder

type FakeBinder struct {
	Binds   map[string]string
	Channel chan string
}

FakeBinder is used as fake binder

func (*FakeBinder) Bind

func (fb *FakeBinder) Bind(kubeClient *kubernetes.Clientset, tasks []*apis.TaskInfo) ([]*apis.TaskInfo, error)

Bind binds each task to its allocated node.

type FakeEvictor

type FakeEvictor struct {
	sync.Mutex

	Channel chan string
	// contains filtered or unexported fields
}

FakeEvictor is used as fake evictor

func (*FakeEvictor) Evict

func (fe *FakeEvictor) Evict(pod *corev1.Pod, reason string) error

Evict adds p to FakeEvictor.evicts.

func (*FakeEvictor) Evicts

func (fe *FakeEvictor) Evicts() []string

type FakeStatusUpdater

type FakeStatusUpdater struct {
}

FakeStatusUpdater is used for fake status update

func (*FakeStatusUpdater) UpdatePodCondition

func (fsu *FakeStatusUpdater) UpdatePodCondition(pod *corev1.Pod, podCondition *corev1.PodCondition) (*corev1.Pod, error)

func (*FakeStatusUpdater) UpdatePodGroup

func (fsu *FakeStatusUpdater) UpdatePodGroup(pg *apis.PodGroup) (*apis.PodGroup, error)

type FakeVolumeBinder

type FakeVolumeBinder struct {
	Actions map[string][]string
	// contains filtered or unexported fields
}

FakeVolumeBinder is used as fake volume binder

func NewFakeVolumeBinder

func NewFakeVolumeBinder(kubeClient kubernetes.Interface) *FakeVolumeBinder

func (*FakeVolumeBinder) AllocateVolumes

func (fvb *FakeVolumeBinder) AllocateVolumes(task *apis.TaskInfo, hostname string, podVolumes *volumebinding.PodVolumes) error

func (*FakeVolumeBinder) BindVolumes

func (fvb *FakeVolumeBinder) BindVolumes(task *apis.TaskInfo, podVolumes *volumebinding.PodVolumes) error

func (*FakeVolumeBinder) GetPodVolumes

func (fvb *FakeVolumeBinder) GetPodVolumes(task *apis.TaskInfo, node *corev1.Node) (*volumebinding.PodVolumes, error)

func (*FakeVolumeBinder) RevertVolumes

func (fvb *FakeVolumeBinder) RevertVolumes(task *apis.TaskInfo, podVolumes *volumebinding.PodVolumes)

type PredicateHelper

type PredicateHelper interface {
	PredicateNodes(task *apis.TaskInfo, nodes []*apis.NodeInfo, fn apis.PredicateFn) ([]*apis.NodeInfo, *apis.FitErrors)
}

func NewPredicateHelper

func NewPredicateHelper() PredicateHelper

type PriorityQueue

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

func NewPriorityQueue

func NewPriorityQueue(lessFn apis.LessFn) *PriorityQueue

func (*PriorityQueue) Empty

func (q *PriorityQueue) Empty() bool

func (*PriorityQueue) Len

func (q *PriorityQueue) Len() int

func (*PriorityQueue) Pop

func (q *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (q *PriorityQueue) Push(it interface{})

type ResourceReservation

type ResourceReservation struct {
	TargetJob   *apis.JobInfo
	LockedNodes map[string]*apis.NodeInfo
}

ResourceReservation reserves resources in LockedNodes for TargetJob.

var Reservation *ResourceReservation

Reservation is used to record target job and locked nodes

func NewResourceReservation

func NewResourceReservation() *ResourceReservation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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