weighers

package
v0.0.0-...-e625038 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Index = map[string]func() NovaWeigher{}

Configuration of weighers supported by the nova scheduler.

Functions

This section is empty.

Types

type KVMBinpackStep

type KVMBinpackStep struct {
	// Base weigher providing common functionality.
	lib.BaseWeigher[api.ExternalSchedulerRequest, KVMBinpackStepOpts]
}

This step implements a binpacking weigher for workloads on kvm hypervisors. It pulls the requested vm into the smallest gaps possible, to ensure other hosts with less allocation stay free for bigger vms. Explanation of the algorithm: https://volcano.sh/en/docs/plugins/#binpack

func (*KVMBinpackStep) Run

Run this weigher in the pipeline after filters have been executed.

type KVMBinpackStepOpts

type KVMBinpackStepOpts struct {
	// ResourceWeights allows configuring the weight for each resource type when
	// calculating the binpacking score. The score is a weighted average of the
	// node's resource utilizations after placing the VM.
	// If a resource is not specified, is ignored in the score calculation
	// (equivalent to a weight of 0).
	ResourceWeights map[hv1.ResourceName]float64 `json:"resourceWeights"`
}

func (KVMBinpackStepOpts) Validate

func (o KVMBinpackStepOpts) Validate() error

Validate the options to ensure they are correct before running the weigher.

type KVMFailoverEvacuationOpts

type KVMFailoverEvacuationOpts struct {
	// Weight to assign to hosts that match a failover reservation for the VM.
	// Default: 1.0
	FailoverHostWeight *float64 `json:"failoverHostWeight,omitempty"`
	// Weight to assign to hosts that don't match a failover reservation.
	// Default: 0.1
	DefaultHostWeight *float64 `json:"defaultHostWeight,omitempty"`
}

Options for the KVM failover evacuation weigher.

func (KVMFailoverEvacuationOpts) GetDefaultHostWeight

func (o KVMFailoverEvacuationOpts) GetDefaultHostWeight() float64

func (KVMFailoverEvacuationOpts) GetFailoverHostWeight

func (o KVMFailoverEvacuationOpts) GetFailoverHostWeight() float64

func (KVMFailoverEvacuationOpts) Validate

func (o KVMFailoverEvacuationOpts) Validate() error

type KVMFailoverEvacuationStep

type KVMFailoverEvacuationStep struct {
	lib.BaseWeigher[api.ExternalSchedulerRequest, KVMFailoverEvacuationOpts]
}

KVMFailoverEvacuationStep weighs hosts based on failover reservations. Hosts that match a failover reservation for the VM being scheduled get a higher weight, encouraging placement on pre-reserved failover capacity.

func (*KVMFailoverEvacuationStep) Run

Run the weigher step. For evacuation requests, hosts matching a failover reservation where the VM is in Allocations get a higher weight. For non-evacuation requests (e.g., live migration, rebuild), this weigher has no effect.

type KVMFailoverReservationConsolidationOpts

type KVMFailoverReservationConsolidationOpts struct {
	// Weight multiplier for the total failover reservation count per host (consolidation signal).
	// Higher values more aggressively pack failover reservations onto fewer hosts.
	// Default: 1.0
	TotalCountWeight *float64 `json:"totalCountWeight,omitempty"`
	// Penalty multiplier for same-spec reservation count per host (diversity signal).
	// Higher values more aggressively avoid clustering reservations of the same size on one host.
	// Should be less than TotalCountWeight to ensure consolidation is the primary goal.
	// Default: 0.1
	SameSpecPenalty *float64 `json:"sameSpecPenalty,omitempty"`
}

Options for the KVM failover reservation consolidation weigher.

func (KVMFailoverReservationConsolidationOpts) GetSameSpecPenalty

func (o KVMFailoverReservationConsolidationOpts) GetSameSpecPenalty() float64

func (KVMFailoverReservationConsolidationOpts) GetTotalCountWeight

func (o KVMFailoverReservationConsolidationOpts) GetTotalCountWeight() float64

func (KVMFailoverReservationConsolidationOpts) Validate

type KVMFailoverReservationConsolidationStep

type KVMFailoverReservationConsolidationStep struct {
	lib.BaseWeigher[api.ExternalSchedulerRequest, KVMFailoverReservationConsolidationOpts]
}

KVMFailoverReservationConsolidationStep weighs hosts for failover reservation placement. It encourages consolidating failover reservations onto as few hosts as possible (primary goal), while preferring hosts with fewer reservations of the same ResourceGroup (secondary tiebreaker).

