nodedb

package
v0.3.84-rc-4d24856 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// MinPriority is the smallest possible priority class priority within the NodeDb.
	MinPriority int32 = evictedPriority
)

Variables

This section is empty.

Functions

func EncodeInt64 added in v0.3.71

func EncodeInt64(out []byte, val int64) []byte

EncodeInt64 returns the canonical byte representation of a int64 used within the nodeDb. The resulting []byte is such that for two int64 a and b, a.Cmp(b) = bytes.Compare(enc(a), enc(b)). The byte representation is appended to out, which is returned.

func EncodeQuantity added in v0.3.71

func EncodeQuantity(out []byte, val resource.Quantity) []byte

EncodeQuantity returns the canonical byte representation of a resource.Quantity used within the nodeDb. The resulting []byte is such that for two resource.Quantity a and b, a.Cmp(b) = bytes.Compare(enc(a), enc(b)). The byte representation is appended to out, which is returned.

func EncodeUint64 added in v0.3.71

func EncodeUint64(out []byte, val uint64) []byte

EncodeUint64 returns the canonical byte representation of a uint64 used within the nodeDb. The resulting []byte is such that for two uint64 a and b, a.Cmp(b) = bytes.Compare(enc(a), enc(b)). The byte representation is appended to out, which is returned.

func NodeIndexKey added in v0.3.71

func NodeIndexKey(out []byte, nodeTypeId uint64, resources []resource.Quantity) []byte

NodeIndexKey returns a []byte to be used as a key with the NodeIndex memdb index with layout

0 8 16 32 | nodeTypeId | resources[0] | resources[1] | ... |

where the numbers indicate number of bytes.

The key layout is such that an index ordered first by the nodeTypeId, then resources[0], and so on. The byte representation is appended to out, which is returned.

func NodeJobDiff

func NodeJobDiff(txnA, txnB *memdb.Txn) (map[string]*Node, map[string]*Node, error)

NodeJobDiff compares two snapshots of the NodeDb memdb and returns - a map from job ids of all preempted jobs to the node they used to be on - a map from job ids of all scheduled jobs to the node they were scheduled on that happened between the two snapshots.

func RoundedNodeIndexKeyFromResourceList added in v0.3.71

func RoundedNodeIndexKeyFromResourceList(out []byte, nodeTypeId uint64, resourceNames []string, resourceResolutionMillis []int64, rl schedulerobjects.ResourceList) []byte

RoundedNodeIndexKeyFromResourceList works like NodeIndexKey, except that prior to constructing a the key the i-th resource is rounded down to the closest multiple of resourceResolutionMillis[i]. It also takes as arguments a list of resource names and a resourceList, instead of a list of resources.

func UnschedulableTaint added in v0.3.65

func UnschedulableTaint() v1.Taint

UnschedulableTaint returns the taint automatically added to unschedulable nodes on inserting into the nodeDb.

func UnschedulableToleration added in v0.3.65

func UnschedulableToleration() v1.Toleration

UnschedulableToleration returns a toleration that tolerates UnschedulableTaint().

Types

type Node added in v0.3.79

type Node struct {
	Id       string
	Name     string
	Executor string

	// We need to store taints and labels separately from the node type: the latter only includes
	// indexed taints and labels, but we need all of them when checking pod requirements.
	Taints []v1.Taint
	Labels map[string]string

	TotalResources schedulerobjects.ResourceList

	// This field is set when inserting the Node into a NodeDb.
	Keys [][]byte

	NodeTypeId uint64

	AllocatableByPriority schedulerobjects.AllocatableByPriorityAndResourceType
	AllocatedByQueue      map[string]schedulerobjects.ResourceList
	AllocatedByJobId      map[string]schedulerobjects.ResourceList
	EvictedJobRunIds      map[string]bool
}

func EvictJobsFromNode added in v0.3.79

func EvictJobsFromNode(
	priorityClasses map[string]types.PriorityClass,
	jobFilter func(interfaces.LegacySchedulerJob) bool,
	jobs []interfaces.LegacySchedulerJob,
	node *Node,
) ([]interfaces.LegacySchedulerJob, *Node, error)

EvictJobsFromNode returns a copy of node with all elements of jobs for which jobFilter returns true evicted from it, together with a slice containing exactly those jobs.

Specifically:

  • The jobs that jobFilter returns true for are marked as evicted on the node.
  • Within AllocatableByPriorityAndResource, the resources allocated to these jobs are moved from the jobs' priorities to evictedPriority; they are not subtracted from AllocatedByJobId and AllocatedByQueue.

