Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions helm/bundles/cortex-nova/templates/pipelines_kvm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ spec:
the migrating VM, by checking cpu architecture, cpu features, emulated
devices, and cpu modes.
- name: filter_requested_destination
params: {{ .Values.kvm.filterRequestedDestinationParams | toYaml | nindent 8 }}
description: |
This step filters hosts based on the `requested_destination` instruction
from the nova scheduler request spec. It supports filtering by host and
by aggregates.
by aggregates. Aggregates use AND logic between list elements, with
comma-separated UUIDs within an element using OR logic.
weighers:
- name: kvm_prefer_smaller_hosts
params:
Expand Down Expand Up @@ -236,11 +236,11 @@ spec:
the migrating VM, by checking cpu architecture, cpu features, emulated
devices, and cpu modes.
- name: filter_requested_destination
params: {{ .Values.kvm.filterRequestedDestinationParams | toYaml | nindent 8 }}
description: |
This step filters hosts based on the `requested_destination` instruction
from the nova scheduler request spec. It supports filtering by host and
by aggregates.
by aggregates. Aggregates use AND logic between list elements, with
comma-separated UUIDs within an element using OR logic.
weighers:
- name: kvm_prefer_smaller_hosts
params:
Expand Down Expand Up @@ -362,11 +362,11 @@ spec:
the migrating VM, by checking cpu architecture, cpu features, emulated
devices, and cpu modes.
- name: filter_requested_destination
params: {{ .Values.kvm.filterRequestedDestinationParams | toYaml | nindent 8 }}
description: |
This step filters hosts based on the `requested_destination` instruction
from the nova scheduler request spec. It supports filtering by host and
by aggregates.
by aggregates. Aggregates use AND logic between list elements, with
comma-separated UUIDs within an element using OR logic.
weighers:
- name: kvm_prefer_smaller_hosts
params:
Expand Down
6 changes: 0 additions & 6 deletions helm/bundles/cortex-nova/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ openstack:
kvm:
# Use this flag to enable/disable KVM host related features.
enabled: false
# Params for the filter_requested_destination filter step.
filterRequestedDestinationParams: []
# Example:
# filterRequestedDestinationParams:
# - {key: ignoredHostnames, stringListValue: []}
# - {key: ignoredAggregates, stringListValue: []}

cortex: &cortex
crd: {enable: false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,15 @@ import (
hv1 "github.com/cobaltcore-dev/openstack-hypervisor-operator/api/v1"
)

type FilterRequestedDestinationStepOpts struct {
// IgnoredAggregates specifies a list of aggregates to ignore when filtering
// hosts based on the requested destination. This can be used to exclude
// certain aggregates from consideration, for example AZ aggregates
// that are already considered by the availability zone filter.
IgnoredAggregates []string
// IgnoredHostnames specifies a list of hostnames to ignore when filtering
// hosts based on the requested destination. This can be used to exclude
// certain hosts from consideration, for example if they are known to be
// unsuitable for the workload.
IgnoredHostnames []string
}

// Validate the options to ensure they are correct before running the weigher.
func (o FilterRequestedDestinationStepOpts) Validate() error {
// No specific validation needed for this filter, but we could add checks here
// if we wanted to enforce certain constraints on the options.
return nil
}

type FilterRequestedDestinationStep struct {
lib.BaseFilter[api.ExternalSchedulerRequest, FilterRequestedDestinationStepOpts]
lib.BaseFilter[api.ExternalSchedulerRequest, lib.EmptyFilterWeigherPipelineStepOpts]
}

// processRequestedAggregates filters hosts based on the requested aggregates.
// The aggregates list uses AND logic between elements, meaning a host must match
// ALL elements to pass. Each element can contain comma-separated UUIDs which use
// OR logic, meaning the host only needs to match ONE of the UUIDs in that group.
// Example: ["agg1", "agg2,agg3"] means host must be in agg1 AND (agg2 OR agg3).
// Respects the IgnoredAggregates option and returns early without filtering
// if all requested aggregates are in the ignored list.
func (s *FilterRequestedDestinationStep) processRequestedAggregates(
traceLog *slog.Logger,
aggregates []string,
Expand All @@ -55,17 +33,6 @@ func (s *FilterRequestedDestinationStep) processRequestedAggregates(
if len(aggregates) == 0 {
return
}
// Filter out ignored aggregates
aggregatesToConsider := make([]string, 0, len(aggregates))
for _, agg := range aggregates {
if !slices.Contains(s.Options.IgnoredAggregates, agg) {
aggregatesToConsider = append(aggregatesToConsider, agg)
}
}
if len(aggregatesToConsider) == 0 {
traceLog.Info("all aggregates in requested_destination are in the ignored list, skipping aggregate filtering")
return
}
for host := range activations {
hv, exists := hvsByName[host]
if !exists {
Expand All @@ -80,7 +47,7 @@ func (s *FilterRequestedDestinationStep) processRequestedAggregates(
// All outer elements must match (AND logic)
// Each element can be comma-separated UUIDs (OR logic within the group)
allMatch := true
for _, reqAggGroup := range aggregatesToConsider {
for _, reqAggGroup := range aggregates {
reqAggs := strings.Split(reqAggGroup, ",")
groupMatch := false
for _, reqAgg := range reqAggs {
Expand All @@ -100,8 +67,6 @@ func (s *FilterRequestedDestinationStep) processRequestedAggregates(
"filtered out host not in requested_destination aggregates",
"host", host, "hostAggregates", hvAggregateUUIDs,
"requestedAggregates", aggregates,
"ignoredAggregates", s.Options.IgnoredAggregates,
"aggregatesConsidered", aggregatesToConsider,
)
continue
}
Expand All @@ -110,8 +75,7 @@ func (s *FilterRequestedDestinationStep) processRequestedAggregates(
}

// processRequestedHost filters hosts based on the requested specific host.
// It removes all hosts except the one matching the requested hostname,
// respecting the IgnoredHostnames option.
// It removes all hosts except the one matching the requested hostname.
func (s *FilterRequestedDestinationStep) processRequestedHost(
traceLog *slog.Logger,
host string,
Expand All @@ -122,10 +86,6 @@ func (s *FilterRequestedDestinationStep) processRequestedHost(
traceLog.Info("no specific host in requested_destination, skipping host filtering")
return
}
if slices.Contains(s.Options.IgnoredHostnames, host) {
traceLog.Info("requested_destination host is in the ignored hostnames list, skipping host filtering", "host", host)
return
}
for h := range activations {
if h != host {
delete(activations, h)
Expand All @@ -139,8 +99,7 @@ func (s *FilterRequestedDestinationStep) processRequestedHost(
// Run filters hosts based on the requested destination specified in the request.
// The requested destination can include a specific host, aggregates, or both.
// When both are specified, aggregate filtering is applied first, followed by
// host filtering. This filter respects the IgnoredAggregates and IgnoredHostnames
// options to skip filtering for specific aggregates or hosts.
// host filtering.
func (s *FilterRequestedDestinationStep) Run(traceLog *slog.Logger, request api.ExternalSchedulerRequest) (*lib.FilterWeigherPipelineStepResult, error) {
result := s.IncludeAllHostsFromRequest(request)
rd := request.Spec.Data.RequestedDestination
Expand Down
Loading
Loading