Documentation
¶
Overview ¶
Package claim is a namespace's claim on a cluster resource.
A namespace consumes things the cluster owns and its peers share: the space of a pool, the addresses of a network. A claim says which resource, and how much of it the namespace may take:
[claim#1] type = pool name = dirquota limit = 250m [claim#2] type = network name = backend2 limit = 10 [claim#3] type = cpu limit = 800% default = 50% [claim#4] type = memory limit = 16g default = 512m
A cpu or memory claim names nothing: there is one compute of the cluster, and the claim is on the caps the objects of the namespace run with. The limit is expressed in the unit of the resource, so reading it is left to the package that hands that resource out. What is common is where the claim is declared and how it is found, which is this package.
Index ¶
- Constants
- Variables
- func ComputeFits(ctx context.Context, namespace, path string, claims map[string]int64) (bool, string, error)
- func ComputeLimit(namespace, claimType string) (int64, bool, error)
- func Default(namespace, claimType string) (string, bool, error)
- func Format(claimType string, v int64) string
- func Limit(namespace, claimType, name string) (string, bool, error)
- func Parse(claimType, s string, allCPUs int) (int64, error)
- func ParseCPU(s string, allCPUs int) (int64, error)
- func ParseMemory(s string) (int64, error)
Constants ¶
const ( // TypeCPU is a claim on the cpu the objects of a namespace are capped // to, counted in thousandths of a cpu. TypeCPU = "cpu" // TypeMemory is a claim on the memory the objects of a namespace are // capped to, counted in bytes. TypeMemory = "memory" // Unbounded is the claim of an object running a process capped by // nothing, which takes what it finds. Unbounded = int64(-1) )
const GuestMemoryMargin = int64(384 * 1024 * 1024)
GuestMemoryMargin is what a virtual machine takes on the node over the memory it is given: qemu, its devices and its page tables. A guest of 1g peaked at 1.3g on a node, all its memory touched.
Variables ¶
var ComputeTypes = []string{TypeCPU, TypeMemory}
ComputeTypes are the claims counted from the caps of the objects.
Functions ¶
func ComputeFits ¶
func ComputeFits(ctx context.Context, namespace, path string, claims map[string]int64) (bool, string, error)
ComputeFits says whether a namespace may have an object claim what it asks of each compute type, and why not when it may not.
The claims are what the object is to claim, not the increase: what it claims today is already counted in what the namespace holds.
A namespace claiming none of the types asked about is not capped on them, and is answered from the local configuration alone. A capped one is brokered by the node speaking for the cluster, as a pool claim is.
Failing to reach the daemon leaves the claim unchecked rather than refused: where there is no daemon to ask there is nothing brokering.
func ComputeLimit ¶
ComputeLimit is the most a namespace may claim of a compute type, and whether it is capped on it at all.
func Default ¶
Default is the cap a namespace gives the containers of its objects that say none, on a compute claim, and whether it gives one at all.
A claim on the cpu or the memory counts the caps of the objects, and a container capped by nothing counts as taking without bound, which no claim admits. The default is what lets a container that says nothing about its caps run in a claimed namespace.
func Limit ¶
Limit is the limit a namespace declares on a cluster resource, and whether it declares one at all.
It is read from the namespace configuration on this node, and never over the api: taking a share of a cluster resource is a common thing to do and most namespaces claim nothing, so it must not wait on a daemon to find that out. A namespace configuration is present on every cluster node, so there is nothing to ask a peer for.
A namespace whose configuration this node does not hold is read as claiming nothing.
func ParseCPU ¶
ParseCPU reads a cpu cap in the pg_cpu_quota notation, a percentage of the cpus named after the @, one when none is, and answers it in thousandths of a cpu:
50% => 500, half of one 100%@4 => 4000, four of them 10%@2 => 200, a tenth of two
@all names the cpus of the node, which are allCPUs of them. A claim is a quantity of the cluster, where no node is the one to count them on, so a claim limit is read with allCPUs at zero, which refuses @all.
func ParseMemory ¶
ParseMemory reads a memory cap in bytes.
Types ¶
This section is empty.