The ResourceGroup is passed via the scheduler hint "_cortex_resource_group" and compared against each existing reservation's Spec.FailoverReservation.ResourceGroup. This groups reservations by flavor group (or individual flavor name when no group exists).

Score formula (normalized by total reservation count T):

score = (totalCountWeight / T) × hostCount - (sameSpecPenalty / T) × sameGroupCount

This produces bounded output (~0 to 1) that plays nicely with other weighers.

func (*KVMFailoverReservationConsolidationStep) Run

Run the weigher step. For reserve_for_failover requests, hosts are scored based on existing failover reservation density and same-spec diversity. For all other request types, this weigher has no effect.

type KVMInstanceGroupSoftAffinityStep

type KVMInstanceGroupSoftAffinityStep struct {
	lib.BaseWeigher[api.ExternalSchedulerRequest, lib.EmptyFilterWeigherPipelineStepOpts]
}

This weigher implements the "soft affinity" and "soft anti-affinity" policy for instance groups in nova.

It assigns a weight to each host based on how many instances of the same instance group are already running on that host. The more instances of the same group on a host, the lower (for soft-anti-affinity) or higher (for soft-affinity) the weight, which makes it less likely or more likely, respectively, for the scheduler to choose that host for new instances of the same group.

func (*KVMInstanceGroupSoftAffinityStep) Run

type KVMPreferSmallerHostsStep

type KVMPreferSmallerHostsStep struct {
	// Base weigher providing common functionality.
	lib.BaseWeigher[api.ExternalSchedulerRequest, KVMPreferSmallerHostsStepOpts]
}

This step pulls virtual machines onto smaller hosts (by capacity). This ensures that larger hosts are not overly fragmented with small VMs, and can still accommodate larger VMs when they need to be scheduled.

func (*KVMPreferSmallerHostsStep) Run

Run this weigher in the pipeline after filters have been executed.

type KVMPreferSmallerHostsStepOpts

type KVMPreferSmallerHostsStepOpts struct {
	// ResourceWeights allows configuring the weight for each resource type when
	// calculating the small host preference score. The score is a weighted average
	// of the normalized distances from the smallest capacity for each resource.
	// If a resource is not specified, it is ignored in the score calculation
	// (equivalent to a weight of 0).
	ResourceWeights map[hv1.ResourceName]float64 `json:"resourceWeights"`
}

func (KVMPreferSmallerHostsStepOpts) Validate

func (o KVMPreferSmallerHostsStepOpts) Validate() error

Validate the options to ensure they are correct before running the weigher.

type VMwareAntiAffinityNoisyProjectsStep

type VMwareAntiAffinityNoisyProjectsStep struct {
	// BaseStep is a helper struct that provides common functionality for all steps.
	lib.BaseWeigher[api.ExternalSchedulerRequest, VMwareAntiAffinityNoisyProjectsStepOpts]
}

Step to avoid noisy projects by downvoting the hosts they are running on.

func (*VMwareAntiAffinityNoisyProjectsStep) Init

Initialize the step and validate that all required knowledges are ready.

func (*VMwareAntiAffinityNoisyProjectsStep) Run

Downvote the hosts a project is currently running on if it's noisy.

type VMwareAntiAffinityNoisyProjectsStepOpts

type VMwareAntiAffinityNoisyProjectsStepOpts struct {
	AvgCPUUsageLowerBound float64 `json:"avgCPUUsageLowerBound"` // -> mapped to ActivationLowerBound
	AvgCPUUsageUpperBound float64 `json:"avgCPUUsageUpperBound"` // -> mapped to ActivationUpperBound

	AvgCPUUsageActivationLowerBound float64 `json:"avgCPUUsageActivationLowerBound"`
	AvgCPUUsageActivationUpperBound float64 `json:"avgCPUUsageActivationUpperBound"`
}

Options for the scheduling step, given through the step config in the service yaml file. Use the options contained in this struct to configure the bounds for min-max scaling.

func (VMwareAntiAffinityNoisyProjectsStepOpts) Validate

type VMwareAvoidLongTermContendedHostsStep

type VMwareAvoidLongTermContendedHostsStep struct {
	// BaseStep is a helper struct that provides common functionality for all steps.
	lib.BaseWeigher[api.ExternalSchedulerRequest, VMwareAvoidLongTermContendedHostsStepOpts]
}

Step to avoid long term contended hosts by downvoting them.

func (*VMwareAvoidLongTermContendedHostsStep) Init

Initialize the step and validate that all required knowledges are ready.

func (*VMwareAvoidLongTermContendedHostsStep) Run

Downvote hosts that are highly contended.

