capacity

package
v0.0.0-...-9f115a5 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceMemory = "memory"
	ResourceCores  = "cores"
)

Resource keys used for capacity splitting. Match CommittedResourceType constants.

Variables

This section is empty.

Functions

func LoggerFromContext

func LoggerFromContext(ctx context.Context) logr.Logger

LoggerFromContext returns a logger with greq and req values from the context. This creates a child logger with the request tracking values pre-attached, so you don't need to repeat them in every log call.

func SplitCapacity

func SplitCapacity(groups []GroupInput, hosts map[string]HostState) (freeResources, exclusiveResources map[string]map[string]int64, unassigned map[string]int64)

SplitCapacity runs the round-robin capacity assignment algorithm.

For each AZ it assigns resources (in raw units — bytes for memory, count for cores) to flavor groups in a fair, deterministic way such that no host is over-committed. Groups sharing hypervisors are served round-robin so no group monopolises shared hosts.

Returns:

  • freeResources[groupName]resource: sum of remaining resources across all candidate hosts for each group before the split. May overlap across groups sharing hosts.
  • exclusiveResources[groupName]resource: fairly attributed share after the split; sum across groups never exceeds actual installed capacity.
  • unassigned[resource]: resources on candidate hosts not claimed by any group due to fragmentation (for operator log visibility).

The caller divides exclusiveResources[group]ResourceMemory by the group's flavor memory to obtain the slot count meaningful to that group.

func WithNewGlobalRequestID

func WithNewGlobalRequestID(ctx context.Context) context.Context

WithNewGlobalRequestID creates a new context with a capacity-prefixed global request ID.

Types

type Config

type Config struct {
	// ReconcileInterval is how often the controller probes the scheduler and updates CRDs.
	ReconcileInterval metav1.Duration `json:"capacityReconcileInterval"`

	// TotalPipeline is the scheduler pipeline used for the empty-state probe.
	// This pipeline should ignore current VM allocations (e.g. kvm-report-capacity).
	TotalPipeline string `json:"capacityTotalPipeline"`

	// PlaceablePipeline is the scheduler pipeline used for the current-state probe.
	// This pipeline considers current VM allocations to determine remaining placement capacity.
	PlaceablePipeline string `json:"capacityPlaceablePipeline"`

	// SchedulerURL is the endpoint of the nova external scheduler.
	SchedulerURL string `json:"schedulerURL"`
}

Config holds configuration for the capacity controller.

func DefaultConfig

func DefaultConfig() Config

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

ApplyDefaults fills in any unset values with defaults.

type Controller

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

Controller reconciles FlavorGroupCapacity CRDs on a fixed interval. For each AZ it probes all flavor groups, runs the round-robin capacity split, then writes one FlavorGroupCapacity CRD per (flavor group × AZ) pair.

func NewController

func NewController(c client.Client, config Config, vmSource reservations.VMSource) *Controller

func (*Controller) Start

func (c *Controller) Start(ctx context.Context) error

Start runs the periodic reconcile loop. Implements manager.Runnable.

type GroupInput

type GroupInput struct {
	Name            string
	FlavorResources map[string]int64
	CandidateHosts  []string
}

type HostState

type HostState struct {
	Remaining map[string]int64
}

type Monitor

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

Monitor provides Prometheus metrics for FlavorGroupCapacity CRDs. It implements prometheus.Collector and reads CRD status on each Collect call.

func NewMonitor

func NewMonitor(c client.Client) Monitor

NewMonitor creates a new Monitor that reads FlavorGroupCapacity CRDs.

func (*Monitor) Collect

func (m *Monitor) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector — lists all FlavorGroupCapacity CRDs and exports gauges.

func (*Monitor) Describe

func (m *Monitor) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

Jump to

Keyboard shortcuts

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