manager

package
v0.0.0-...-cdf4838 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllocatorPolicyBinPack = "binpack"
	AllocatorPolicySpread  = "spread"

	BoardIDNotFount = -1
)
View Source
const DefaultOrinStartBit = 1

Variables

Functions

func AddPodBindAnnotation

func AddPodBindAnnotation(oldPod *v1.Pod, boardID int) *v1.Pod

GetUpdatedPodAnnotationSpec updates pod annotation with devId

func BoardIDFromResourceName

func BoardIDFromResourceName(name string) (int64, error)

func BuildDecimalMap

func BuildDecimalMap(set sets.Int, startBit int) int64

func BuildRequestOrinSet

func BuildRequestOrinSet(pod *v1.Pod) sets.Int

func IsBindingBoard

func IsBindingBoard(pod *v1.Pod) bool

func IsCompletedPod

func IsCompletedPod(pod *v1.Pod) bool

func IsOrinPod

func IsOrinPod(pod *v1.Pod) bool

func IsResourceExists

func IsResourceExists(pod *v1.Pod, resourceName string) bool

func NewManager

func NewManager(c Cache, clientSet kubernetes.Interface) *manager

func NewScheduleCache

func NewScheduleCache() *scheduleCache

func Normalize

func Normalize(maxPriority int, scores []int)

func OrinIDFromResourceName

func OrinIDFromResourceName(name string) (int64, error)

func Parallelize

func Parallelize(workers, pieces int, doWorkPiece func(i int))

func RemovePodBindAnnotation

func RemovePodBindAnnotation(oldPod *v1.Pod) *v1.Pod

Types

type Allocator

type Allocator interface {
	Allocate(canAlloc topo.BoardDetails, orinRequest sets.Int) *AllocatorResult
}

type AllocatorResult

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

type BinpackAllocator

type BinpackAllocator struct{}

func (*BinpackAllocator) Allocate

func (ba *BinpackAllocator) Allocate(canAlloc topo.BoardDetails, orinRequest sets.Int) *AllocatorResult

type Cache

type Cache interface {
	// pod cache will be updated by two way, one is Bind() method, the other is
	// pod informer call back handler
	// AddPod add a pod to cache which we focus on
	AddPod(pod *v1.Pod) error
	// DeletePod add a pod to cache which we focus on
	DeletePod(pod *v1.Pod) error

	KnownPod(pod *v1.Pod) bool
	// node cache will be updated by node informer call back handler
	// AddNode add a node to cache
	AddNode(node *v1.Node, pods ...*v1.Pod) error
	// UpdateNode update a node in cache, when device-plugin check orin device offline
	// it will be update board and orin extend resources
	GetNode(name string) *NodeInfo
	UpdateNode(oldNode *v1.Node, newNode *v1.Node, pods ...*v1.Pod) error
	// DeleteNode delete a node to cache
	DeleteNode(node *v1.Node) error
	// AssumePod will add pod to tmp cache
	AssumePod(pod *v1.Pod, node string) error
	// ForgetPod will clear assume cache, like bind error
	ForgetPod(pod *v1.Pod, node string) error
}

type Controller

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

func NewController

func NewController(clientset kubernetes.Interface, manager Manager, stopCh <-chan struct{}) (c *Controller, err error)

func (*Controller) Run

func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error

Run will set up the event handlers

type DecimalMap

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

func NewDecimalMap

func NewDecimalMap(src int64, startBit int) *DecimalMap

func (*DecimalMap) Parse

func (dm *DecimalMap) Parse() (sets.Int, error)

type Manager

type Manager interface {
	// Predicate check node if has sufficent device resource to allocate
	Predicate(nodes []string, pod *v1.Pod) ([]string, map[string]string, error)
	// Priority score node for place current pod device resource request
	Priority(node []string, pod *v1.Pod) []int
	// Bind will update pod annotaion and update local cache
	Bind(node string, name, namespace string, podUID types.UID) error
	// GetPodFromApiserver use clientset to get newest pod info, instead localcache
	GetPodFromApiserver(podName, podNamespace string, podUID types.UID) (*v1.Pod, error)
	Cache
}

type Map

type Map interface {
	Parse() (sets.Int, error)
}

type NodeInfo

type NodeInfo struct {
	// Overall node information.
	Node *v1.Node

	// Pods running on the node.
	Pods map[types.UID]*v1.Pod

	// Requested is orin device num
	Allocatable topo.BoardDetails
	Requested   topo.BoardDetails
	Total       topo.BoardDetails
}

func NewNodeInfo

func NewNodeInfo(node *v1.Node, pods ...*v1.Pod) *NodeInfo

type SpreadAllocator

type SpreadAllocator struct{}

func (*SpreadAllocator) Allocate

func (sa *SpreadAllocator) Allocate(canAlloc topo.BoardDetails, orinRequest sets.Int) *AllocatorResult

TODO implement

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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