nodedb

package
v0.15.4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PodRequirementsNotMetReasonUnknown               = "unknown"
	PodRequirementsNotMetReasonInsufficientResources = "insufficient resources available"
)

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 an 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 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 []int64) []byte

NodeIndexKey returns a []byte to be used as a key with the NodeIndex memdb index. This key should be used for lookup. Use the rounded version below for inserts.

The layout of the key is:

0 8 16 32 x x+8 | nodeTypeId | resources[0] | resources[1] | ... | nodeIndex |

where the numbers indicate byte index. NodeIndex ensures each key is unique and so must be unique across all nodes.

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 RoundedNodeIndexKeyFromResourceList added in v0.3.71

func RoundedNodeIndexKeyFromResourceList(
	out []byte,
	nodeTypeId uint64,
	resourceNames []string,
	resourceResolution []int64,
	rl internaltypes.ResourceList,
	nodeIndex uint64,
) []byte

RoundedNodeIndexKeyFromResourceList works like NodeIndexKey, except that prior to constructing the key the i-th resource is rounded down to the closest multiple of resourceResolution[i]. This rounding makes iterating over nodes with at least some amount of available resources more efficient. It also takes as arguments a list of resource names and a resourceList, instead of a list of resources.

Types

type EvictedJobSchedulingContext added in v0.3.90

type EvictedJobSchedulingContext struct {
	// Id of the evicted job.
	JobId string
	// Each evicted job is assigned a unique integer indicating the order in which it is re-scheduled.
	// I.e., index establishes a global order among all evicted jobs.
	//
	// When choosing on which node to schedule a job that would prevent re-scheduling evicted jobs,
	// nodeDb choses the node that would prevent re-scheduling jobs with as a large an index as possible.
	Index                int
	JobSchedulingContext *context.JobSchedulingContext
}

EvictedJobSchedulingContext represents an evicted job. NodeDb may track these to ensure preemptions are fair.

type InsufficientResources added in v0.4.1

type InsufficientResources struct {
	ResourceName string
	Required     resource.Quantity
	Available    resource.Quantity
}

func (*InsufficientResources) String added in v0.4.1

func (err *InsufficientResources) String() string

func (*InsufficientResources) Sum64 added in v0.4.1

func (r *InsufficientResources) Sum64() uint64

type MissingLabel added in v0.4.1

type MissingLabel struct {
	Label string
}

func (*MissingLabel) String added in v0.4.1

func (r *MissingLabel) String() string

func (*MissingLabel) Sum64 added in v0.4.1

func (r *MissingLabel) Sum64() uint64

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,
	indexedResources []configuration.ResourceType,
	indexedTaints []string,
	indexedNodeLabels []string,
	wellKnownNodeTypes []configuration.WellKnownNodeType,
	resourceListFactory *internaltypes.ResourceListFactory,
) (*NodeDb, error)

func (*NodeDb) AddEvictedJobSchedulingContextWithTxn added in v0.3.90

func (nodeDb *NodeDb) AddEvictedJobSchedulingContextWithTxn(txn *memdb.Txn, index int, jctx *context.JobSchedulingContext) error

func (*NodeDb) AddNodeToDb added in v0.13.0

func (nodeDb *NodeDb) AddNodeToDb(node *internaltypes.Node)

func (*NodeDb) ClearAllocated

func (nodeDb *NodeDb) ClearAllocated() error

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

func (*NodeDb) CreateAndInsertWithJobDbJobsWithTxn added in v0.3.79

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

func (*NodeDb) EvictJobsFromNode added in v0.4.8

func (nodeDb *NodeDb) EvictJobsFromNode(
	jobFilter func(*jobdb.Job) bool,
	jobs []*jobdb.Job,
	node *internaltypes.Node,
) ([]*jobdb.Job, *internaltypes.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 (*NodeDb) GetNode

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

GetNode returns a node in the db with given id.

func (*NodeDb) GetNodeWithTxn

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

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

func (*NodeDb) GetScheduledAtPriority added in v0.4.8

func (nodeDb *NodeDb) GetScheduledAtPriority(jobId string) (int32, bool)

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) NodeTypesMatchingJob added in v0.4.1

func (nodeDb *NodeDb) NodeTypesMatchingJob(jctx *context.JobSchedulingContext) ([]uint64, map[string]int, error)

NodeTypesMatchingJob 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) Reset added in v0.3.90

func (nodeDb *NodeDb) Reset() error

Reset clears out data specific to one scheduling round to prepare for a new scheduling round. Only necessary when nodeDb.enableNewPreemptionStrategy is true.

func (*NodeDb) ScheduleManyWithTxn

func (nodeDb *NodeDb) ScheduleManyWithTxn(txn *memdb.Txn, gctx *context.GangSchedulingContext) (bool, error)

func (*NodeDb) SelectNodeForJobWithTxn added in v0.3.78

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

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

func (*NodeDb) String

func (nodeDb *NodeDb) String() string

func (*NodeDb) TotalKubernetesResources added in v0.14.1

func (nodeDb *NodeDb) TotalKubernetesResources() internaltypes.ResourceList

func (*NodeDb) Txn

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

func (*NodeDb) UnbindJobFromNode added in v0.4.8

