capacity

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGPULabelsProvider added in v1.2.1

func NewGPULabelsProvider(totalCapacity models.Resources) models.LabelsProvider

Types

type ChainedUsageCalculator

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

func (*ChainedUsageCalculator) Calculate

func (c *ChainedUsageCalculator) Calculate(
	ctx context.Context, job models.Job, parsedUsage models.Resources) (*models.Resources, error)

type ChainedUsageCalculatorParams

type ChainedUsageCalculatorParams struct {
	Calculators []UsageCalculator
}

type DefaultsUsageCalculator

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

func (*DefaultsUsageCalculator) Calculate

func (c *DefaultsUsageCalculator) Calculate(
	ctx context.Context, job models.Job, parsedUsage models.Resources) (*models.Resources, error)

type DefaultsUsageCalculatorParams

type DefaultsUsageCalculatorParams struct {
	Defaults models.Resources
}

type LocalTracker

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

LocalTracker keeps track of the current resource usage of the local node in-memory.

func NewLocalTracker

func NewLocalTracker(params LocalTrackerParams) *LocalTracker

func (*LocalTracker) AddIfHasCapacity

func (t *LocalTracker) AddIfHasCapacity(ctx context.Context, usage models.Resources) *models.Resources

func (*LocalTracker) GetAvailableCapacity

func (t *LocalTracker) GetAvailableCapacity(ctx context.Context) models.Resources

func (*LocalTracker) GetMaxCapacity

func (t *LocalTracker) GetMaxCapacity(ctx context.Context) models.Resources

func (*LocalTracker) IsWithinLimits

func (t *LocalTracker) IsWithinLimits(ctx context.Context, usage models.Resources) bool

func (*LocalTracker) Remove

func (t *LocalTracker) Remove(ctx context.Context, usage models.Resources)

type LocalTrackerParams

type LocalTrackerParams struct {
	MaxCapacity models.Resources
}

type Provider

type Provider interface {
	// GetAvailableCapacity returns the resources that are available for use by this node.
	GetAvailableCapacity(ctx context.Context) (models.Resources, error)

	// A set of human-readable strings that explains what this subprovider can detect.
	ResourceTypes() []string
}

Provider returns the available capacity of a compute node. Implementation can return local node capacity if operating with a single node, or capacity of a cluster if compute is backed by a fleet of nodes.

type ToolBasedProvider added in v1.2.0

type ToolBasedProvider struct {
	Command  string
	Provides string
	Args     []string
	Parser   func(io.Reader) (models.Resources, error)
}

ToolBasedProvider will run an external tool and parse the results in a tool-specific way into a models.Resources instance.

The tool is not required to return values for all fields. Any fields that aren't covered by the tool will have a zero value.

func (*ToolBasedProvider) GetAvailableCapacity added in v1.2.0

func (tool *ToolBasedProvider) GetAvailableCapacity(ctx context.Context) (models.Resources, error)

GetAvailableCapacity implements Provider.

func (*ToolBasedProvider) ResourceTypes added in v1.2.0

func (tool *ToolBasedProvider) ResourceTypes() []string

ResourceTypes implements Subprovider.

type Tracker

type Tracker interface {
	// IsWithinLimits returns true if the given resource usage is within the limits of the compute node.
	// Limits refer to the total capacity of the compute node, and not to the currently available capacity.
	IsWithinLimits(ctx context.Context, usage models.Resources) bool
	// AddIfHasCapacity atomically adds the given resource usage to the tracker
	// if the compute node has capacity for it, returning the resource usage
	// that was added including any allocations that were made, or nil if the usage could not be added.
	AddIfHasCapacity(ctx context.Context, usage models.Resources) *models.Resources
	// GetAvailableCapacity returns the available capacity of the compute node.
	GetAvailableCapacity(ctx context.Context) models.Resources
	// GetMaxCapacity returns the total capacity of the compute node.
	GetMaxCapacity(ctx context.Context) models.Resources
	// Remove removes the given resource usage from the tracker.
	Remove(ctx context.Context, usage models.Resources)
}

Tracker keeps track of the current resource usage of the compute node. The regular flow is to call AddIfHasCapacity before starting a new execution to reserve capacity, and Remove after the execution is done to release the reserved capacity.

type UsageCalculator

type UsageCalculator interface {
	Calculate(ctx context.Context, job models.Job, parsedUsage models.Resources) (*models.Resources, error)
}

UsageCalculator calculates the resource usage of a job. Can also be used to populate the resource usage of a job with default values if not defined

Directories

Path Synopsis
gpu

Jump to

Keyboard shortcuts

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