Documentation
¶
Overview ¶
Package limits holds the caps the cluster owns on devices, labs and tenants. The chart sets them (values limits.*); the management agent enforces them on CreateLabs and reports them in GetFeatures, and the planning profile (the default of a device without resources) is the one the scheduler counts with.
Index ¶
- func DeviceQuantity(s string, cpu bool) (int64, error)
- type Config
- type Limits
- func (l Limits) CheckSpec(spec *laboratoryv1alpha1.LabSpec) error
- func (l Limits) DeviceResources(r *laboratoryv1alpha1.DeviceResources) (cpu, mem int64, err error)
- func (l Limits) GroupFits(labs int, cpu, mem, addCPU, addMem int64) error
- func (l Limits) SpecTotals(spec *laboratoryv1alpha1.LabSpec) (cpu, mem int64, containers int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeviceQuantity ¶
DeviceQuantity parses a device cpu (millicores) or memory (bytes) value the way a tenant may write it: it must be positive and within the absolute bound. A zero value would remove the pod limit, a negative or an overflowing one would skew the sums. Quantities are compared as quantities, so an exponent that overflows int64 is refused, not wrapped.
Types ¶
type Config ¶
type Config struct {
DeviceMaxCPU string `env:"DEVICE_MAX_CPU" envDefault:"2000m"`
DeviceMaxMemory string `env:"DEVICE_MAX_MEMORY" envDefault:"4Gi"`
DeviceDefaultCPU string `env:"DEVICE_DEFAULT_CPU" envDefault:"100m"`
DeviceDefaultMemory string `env:"DEVICE_DEFAULT_MEMORY" envDefault:"256Mi"`
// LabMaxDevices caps the devices of one lab, switches and hubs included (0 = the platform ceiling, names.MaxLabDevices).
LabMaxDevices int `env:"AGENT_LIMIT_LAB_MAX_DEVICES" envDefault:"32"`
// GroupMaxLabs caps the labs of one LabGroup (0 = no limit); GroupMaxCPU and GroupMaxMemory cap the sum of
// the resources of the devices of all its labs (the planning profile counts for a device without resources;
// "0" = no limit).
GroupMaxLabs int `env:"AGENT_LIMIT_GROUP_MAX_LABS" envDefault:"50"`
GroupMaxCPU string `env:"AGENT_LIMIT_GROUP_MAX_CPU" envDefault:"0"`
GroupMaxMemory string `env:"AGENT_LIMIT_GROUP_MAX_MEMORY" envDefault:"0"`
TenantMaxLabs int `env:"AGENT_LIMIT_TENANT_MAX_LABS" envDefault:"0"`
}
Config is read by the agent from the environment the chart gives it. CPU is a Kubernetes quantity ("500m", "2"), memory too ("512Mi"). The defaults mirror values.yaml. The DEVICE_* names are the operator's (the same chart values limits.device.*).
type Limits ¶
type Limits struct {
DeviceMaxCPU, DeviceMaxMemory int64
DeviceDefaultCPU, DeviceDefaultMemory int64
LabMaxDevices int
GroupMaxLabs int
GroupMaxCPU, GroupMaxMemory int64
TenantMaxLabs int
}
Limits is Config parsed: CPU in millicores, memory in bytes. A zero cap means no limit.
func (Limits) CheckSpec ¶
func (l Limits) CheckSpec(spec *laboratoryv1alpha1.LabSpec) error
CheckSpec refuses a lab spec that passes a cap: too many devices (every type counts), too many interfaces on a device (16 on a container, 48 on a switch or hub), or a device over the device maximum. The message names the numbers.
func (Limits) DeviceResources ¶
func (l Limits) DeviceResources(r *laboratoryv1alpha1.DeviceResources) (cpu, mem int64, err error)
DeviceResources is what a device is planned with: its limit, else its request, else the default. A quantity that does not parse is an error.
func (Limits) GroupFits ¶
GroupFits says whether a group that already holds labs labs planned at cpu and mem can take one more lab of the given totals; the error says which cap stops it.
func (Limits) SpecTotals ¶
func (l Limits) SpecTotals(spec *laboratoryv1alpha1.LabSpec) (cpu, mem int64, containers int, err error)
SpecTotals is the CPU (millicores) and memory (bytes) the container devices of a spec are planned with, and how many there are. A quantity that does not parse is an error naming the device.