func (nodeDb *NodeDb) UnbindJobFromNode(job *jobdb.Job, node *internaltypes.Node) (*internaltypes.Node, error)

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

func (*NodeDb) UnbindJobsFromNode added in v0.4.8

func (nodeDb *NodeDb) UnbindJobsFromNode(jobs []*jobdb.Job, node *internaltypes.Node) (*internaltypes.Node, error)

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

func (*NodeDb) Upsert

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

func (*NodeDb) UpsertMany

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

func (*NodeDb) UpsertManyWithTxn

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

func (*NodeDb) UpsertWithTxn

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

type NodeIndex added in v0.3.71

type NodeIndex struct {
	KeyIndex int
}

NodeIndex is an index for internaltypes.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() *internaltypes.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,
	keyIndex int,
	indexedResources []string,
	indexedResourceRequests []int64,
	indexedResourceResolution []int64,
) (*NodeTypeIterator, error)

func (*NodeTypeIterator) Next

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

func (*NodeTypeIterator) NextNode

func (it *NodeTypeIterator) NextNode() (*internaltypes.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,
	keyIndex int,
	indexedResources []string,
	indexedResourceRequests []int64,
	indexedResourceResolution []int64,
) (*NodeTypesIterator, error)

func (*NodeTypesIterator) Next

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

func (*NodeTypesIterator) NextNode

func (it *NodeTypesIterator) NextNode() (*internaltypes.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() *internaltypes.Node

func (*NodesIterator) WatchCh

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

type PodRequirementsNotMetReason added in v0.4.1

type PodRequirementsNotMetReason interface {
	fmt.Stringer
	// Returns a 64-bit hash of this reason.
	Sum64() uint64
}

func DynamicJobRequirementsMet added in v0.4.1

func DynamicJobRequirementsMet(allocatableResources internaltypes.ResourceList, jctx *schedulercontext.JobSchedulingContext) (bool, PodRequirementsNotMetReason)

DynamicJobRequirementsMet checks if a pod can be scheduled onto this node, accounting for resources allocated to pods already assigned to this node.

func JobRequirementsMet added in v0.4.1

JobRequirementsMet determines whether a job can be scheduled onto this node. If the pod can be scheduled, the returned score indicates how well the node fits: - 0: Pod can be scheduled by preempting running pods. - 1: Pod can be scheduled without preempting any running pods. If the requirements are not met, it returns the reason why. If the requirements can't be parsed, an error is returned.

func NodeAffinityRequirementsMet added in v0.4.1

func NodeAffinityRequirementsMet(node *internaltypes.Node, nodeSelector *v1.NodeSelector) (bool, PodRequirementsNotMetReason, error)

func NodeSelectorRequirementsMet added in v0.4.1

func NodeSelectorRequirementsMet(nodeLabelGetter func(string) (string, bool), unsetIndexedLabelGetter func(string) (string, bool), nodeSelector map[string]string) (bool, PodRequirementsNotMetReason)

func NodeTolerationRequirementsMet added in v0.4.40

func NodeTolerationRequirementsMet(node *internaltypes.Node, tolerations ...[]v1.Toleration) (bool, PodRequirementsNotMetReason)

func NodeTypeJobRequirementsMet added in v0.4.1

func NodeTypeJobRequirementsMet(nodeType *internaltypes.NodeType, jctx *schedulercontext.JobSchedulingContext) (bool, PodRequirementsNotMetReason)

NodeTypeJobRequirementsMet determines whether a pod can be scheduled on nodes of this NodeType. If the requirements are not met, it returns the reason for why. If the requirements can't be parsed, an error is returned.

func StaticJobRequirementsMet added in v0.4.1

StaticJobRequirementsMet checks if a job can be scheduled onto this node, accounting for taints, node selectors, node affinity, and total resources available on the node.

func TolerationRequirementsMet added in v0.4.1

func TolerationRequirementsMet(nodeType *internaltypes.NodeType, tolerations ...[]v1.Toleration) (bool, PodRequirementsNotMetReason)

type UnmatchedLabel added in v0.4.1

type UnmatchedLabel struct {
	Label     string
	PodValue  string
	NodeValue string
}

func (*UnmatchedLabel) String added in v0.4.1

func (r *UnmatchedLabel) String() string

func (*UnmatchedLabel) Sum64 added in v0.4.1

func (r *UnmatchedLabel) Sum64() uint64

type UnmatchedNodeSelector added in v0.4.1

type UnmatchedNodeSelector struct {
	NodeSelector *v1.NodeSelector
}

func (*UnmatchedNodeSelector) String added in v0.4.1

func (r *UnmatchedNodeSelector) String() string

func (*UnmatchedNodeSelector) Sum64 added in v0.4.1

func (r *UnmatchedNodeSelector) Sum64() uint64

type UntoleratedTaint added in v0.4.1

type UntoleratedTaint struct {
	Taint v1.Taint
}

func (*UntoleratedTaint) String added in v0.4.1

func (r *UntoleratedTaint) String() string

func (*UntoleratedTaint) Sum64 added in v0.4.1

func (r *UntoleratedTaint) Sum64() uint64

Jump to

Keyboard shortcuts

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