Documentation ¶
Index ¶
- func ConvertBytesString(val string) uint64
- func ConvertCPUString(val string) float64
- func ConvertGPUString(val string) uint64
- func ParseResourceUsageConfig(usage model.ResourceUsageConfig) model.ResourceUsageData
- type ChainedUsageCalculator
- type ChainedUsageCalculatorParams
- type DefaultsUsageCalculator
- type DefaultsUsageCalculatorParams
- type LocalTracker
- func (t *LocalTracker) AddIfHasCapacity(ctx context.Context, usage model.ResourceUsageData) bool
- func (t *LocalTracker) GetAvailableCapacity(ctx context.Context) model.ResourceUsageData
- func (t *LocalTracker) GetMaxCapacity(ctx context.Context) model.ResourceUsageData
- func (t *LocalTracker) IsWithinLimits(ctx context.Context, usage model.ResourceUsageData) bool
- func (t *LocalTracker) Remove(ctx context.Context, usage model.ResourceUsageData)
- type LocalTrackerParams
- type Provider
- type Tracker
- type UsageCalculator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertBytesString ¶
func ConvertCPUString ¶
func ConvertGPUString ¶
func ParseResourceUsageConfig ¶
func ParseResourceUsageConfig(usage model.ResourceUsageConfig) model.ResourceUsageData
Types ¶
type ChainedUsageCalculator ¶
type ChainedUsageCalculator struct {
// contains filtered or unexported fields
}
func NewChainedUsageCalculator ¶
func NewChainedUsageCalculator(params ChainedUsageCalculatorParams) *ChainedUsageCalculator
func (*ChainedUsageCalculator) Calculate ¶
func (c *ChainedUsageCalculator) Calculate( ctx context.Context, job model.Job, parsedUsage model.ResourceUsageData) (model.ResourceUsageData, error)
type ChainedUsageCalculatorParams ¶
type ChainedUsageCalculatorParams struct {
Calculators []UsageCalculator
}
type DefaultsUsageCalculator ¶
type DefaultsUsageCalculator struct {
// contains filtered or unexported fields
}
func NewDefaultsUsageCalculator ¶
func NewDefaultsUsageCalculator(params DefaultsUsageCalculatorParams) *DefaultsUsageCalculator
func (*DefaultsUsageCalculator) Calculate ¶
func (c *DefaultsUsageCalculator) Calculate( ctx context.Context, job model.Job, parsedUsage model.ResourceUsageData) (model.ResourceUsageData, error)
type DefaultsUsageCalculatorParams ¶
type DefaultsUsageCalculatorParams struct {
Defaults model.ResourceUsageData
}
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 model.ResourceUsageData) bool
func (*LocalTracker) GetAvailableCapacity ¶
func (t *LocalTracker) GetAvailableCapacity(ctx context.Context) model.ResourceUsageData
func (*LocalTracker) GetMaxCapacity ¶
func (t *LocalTracker) GetMaxCapacity(ctx context.Context) model.ResourceUsageData
func (*LocalTracker) IsWithinLimits ¶
func (t *LocalTracker) IsWithinLimits(ctx context.Context, usage model.ResourceUsageData) bool
func (*LocalTracker) Remove ¶
func (t *LocalTracker) Remove(ctx context.Context, usage model.ResourceUsageData)
type LocalTrackerParams ¶
type LocalTrackerParams struct {
MaxCapacity model.ResourceUsageData
}
type Provider ¶
type Provider interface {
GetAvailableCapacity(ctx context.Context) (model.ResourceUsageData, error)
}
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 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 model.ResourceUsageData) bool // AddIfHasCapacity atomically adds the given resource usage to the tracker if the compute node has capacity for it. AddIfHasCapacity(ctx context.Context, usage model.ResourceUsageData) bool // GetAvailableCapacity returns the available capacity of the compute node. GetAvailableCapacity(ctx context.Context) model.ResourceUsageData // GetMaxCapacity returns the total capacity of the compute node. GetMaxCapacity(ctx context.Context) model.ResourceUsageData // Remove removes the given resource usage from the tracker. Remove(ctx context.Context, usage model.ResourceUsageData) }
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 model.Job, parsedUsage model.ResourceUsageData) (model.ResourceUsageData, 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