func UnbindJobFromNode added in v0.3.78

func UnbindJobFromNode(priorityClasses map[string]types.PriorityClass, job interfaces.LegacySchedulerJob, node *Node) (*Node, error)

UnbindJobFromNode returns a copy of node with job unbound from it.

func UnbindJobsFromNode added in v0.3.78

func UnbindJobsFromNode(priorityClasses map[string]types.PriorityClass, jobs []interfaces.LegacySchedulerJob, node *Node) (*Node, error)

UnbindJobsFromNode returns a node with all elements of jobs unbound from it.

func (*Node) UnsafeCopy added in v0.3.79

func (node *Node) UnsafeCopy() *Node

UnsafeCopy returns a pointer to a new value of type Node; it is unsafe because it only makes shallow copies of fields that are not mutated by methods of NodeDb.

type NodeDb

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

NodeDb is the scheduler-internal system used to efficiently find nodes on which a pod could be scheduled.

func NewNodeDb

func NewNodeDb(
	priorityClasses map[string]types.PriorityClass,
	maxExtraNodesToConsider uint,
	indexedResources []configuration.IndexedResource,
	indexedTaints,
	indexedNodeLabels []string,
) (*NodeDb, error)

func (*NodeDb) ClearAllocated

func (nodeDb *NodeDb) ClearAllocated() error

ClearAllocated zeroes out allocated resources on all nodes in the NodeDb.

func (*NodeDb) CreateAndInsertWithApiJobsWithTxn added in v0.3.79

func (nodeDb *NodeDb) CreateAndInsertWithApiJobsWithTxn(txn *memdb.Txn, jobs []*api.Job, node *schedulerobjects.Node) error

func (*NodeDb) CreateAndInsertWithJobDbJobsWithTxn added in v0.3.79

func (nodeDb *NodeDb) CreateAndInsertWithJobDbJobsWithTxn(txn *memdb.Txn, jobs []*jobdb.Job, node *schedulerobjects.Node) error

func (*NodeDb) GetNode

func (nodeDb *NodeDb) GetNode(id string) (*Node, error)

GetNode returns a node in the db with given id.

func (*NodeDb) GetNodeWithTxn

func (nodeDb *NodeDb) GetNodeWithTxn(txn *memdb.Txn, id string) (*Node, error)

GetNodeWithTxn returns a node in the db with given id, within the provided transactions.

func (*NodeDb) IndexedNodeLabelValues added in v0.3.79

func (nodeDb *NodeDb) IndexedNodeLabelValues(label string) (map[string]struct{}, bool)

IndexedNodeLabelValues returns the set of possible values for a given indexed label across all nodes in the NodeDb.

func (*NodeDb) NodeTypesMatchingPod

func (nodeDb *NodeDb) NodeTypesMatchingPod(req *schedulerobjects.PodRequirements) ([]*schedulerobjects.NodeType, map[string]int, error)

NodeTypesMatchingPod returns a slice with all node types a pod could be scheduled on. It also returns the number of nodes excluded by reason for exclusion.

func (*NodeDb) NumNodes

func (nodeDb *NodeDb) NumNodes() int

func (*NodeDb) ScheduleMany

func (nodeDb *NodeDb) ScheduleMany(jctxs []*schedulercontext.JobSchedulingContext) (bool, error)

ScheduleMany assigns a set of jobs to nodes. The assignment is atomic, i.e., either all jobs are successfully assigned to nodes or none are. The returned bool indicates whether assignment succeeded (true) or not (false).

This method sets the PodSchedulingContext field on each JobSchedulingContext that it attempts to schedule; if it returns early (e.g., because it finds an unschedulable JobSchedulingContext), then this field will not be set on the remaining items. TODO: Pass through contexts to support timeouts.

func (*NodeDb) ScheduleManyWithTxn

func (nodeDb *NodeDb) ScheduleManyWithTxn(txn *memdb.Txn, jctxs []*schedulercontext.JobSchedulingContext) (bool, error)

func (*NodeDb) SelectNodeForJobWithTxn added in v0.3.78

func (nodeDb *NodeDb) SelectNodeForJobWithTxn(txn *memdb.Txn, jctx *schedulercontext.JobSchedulingContext) (*Node, error)

SelectNodeForJobWithTxn selects a node on which the job can be scheduled.

func (*NodeDb) String

func (nodeDb *NodeDb) String() string

func (*NodeDb) TotalResources

