Documentation
¶
Index ¶
- func ClassifyNoHostFound(activeCRs []v1alpha1.CommittedResource, evaluator *SlotEvaluator, ...) string
- func ClassifyPlacement(evaluator *SlotEvaluator, activeCRs []v1alpha1.CommittedResource, ...) string
- func NewNoHostFoundCounter() *prometheus.CounterVec
- func NewPlacementCounter() *prometheus.CounterVec
- func PickSlot(candidates []v1alpha1.Reservation, vmMemoryBytes int64) string
- func ReservationRemainingMemory(res v1alpha1.Reservation) int64
- type Recorder
- type SlotEvaluator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClassifyNoHostFound ¶
func ClassifyNoHostFound( activeCRs []v1alpha1.CommittedResource, evaluator *SlotEvaluator, inputHosts []string, projectID, flavorGroupName string, vmMemBytes int64, ) string
ClassifyNoHostFound determines why no host was found for a nova placement request, in terms of committed resource coverage:
- no_cr: project has no active CommittedResources for the flavor group (NH1)
- cr_exhausted: CommittedResources exist but are fully occupied (NH2)
- slot_exhausted: CR has remaining capacity but no input host has a usable slot (NH3)
- slot_blocked: a usable slot exists but scheduling constraints excluded all such hosts (NH4)
func ClassifyPlacement ¶
func ClassifyPlacement( evaluator *SlotEvaluator, activeCRs []v1alpha1.CommittedResource, candidateHosts []string, projectID, flavorGroupName string, ) string
ClassifyPlacement determines the CR slot outcome for a successful placement:
- no_cr: no active CR or CR capacity fully exhausted (H1)
- slot_missed: CR has remaining capacity but no candidate host has a slot with remaining > 0 (H2)
- slot_used: CR has remaining capacity and at least one candidate host has a slot with remaining > 0 (H3)
func NewNoHostFoundCounter ¶
func NewNoHostFoundCounter() *prometheus.CounterVec
NewNoHostFoundCounter creates the Prometheus counter for no-host-found classification. Register it with the metrics registry before assigning it to the Recorder.
func NewPlacementCounter ¶
func NewPlacementCounter() *prometheus.CounterVec
NewPlacementCounter creates the Prometheus counter for successful Nova placements. Labels: flavor_group, intent, cr_slot (no_cr/slot_missed/slot_used/error). PAYG placements (flavor not in any group) are not counted — they return before reaching this counter. cr_slot=error is emitted when the flavor group lookup fails due to a K8s error. Register it with the metrics registry before assigning it to the Recorder.
func PickSlot ¶
func PickSlot(candidates []v1alpha1.Reservation, vmMemoryBytes int64) string
PickSlot selects the best reservation slot for a new VM. A slot is usable if it has any remaining memory (overfill is allowed: the VM may exceed the slot's remaining capacity, with the overflow covered by the host's free capacity which the pipeline already verified). Selection: maximise coverage (min(remMem, vmMemoryBytes)), tiebreak by smallest remaining memory (tightest fit), then reservation name. Returns the slot name, or "" if no slot has any remaining memory.
func ReservationRemainingMemory ¶
func ReservationRemainingMemory(res v1alpha1.Reservation) int64
ReservationRemainingMemory returns how many bytes of memory remain unallocated in a reservation slot. Returns 0 if the slot is full or nil.
Types ¶
type Recorder ¶
type Recorder struct {
// Client is the Kubernetes client used to read and patch Reservation CRDs.
client.Client
// NoHostFoundCounter counts no-host-found results by CR slot outcome.
NoHostFoundCounter *prometheus.CounterVec
// PlacementCounter counts successful placements by CR slot outcome.
PlacementCounter *prometheus.CounterVec
}
Recorder receives scheduling outcomes and updates CR reservations and metrics accordingly.
func (*Recorder) RecordNoHostFound ¶
func (r *Recorder) RecordNoHostFound(ctx context.Context, decision *v1alpha1.Decision, request api.ExternalSchedulerRequest)
RecordNoHostFound classifies a no-host-found result and emits a log line and metric.
func (*Recorder) RecordPlacement ¶
func (r *Recorder) RecordPlacement(ctx context.Context, decision *v1alpha1.Decision, request api.ExternalSchedulerRequest)
RecordPlacement writes the placed VM UUID into the matching Reservation slot and emits placement metrics. Called after a successful Nova placement.
type SlotEvaluator ¶
type SlotEvaluator struct {
// contains filtered or unexported fields
}
SlotEvaluator provides post-pipeline evaluation of CR reservation slots. Build once per request from HV and Reservation CRDs; query without further reads.
func BuildSlotEvaluator ¶
BuildSlotEvaluator lists HV CRDs and CR Reservation CRDs once and returns an evaluator that can answer slot-usability queries without further K8s reads.
func (*SlotEvaluator) HasUsableSlot ¶
func (e *SlotEvaluator) HasUsableSlot(hostName, projectID, flavorGroup string, vmMemBytes int64) bool
HasUsableSlot reports whether hostName has at least one CR slot that can accommodate a VM of vmMemBytes under the overfill model:
slot.remaining + host.base_free >= vmMemBytes
where host.base_free = hvFreeMemory[host] - sum(all reservation blocks on host). On happy-path candidates the pipeline already guarantees host capacity, so this simplifies to slot.remaining > 0 — but the full formula is evaluated regardless.
func (*SlotEvaluator) SlotsForHost ¶
func (e *SlotEvaluator) SlotsForHost(hostName, projectID, flavorGroup string) []v1alpha1.Reservation
SlotsForHost returns all CR reservation slots on hostName matching projectID + flavorGroup.