resources

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NodeGroupResources

type NodeGroupResources map[string]*Resources

NodeGroupResources represents resources for a group of nodes

func AvailableForNodes

func AvailableForNodes(nodes []*corev1.Node, currentUsage NodeGroupResources) NodeGroupResources

AvailableForNodes finds available resources by subtracting current usage from allocatable per node

func UsageForNodes

func UsageForNodes(resourceReservations []*v1beta2.ResourceReservation) NodeGroupResources

UsageForNodes tallies resource usages per node from the given list of resource reservations

func (NodeGroupResources) Add

func (nodeResources NodeGroupResources) Add(other NodeGroupResources)

Add adds all resources in other into the receiver, modifies receiver

func (NodeGroupResources) Sub

func (nodeResources NodeGroupResources) Sub(other NodeGroupResources)

Sub subtract all resources in other from the receiver, modifies receiver

type NodeGroupSchedulingMetadata

type NodeGroupSchedulingMetadata map[string]*NodeSchedulingMetadata

NodeGroupSchedulingMetadata represents NodeSchedulingMetadata for a group of nodes

func NodeSchedulingMetadataForNodes

func NodeSchedulingMetadataForNodes(
	nodes []*corev1.Node,
	currentUsage NodeGroupResources,
	overheadUsage NodeGroupResources) NodeGroupSchedulingMetadata

NodeSchedulingMetadataForNodes calculate available and schedulable resources. Available resources are computed by subtracting current and overhead usage from allocatable per node. Schedulable resources are computed by subtracting overhead usage from allocatable per node.

func (NodeGroupSchedulingMetadata) SubtractUsageIfExists

func (nodesSchedulingMetadata NodeGroupSchedulingMetadata) SubtractUsageIfExists(usedResourcesByNodeName NodeGroupResources)

SubtractUsageIfExists subtracts usedResourcesByNodeName from the receiver, modifies receiver, only for nodes that exist in receiver

type NodeSchedulingMetadata

type NodeSchedulingMetadata struct {
	AvailableResources   *Resources
	SchedulableResources *Resources
	CreationTimestamp    time.Time
	ZoneLabel            string
	AllLabels            map[string]string
	Unschedulable        bool
	Ready                bool
}

NodeSchedulingMetadata represents various parameters of a node that are considered in scheduling decisions

func CreateSchedulingMetadata added in v0.12.0

func CreateSchedulingMetadata(cpu, memory, nvidiaGPU int64, zoneLabel string) *NodeSchedulingMetadata

CreateSchedulingMetadata creates a new NodeSchedulingMetadata struct with provided specs as the available capacity. Total capacity is set to infinity. When total capacity is relevant use CreateSchedulingMetadataWithTotals instead.

func CreateSchedulingMetadataWithTotals added in v0.12.0

func CreateSchedulingMetadataWithTotals(
	availableCPU, cpuTotal, availableMemory, memoryTotal, availableNvidiaGPU, nvidiaGPUTotal int64,
	zoneLabel string) *NodeSchedulingMetadata

CreateSchedulingMetadataWithTotals creates a new NodeSchedulingMetadata struct with the provided usage and total capacity specs.

type Resources

type Resources struct {
	CPU       resource.Quantity
	Memory    resource.Quantity
	NvidiaGPU resource.Quantity
}

Resources represents the CPU and Memory resource quantities

func CreateResources added in v0.12.0

func CreateResources(cpu, memory, nvidiaGpus int64) *Resources

CreateResources creates a new Resources struct with given specs.

func Zero

func Zero() *Resources

Zero returns a Resources object with quantities of zero

func (*Resources) Add

func (r *Resources) Add(other *Resources)

Add modifies the receiver in place.

func (*Resources) AddFromReservation

func (r *Resources) AddFromReservation(reservation *v1beta2.Reservation)

AddFromReservation modifies the receiver in place.

func (*Resources) AddFromResourceList

func (r *Resources) AddFromResourceList(resourceList corev1.ResourceList)

AddFromResourceList modified the receiver in place

func (*Resources) Copy

func (r *Resources) Copy() *Resources

Copy returns a clone of the Resources object

func (*Resources) Eq

func (r *Resources) Eq(other *Resources) bool

Eq returns true if all of CPU, Memory and NvidiaGPU quantities are equal between this Resources object and other

func (*Resources) GreaterThan

func (r *Resources) GreaterThan(other *Resources) bool

GreaterThan returns true if any of CPU, Memory or NvidiaGPU quantities of this object are greater than those of other

func (*Resources) SetMaxResource added in v0.2.9

func (r *Resources) SetMaxResource(resourceList corev1.ResourceList)

SetMaxResource modifies the receiver in place to set each resource to the greater value of itself or the corresponding resource in resourceList

func (*Resources) Sub

func (r *Resources) Sub(other *Resources)

Sub modifies the receiver in place

Jump to

Keyboard shortcuts

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