func (nodeDb *NodeDb) TotalResources() schedulerobjects.ResourceList

func (*NodeDb) Txn

func (nodeDb *NodeDb) Txn(write bool) *memdb.Txn

func (*NodeDb) Upsert

func (nodeDb *NodeDb) Upsert(node *Node) error

func (*NodeDb) UpsertMany

func (nodeDb *NodeDb) UpsertMany(nodes []*Node) error

func (*NodeDb) UpsertManyWithTxn

func (nodeDb *NodeDb) UpsertManyWithTxn(txn *memdb.Txn, nodes []*Node) error

func (*NodeDb) UpsertWithTxn

func (nodeDb *NodeDb) UpsertWithTxn(txn *memdb.Txn, node *Node) error

type NodeIndex added in v0.3.71

type NodeIndex struct {
	KeyIndex int
}

NodeIndex is an index for schedulerobjects.Node that returns node.NodeDbKeys[KeyIndex].

func (*NodeIndex) FromArgs added in v0.3.71

func (index *NodeIndex) FromArgs(args ...interface{}) ([]byte, error)

FromArgs computes the index key from a set of arguments. Takes a single argument resourceAmount of type []byte.

func (*NodeIndex) FromObject added in v0.3.71

func (index *NodeIndex) FromObject(raw interface{}) (bool, []byte, error)

FromObject extracts the index key from a *Node.

type NodeIterator

type NodeIterator interface {
	NextNode() *Node
}

type NodePairIterator

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

func NewNodePairIterator

func NewNodePairIterator(txnA, txnB *memdb.Txn) (*NodePairIterator, error)

func (*NodePairIterator) Next

func (it *NodePairIterator) Next() interface{}

func (*NodePairIterator) NextItem

func (it *NodePairIterator) NextItem() (rv *NodePairIteratorItem)

func (*NodePairIterator) WatchCh

func (it *NodePairIterator) WatchCh() <-chan struct{}

type NodePairIteratorItem

type NodePairIteratorItem struct {
	NodeA *Node
	NodeB *Node
}

type NodeTypeIterator

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

NodeTypeIterator is an iterator over all nodes of a given nodeType with at least some specified amount of resources allocatable at a given priority. For example, all nodes of nodeType "foo" with at least 2 cores and 1Gi memory allocatable at priority 2. Nodes are returned in sorted order, from least to most of the specified resource available.

func NewNodeTypeIterator

func NewNodeTypeIterator(
	txn *memdb.Txn,
	nodeTypeId uint64,
	indexName string,
	priority int32,
	indexedResources []string,
	indexedResourceRequests []resource.Quantity,
	indexedResourceResolutionMillis []int64,
) (*NodeTypeIterator, error)

func (*NodeTypeIterator) Next

func (it *NodeTypeIterator) Next() interface{}

func (*NodeTypeIterator) NextNode

func (it *NodeTypeIterator) NextNode() (*Node, error)

func (*NodeTypeIterator) WatchCh

func (it *NodeTypeIterator) WatchCh() <-chan struct{}

type NodeTypesIterator

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

NodeTypesIterator is an iterator over all nodes of the given nodeTypes with at least some specified amount of resources allocatable at a given priority. For example, all nodes of nodeType "foo" and "bar" with at least 2 cores and 1Gi memory allocatable at priority 2. Nodes are returned in sorted order, from least to most of the specified resource available.

func NewNodeTypesIterator

func NewNodeTypesIterator(
	txn *memdb.Txn,
	nodeTypeIds []uint64,
	indexName string,
	priority int32,
	indexedResources []string,
	indexedResourceRequests []resource.Quantity,
	indexedResourceResolutionMillis []int64,
) (*NodeTypesIterator, error)

func (*NodeTypesIterator) Next

func (it *NodeTypesIterator) Next() interface{}

func (*NodeTypesIterator) NextNode

func (it *NodeTypesIterator) NextNode() (*Node, error)

func (*NodeTypesIterator) WatchCh

func (it *NodeTypesIterator) WatchCh() <-chan struct{}

type NodesIterator

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

NodesIterator is an iterator over all nodes in the db.

func NewNodesIterator

func NewNodesIterator(txn *memdb.Txn) (*NodesIterator, error)

func (*NodesIterator) Next

func (it *NodesIterator) Next() interface{}

func (*NodesIterator) NextNode

func (it *NodesIterator) NextNode() *Node

func (*NodesIterator) WatchCh

func (it *NodesIterator) WatchCh() <-chan struct{}

Jump to

Keyboard shortcuts

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