Documentation
¶
Index ¶
- Constants
- func LoggerFromContext(ctx context.Context) logr.Logger
- func SplitCapacity(groups []GroupInput, hosts map[string]HostState) (freeResources, exclusiveResources map[string]map[string]int64, ...)
- func WithNewGlobalRequestID(ctx context.Context) context.Context
- type Config
- type GroupInput
- type HostState
- type Monitor
- type Reconciler
Constants ¶
const ( ResourceMemory = "memory" ResourceCores = "cores" )
Resource keys used for capacity splitting. Match CommittedResourceType constants.
Variables ¶
This section is empty.
Functions ¶
func LoggerFromContext ¶
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, strandedByHost map[string]map[string]int64, exclusiveHosts map[string][]string)
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).
- exclusiveHosts[groupName]: unique host names assigned to the group by the split. Each host appears in at most one group's list.
The caller divides exclusiveResources[group]ResourceMemory by the group's flavor memory to obtain the slot count meaningful to that group.
Types ¶
type Config ¶
type Config struct {
// ReconcileInterval is the periodic floor: how often the reconciler re-runs even without a
// watch event. Acts as a fallback for changes not covered by watches (e.g. blocked memory drift).
ReconcileInterval metav1.Duration `json:"capacityReconcileInterval"`
// MinReconcileInterval is the minimum time between two consecutive reconcile runs.
// If Reconcile() is called sooner than this since the last successful run, it returns early
// with RequeueAfter set to the remaining duration. Prevents back-to-back reconciles on rapid
// watch events (e.g. a batch of CommittedResource updates).
MinReconcileInterval metav1.Duration `json:"capacityMinReconcileInterval"`
// TotalPipeline is the scheduler pipeline used for the empty-state probe.
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"`
}
Config holds configuration for the capacity reconciler.
func DefaultConfig ¶
func DefaultConfig() Config
func (*Config) ApplyDefaults ¶
func (c *Config) ApplyDefaults()
ApplyDefaults fills in any unset values with defaults.
type GroupInput ¶
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 ¶
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.
type Reconciler ¶
type Reconciler struct {
// contains filtered or unexported fields
}
Reconciler reconciles FlavorGroupCapacity CRDs, driven by both watch events and a periodic floor timer. All watch events are coalesced into a single reconcile key so rapid changes produce at most one queued reconcile.
func NewController ¶
func NewController(c client.Client, config Config, vmSource reservations.VMSource, scheduler *sched.Placement) *Reconciler
func (*Reconciler) Reconcile ¶
Reconcile implements reconcile.Reconciler. It is called by controller-runtime whenever a watched CRD changes, and also on the periodic RequeueAfter floor set by ReconcileInterval. If called sooner than MinReconcileInterval since the last successful run, it returns early.
func (*Reconciler) SetupWithManager ¶
func (c *Reconciler) SetupWithManager(mgr ctrl.Manager, mcl *multicluster.Client) error
SetupWithManager registers the reconciler with the controller manager and sets up watches on all CRDs that affect capacity output. All events are coalesced to a single key.