type VMwareAvoidLongTermContendedHostsStepOpts

type VMwareAvoidLongTermContendedHostsStepOpts struct {
	AvgCPUContentionLowerBound float64 `json:"avgCPUContentionLowerBound"` // -> mapped to ActivationLowerBound
	AvgCPUContentionUpperBound float64 `json:"avgCPUContentionUpperBound"` // -> mapped to ActivationUpperBound

	AvgCPUContentionActivationLowerBound float64 `json:"avgCPUContentionActivationLowerBound"`
	AvgCPUContentionActivationUpperBound float64 `json:"avgCPUContentionActivationUpperBound"`

	MaxCPUContentionLowerBound float64 `json:"maxCPUContentionLowerBound"` // -> mapped to ActivationLowerBound
	MaxCPUContentionUpperBound float64 `json:"maxCPUContentionUpperBound"` // -> mapped to ActivationUpperBound

	MaxCPUContentionActivationLowerBound float64 `json:"maxCPUContentionActivationLowerBound"`
	MaxCPUContentionActivationUpperBound float64 `json:"maxCPUContentionActivationUpperBound"`
}

Options for the scheduling step, given through the step config in the service yaml file.

func (VMwareAvoidLongTermContendedHostsStepOpts) Validate

type VMwareAvoidShortTermContendedHostsStep

type VMwareAvoidShortTermContendedHostsStep struct {
	// BaseStep is a helper struct that provides common functionality for all steps.
	lib.BaseWeigher[api.ExternalSchedulerRequest, VMwareAvoidShortTermContendedHostsStepOpts]
}

Step to avoid recently contended hosts by downvoting them.

func (*VMwareAvoidShortTermContendedHostsStep) Init

Initialize the step and validate that all required knowledges are ready.

func (*VMwareAvoidShortTermContendedHostsStep) Run

Downvote hosts that are highly contended.

type VMwareAvoidShortTermContendedHostsStepOpts

type VMwareAvoidShortTermContendedHostsStepOpts struct {
	AvgCPUContentionLowerBound float64 `json:"avgCPUContentionLowerBound"` // -> mapped to ActivationLowerBound
	AvgCPUContentionUpperBound float64 `json:"avgCPUContentionUpperBound"` // -> mapped to ActivationUpperBound

	AvgCPUContentionActivationLowerBound float64 `json:"avgCPUContentionActivationLowerBound"`
	AvgCPUContentionActivationUpperBound float64 `json:"avgCPUContentionActivationUpperBound"`

	MaxCPUContentionLowerBound float64 `json:"maxCPUContentionLowerBound"` // -> mapped to ActivationLowerBound
	MaxCPUContentionUpperBound float64 `json:"maxCPUContentionUpperBound"` // -> mapped to ActivationUpperBound

	MaxCPUContentionActivationLowerBound float64 `json:"maxCPUContentionActivationLowerBound"`
	MaxCPUContentionActivationUpperBound float64 `json:"maxCPUContentionActivationUpperBound"`
}

Options for the scheduling step, given through the step config in the service yaml file.

func (VMwareAvoidShortTermContendedHostsStepOpts) Validate

type VMwareBinpackStep

type VMwareBinpackStep struct {
	// Base weigher providing common functionality.
	lib.BaseWeigher[api.ExternalSchedulerRequest, VMwareBinpackStepOpts]
}

This step implements a binpacking weigher for workloads on vmware hypervisors. It pulls the requested vm into the smallest gaps possible, to ensure other hosts with less allocation stay free for bigger vms. Explanation of the algorithm: https://volcano.sh/en/docs/plugins/#binpack

func (*VMwareBinpackStep) Init

func (s *VMwareBinpackStep) Init(ctx context.Context, client client.Client, weigher v1alpha1.WeigherSpec) error

Initialize the step and validate that all required knowledges are ready.

func (*VMwareBinpackStep) Run

Run this weigher in the pipeline after filters have been executed.

type VMwareBinpackStepOpts

type VMwareBinpackStepOpts struct {
	// ResourceWeights allows configuring the weight for each resource type when
	// calculating the binpacking score. The score is a weighted average of the
	// node's resource utilizations after placing the VM.
	// If a resource is not specified, is ignored in the score calculation
	// (equivalent to a weight of 0).
	ResourceWeights map[corev1.ResourceName]float64 `json:"resourceWeights"`
}

func (VMwareBinpackStepOpts) Validate

func (o VMwareBinpackStepOpts) Validate() error

Validate the options to ensure they are correct before running the weigher.

Jump to

Keyboard shortcuts

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