Documentation
¶
Overview ¶
Package respool groups machines into resource pools with hard limits (ADR-0030, made binding in ADR-0032): vCPUs, memory and disk space per storage pool. Pools nest; a machine in a child pool counts against every ancestor, so a parent caps its whole tree. Limits are checked whenever a machine is created, grows, gets a disk or is moved into a pool, for everyone (admins included): that is what a limit is for.
Index ¶
- func Check(chain []ResourcePool, usage map[string]Usage, d Demand) error
- type Demand
- type MachineUse
- type ResourcePool
- type Store
- func (s *Store) Assign(poolID, uuid string, fits func(chain []ResourcePool) error) error
- func (s *Store) Chain(id string) []ResourcePool
- func (s *Store) Create(p ResourcePool) (ResourcePool, error)
- func (s *Store) Delete(id string) error
- func (s *Store) Forget(uuid string)
- func (s *Store) Get(id string) (ResourcePool, bool)
- func (s *Store) List() []ResourcePool
- func (s *Store) PoolOf(uuid string) string
- func (s *Store) Update(p ResourcePool) error
- func (s *Store) Usages(use func(uuid string) (MachineUse, bool)) map[string]Usage
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MachineUse ¶
type MachineUse struct {
VCPUs int
MemoryMiB uint64
StorageBytes map[string]uint64 // per storage pool
}
MachineUse is one machine's resources as the limits count them.
type ResourcePool ¶
type ResourcePool struct {
ID string `json:"id"`
Name string `json:"name"`
ParentID string `json:"parentId,omitempty"`
Description string `json:"description,omitempty"`
// CPULimit is the most vCPUs the pool's machines may have together.
CPULimit int `json:"cpuLimit"`
// MemoryLimitMiB is the most memory (maximum memory of each machine) together.
MemoryLimitMiB uint64 `json:"memoryLimitMiB"`
// StorageLimits caps disk capacity per libvirt storage pool name, in bytes.
StorageLimits map[string]uint64 `json:"storageLimits"`
Machines []string `json:"machines"` // machine UUIDs (lower case)
CreatedAt time.Time `json:"createdAt"`
}
ResourcePool is a group of machines with limits (0 means unlimited).
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Assign ¶
func (s *Store) Assign(poolID, uuid string, fits func(chain []ResourcePool) error) error
Assign moves a machine into a pool (out of any other); poolID "" takes it out of all. fits is called first with the destination chain, so the caller can check the limits (counting usage without this machine, which may already be somewhere in the tree).
func (*Store) Chain ¶
func (s *Store) Chain(id string) []ResourcePool
Chain is a pool and its ancestors, the pool first.
func (*Store) Create ¶
func (s *Store) Create(p ResourcePool) (ResourcePool, error)
Create adds a pool. Its limits must fit inside its parent's.
func (*Store) Update ¶
func (s *Store) Update(p ResourcePool) error
Update changes name, parent, description and limits (not the machines).