capacity

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package capacity implements a tracker for node resource capacity.

Index

Constants

View Source
const (
	TaintKey         = "zeropod.ctrox.dev/at-capacity"
	MinTaintDuration = time.Minute

	MetricNodeCapacity  = "node_capacity"
	MetricNodeRequested = "node_requested"
	MetricNodeEvictions = "node_evictions"
)

Variables

This section is empty.

Functions

func AddTaint

func AddTaint(node *corev1.Node) bool

AddTaint taints the node to not be used for scheduling if not already the case.

func CmpThreshold

func CmpThreshold(cap Tracker, name corev1.ResourceName, requested resource.Quantity) int

CmpThreshold returns 0 if requested is equal to capacity, -1 if the requested is less than capacity, or 1 if the requested is greater than capacity. Note that capacity will be multiplied by the Tracker threshold.

func HasTaint

func HasTaint(node *corev1.Node) (bool, time.Time)

HasTaint checks for an existing taint and returns the time added if true.

func RemoveTaint

func RemoveTaint(node *corev1.Node)

RemoveTaint removes the taint from the node.

Types

type NodeTracker

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

func (*NodeTracker) Capacity

func (c *NodeTracker) Capacity(name corev1.ResourceName) resource.Quantity

Capacity returns the node capacity for the corev1.ResourceName.

func (*NodeTracker) IncEvicted

func (c *NodeTracker) IncEvicted()

func (*NodeTracker) Requested

func (c *NodeTracker) Requested(name corev1.ResourceName) resource.Quantity

Requested returns the node requested resources for the corev1.ResourceName.

func (*NodeTracker) SetCapacity

func (c *NodeTracker) SetCapacity(name corev1.ResourceName, q resource.Quantity)

SetCapacity sets the resource capacity of a node.

func (*NodeTracker) SetRequested

func (c *NodeTracker) SetRequested(name corev1.ResourceName, q resource.Quantity)

SetRequested sets the requested resources of a node.

func (*NodeTracker) Threshold

func (c *NodeTracker) Threshold() float64

Threshold where capacity eviction starts.

func (*NodeTracker) UseCheckpointMemory

func (c *NodeTracker) UseCheckpointMemory() bool

type NoopTracker

type NoopTracker struct{}

NoopTracker implements a capacity tracker that does nothing.

func (*NoopTracker) Capacity

func (n *NoopTracker) Capacity(name corev1.ResourceName) resource.Quantity

Capacity implements Tracker.

func (*NoopTracker) IncEvicted

func (n *NoopTracker) IncEvicted()

IncEvicted implements Tracker.

func (*NoopTracker) Requested

func (n *NoopTracker) Requested(name corev1.ResourceName) resource.Quantity

Requested implements Tracker.

func (*NoopTracker) SetCapacity

func (n *NoopTracker) SetCapacity(name corev1.ResourceName, q resource.Quantity)

SetCapacity implements Tracker.

func (*NoopTracker) SetRequested

func (n *NoopTracker) SetRequested(name corev1.ResourceName, q resource.Quantity)

SetRequested implements Tracker.

func (*NoopTracker) Threshold

func (n *NoopTracker) Threshold() float64

Threshold implements Tracker.

func (*NoopTracker) UseCheckpointMemory

func (n *NoopTracker) UseCheckpointMemory() bool

UseCheckpointMemory implements Tracker.

type SystemMemoryTracker

type SystemMemoryTracker struct {
	Tracker
}

func (*SystemMemoryTracker) Capacity

Capacity gets the memory capacity from the total node memory.

func (*SystemMemoryTracker) Requested

Requested gets memory requests from the current available system memory.

func (*SystemMemoryTracker) SetCapacity

func (m *SystemMemoryTracker) SetCapacity(name corev1.ResourceName, q resource.Quantity)

SetCapacity sets the memory capacity to the total node memory.

func (*SystemMemoryTracker) SetRequested

func (m *SystemMemoryTracker) SetRequested(name corev1.ResourceName, q resource.Quantity)

SetRequested sets memory requests to the current available system memory.

func (*SystemMemoryTracker) UseCheckpointMemory

func (m *SystemMemoryTracker) UseCheckpointMemory() bool

type Tracker

type Tracker interface {
	Capacity(name corev1.ResourceName) resource.Quantity
	Requested(name corev1.ResourceName) resource.Quantity
	SetCapacity(name corev1.ResourceName, q resource.Quantity)
	SetRequested(name corev1.ResourceName, q resource.Quantity)
	Threshold() float64
	IncEvicted()
	UseCheckpointMemory() bool
}

func NewNodeTracker

func NewNodeTracker(reg prometheus.Registerer, name string, threshold float64) Tracker

NewNodeTracker creates a NodeTracker.

func NewNoopTracker

func NewNoopTracker() Tracker

NewNoopTracker creates a NoopTracker

func NewSystemMemoryTracker

func NewSystemMemoryTracker(reg prometheus.Registerer, name string, threshold float64) Tracker

NewSystemMemoryTracker creates a SystemMemoryTracker.

Jump to

Keyboard shortcuts

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