respool

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(chain []ResourcePool, usage map[string]Usage, d Demand) error

Check reports the first limit in chain that d would exceed, given current usage.

Types

type Demand

type Demand struct {
	VCPUs        int
	MemoryMiB    uint64
	StoragePool  string
	StorageBytes uint64
}

Demand is what an operation adds.

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 Open

func Open(path string) (*Store, error)

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) Delete

func (s *Store) Delete(id string) error

Delete removes an empty pool without children.

func (*Store) Forget

func (s *Store) Forget(uuid string)

Forget drops a deleted machine from its pool.

func (*Store) Get

func (s *Store) Get(id string) (ResourcePool, bool)

func (*Store) List

func (s *Store) List() []ResourcePool

List returns every pool, by name.

func (*Store) PoolOf

func (s *Store) PoolOf(uuid string) string

PoolOf is the pool a machine is in ("" for none).

func (*Store) Update

func (s *Store) Update(p ResourcePool) error

Update changes name, parent, description and limits (not the machines).

func (*Store) Usages

func (s *Store) Usages(use func(uuid string) (MachineUse, bool)) map[string]Usage

Usages adds up every pool's machines, children's included. use gives a machine's resources (ok=false: it no longer exists here and counts nothing).

type Usage

type Usage struct {
	PoolID       string            `json:"poolId"`
	Machines     int               `json:"machines"`
	VCPUs        int               `json:"vcpus"`
	MemoryMiB    uint64            `json:"memoryMiB"`
	StorageBytes map[string]uint64 `json:"storageBytes"`
}

Usage is what a pool's machines (its children's included) use.

Jump to

Keyboard shortcuts

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