From b04ec9e711fe6af21040bf8fd115f07cb27e5a5f Mon Sep 17 00:00:00 2001
From: Philipp Matthes
Date: Tue, 10 Mar 2026 13:01:51 +0100
Subject: [PATCH] Remove filter packed virtqueue
---
.../cortex-nova/templates/pipelines_kvm.yaml | 10 -
.../filters/filter_packed_virtqueue.go | 60 ---
.../filters/filter_packed_virtqueue_test.go | 510 ------------------
3 files changed, 580 deletions(-)
delete mode 100644 internal/scheduling/nova/plugins/filters/filter_packed_virtqueue.go
delete mode 100644 internal/scheduling/nova/plugins/filters/filter_packed_virtqueue_test.go
diff --git a/helm/bundles/cortex-nova/templates/pipelines_kvm.yaml b/helm/bundles/cortex-nova/templates/pipelines_kvm.yaml
index 815fed44..a17f75f5 100644
--- a/helm/bundles/cortex-nova/templates/pipelines_kvm.yaml
+++ b/helm/bundles/cortex-nova/templates/pipelines_kvm.yaml
@@ -151,11 +151,6 @@ spec:
`domain_name` scheduler hint from the nova request spec.
params:
- {key: domainNamePrefixes, stringListValue: ["iaas-"]}
- - name: filter_packed_virtqueue
- description: |
- If the flavor extra specs contain the `hw:virtio_packed_ring` key, or the
- image properties contain the `hw_virtio_packed_ring` key, this step will
- filter out hosts that do not have the `COMPUTE_NET_VIRTIO_PACKED` trait.
- name: filter_allowed_projects
description: |
This step filters hosts based on allowed projects defined in the
@@ -282,11 +277,6 @@ spec:
`domain_name` scheduler hint from the nova request spec.
params:
- {key: domainNamePrefixes, stringListValue: ["iaas-"]}
- - name: filter_packed_virtqueue
- description: |
- If the flavor extra specs contain the `hw:virtio_packed_ring` key, or the
- image properties contain the `hw_virtio_packed_ring` key, this step will
- filter out hosts that do not have the `COMPUTE_NET_VIRTIO_PACKED` trait.
- name: filter_allowed_projects
description: |
This step filters hosts based on allowed projects defined in the
diff --git a/internal/scheduling/nova/plugins/filters/filter_packed_virtqueue.go b/internal/scheduling/nova/plugins/filters/filter_packed_virtqueue.go
deleted file mode 100644
index dac317e5..00000000
--- a/internal/scheduling/nova/plugins/filters/filter_packed_virtqueue.go
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright SAP SE
-// SPDX-License-Identifier: Apache-2.0
-
-package filters
-
-import (
- "context"
- "log/slog"
- "slices"
-
- api "github.com/cobaltcore-dev/cortex/api/external/nova"
- "github.com/cobaltcore-dev/cortex/internal/scheduling/lib"
- hv1 "github.com/cobaltcore-dev/openstack-hypervisor-operator/api/v1"
-)
-
-type FilterPackedVirtqueueStep struct {
- lib.BaseFilter[api.ExternalSchedulerRequest, lib.EmptyFilterWeigherPipelineStepOpts]
-}
-
-// If requested, only get hosts with packed virtqueues.
-func (s *FilterPackedVirtqueueStep) Run(traceLog *slog.Logger, request api.ExternalSchedulerRequest) (*lib.FilterWeigherPipelineStepResult, error) {
- result := s.IncludeAllHostsFromRequest(request)
- // We don't care about the value.
- _, reqInSpecs := request.Spec.Data.Flavor.Data.ExtraSpecs["hw:virtio_packed_ring"]
- _, reqInProps := request.Spec.Data.Image.Data.Properties.Data["hw_virtio_packed_ring"]
- if !reqInSpecs && !reqInProps {
- traceLog.Info("no request for packed virtqueues, skipping filter")
- return result, nil // No packed virtqueue requested, nothing to filter.
- }
-
- hvs := &hv1.HypervisorList{}
- if err := s.Client.List(context.Background(), hvs); err != nil {
- traceLog.Error("failed to list hypervisors", "error", err)
- return nil, err
- }
- hvsWithTrait := make(map[string]struct{})
- for _, hv := range hvs.Items {
- traits := hv.Status.Traits
- traits = append(traits, hv.Spec.CustomTraits...)
- if !slices.Contains(traits, "COMPUTE_NET_VIRTIO_PACKED") {
- continue
- }
- hvsWithTrait[hv.Name] = struct{}{}
- }
-
- traceLog.Info("hosts with packed virtqueues", "hosts", hvsWithTrait)
- for host := range result.Activations {
- if _, ok := hvsWithTrait[host]; ok {
- traceLog.Info("host has packed virtqueues, keeping", "host", host)
- continue
- }
- delete(result.Activations, host)
- traceLog.Info("filtering host without packed virtqueues", "host", host)
- }
- return result, nil
-}
-
-func init() {
- Index["filter_packed_virtqueue"] = func() NovaFilter { return &FilterPackedVirtqueueStep{} }
-}
diff --git a/internal/scheduling/nova/plugins/filters/filter_packed_virtqueue_test.go b/internal/scheduling/nova/plugins/filters/filter_packed_virtqueue_test.go
deleted file mode 100644
index 82b68da8..00000000
--- a/internal/scheduling/nova/plugins/filters/filter_packed_virtqueue_test.go
+++ /dev/null
@@ -1,510 +0,0 @@
-// Copyright SAP SE
-// SPDX-License-Identifier: Apache-2.0
-
-package filters
-
-import (
- "log/slog"
- "testing"
-
- api "github.com/cobaltcore-dev/cortex/api/external/nova"
- hv1 "github.com/cobaltcore-dev/openstack-hypervisor-operator/api/v1"
- v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/client/fake"
-)
-
-func TestFilterPackedVirtqueueStep_Run(t *testing.T) {
- scheme, err := hv1.SchemeBuilder.Build()
- if err != nil {
- t.Fatalf("expected no error, got %v", err)
- }
-
- hvs := []client.Object{
- &hv1.Hypervisor{
- ObjectMeta: v1.ObjectMeta{
- Name: "host1",
- },
- Status: hv1.HypervisorStatus{
- Traits: []string{"COMPUTE_NET_VIRTIO_PACKED"},
- },
- },
- &hv1.Hypervisor{
- ObjectMeta: v1.ObjectMeta{
- Name: "host2",
- },
- Status: hv1.HypervisorStatus{
- Traits: []string{"COMPUTE_NET_VIRTIO_PACKED", "SOME_OTHER_TRAIT"},
- },
- },
- &hv1.Hypervisor{
- ObjectMeta: v1.ObjectMeta{
- Name: "host3",
- },
- Status: hv1.HypervisorStatus{
- Traits: []string{"SOME_OTHER_TRAIT"},
- },
- },
- &hv1.Hypervisor{
- ObjectMeta: v1.ObjectMeta{
- Name: "host4",
- },
- Status: hv1.HypervisorStatus{
- Traits: []string{},
- },
- },
- }
-
- tests := []struct {
- name string
- request api.ExternalSchedulerRequest
- expectedHosts []string
- filteredHosts []string
- }{
- {
- name: "No packed virtqueue requested - all hosts pass",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{},
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{},
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{
- {ComputeHost: "host1"},
- {ComputeHost: "host2"},
- {ComputeHost: "host3"},
- {ComputeHost: "host4"},
- },
- },
- expectedHosts: []string{"host1", "host2", "host3", "host4"},
- filteredHosts: []string{},
- },
- {
- name: "Packed virtqueue requested in flavor extra specs",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{
- "hw:virtio_packed_ring": "true",
- },
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{},
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{
- {ComputeHost: "host1"},
- {ComputeHost: "host2"},
- {ComputeHost: "host3"},
- {ComputeHost: "host4"},
- },
- },
- expectedHosts: []string{"host1", "host2"},
- filteredHosts: []string{"host3", "host4"},
- },
- {
- name: "Packed virtqueue requested in image properties",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{},
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{
- "hw_virtio_packed_ring": "true",
- },
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{
- {ComputeHost: "host1"},
- {ComputeHost: "host2"},
- {ComputeHost: "host3"},
- {ComputeHost: "host4"},
- },
- },
- expectedHosts: []string{"host1", "host2"},
- filteredHosts: []string{"host3", "host4"},
- },
- {
- name: "Packed virtqueue requested in both flavor and image",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{
- "hw:virtio_packed_ring": "true",
- },
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{
- "hw_virtio_packed_ring": "true",
- },
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{
- {ComputeHost: "host1"},
- {ComputeHost: "host3"},
- },
- },
- expectedHosts: []string{"host1"},
- filteredHosts: []string{"host3"},
- },
- {
- name: "Packed virtqueue with false value in flavor - still triggers filter",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{
- "hw:virtio_packed_ring": "false",
- },
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{},
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{
- {ComputeHost: "host1"},
- {ComputeHost: "host2"},
- {ComputeHost: "host3"},
- },
- },
- expectedHosts: []string{"host1", "host2"},
- filteredHosts: []string{"host3"},
- },
- {
- name: "Packed virtqueue with empty value in image - still triggers filter",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{},
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{
- "hw_virtio_packed_ring": "",
- },
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{
- {ComputeHost: "host1"},
- {ComputeHost: "host4"},
- },
- },
- expectedHosts: []string{"host1"},
- filteredHosts: []string{"host4"},
- },
- {
- name: "No hosts with trait - all filtered",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{
- "hw:virtio_packed_ring": "true",
- },
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{},
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{
- {ComputeHost: "host3"},
- {ComputeHost: "host4"},
- },
- },
- expectedHosts: []string{},
- filteredHosts: []string{"host3", "host4"},
- },
- {
- name: "All hosts have trait",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{
- "hw:virtio_packed_ring": "true",
- },
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{},
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{
- {ComputeHost: "host1"},
- {ComputeHost: "host2"},
- },
- },
- expectedHosts: []string{"host1", "host2"},
- filteredHosts: []string{},
- },
- {
- name: "Empty host list with packed virtqueue requested",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{
- "hw:virtio_packed_ring": "true",
- },
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{},
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{},
- },
- expectedHosts: []string{},
- filteredHosts: []string{},
- },
- {
- name: "Empty host list without packed virtqueue requested",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{},
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{},
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{},
- },
- expectedHosts: []string{},
- filteredHosts: []string{},
- },
- {
- name: "Host not in database with packed virtqueue requested",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{
- "hw:virtio_packed_ring": "true",
- },
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{},
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{
- {ComputeHost: "host1"},
- {ComputeHost: "host-unknown"},
- },
- },
- expectedHosts: []string{"host1"},
- filteredHosts: []string{"host-unknown"},
- },
- {
- name: "Packed virtqueue with additional extra specs",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{
- "hw:virtio_packed_ring": "true",
- "hw:cpu_policy": "dedicated",
- "hw:mem_page_size": "large",
- },
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{},
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{
- {ComputeHost: "host1"},
- {ComputeHost: "host3"},
- },
- },
- expectedHosts: []string{"host1"},
- filteredHosts: []string{"host3"},
- },
- {
- name: "Mixed hosts with and without trait",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{
- "hw:virtio_packed_ring": "true",
- },
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{},
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{
- {ComputeHost: "host1"},
- {ComputeHost: "host2"},
- {ComputeHost: "host3"},
- {ComputeHost: "host4"},
- },
- },
- expectedHosts: []string{"host1", "host2"},
- filteredHosts: []string{"host3", "host4"},
- },
- {
- name: "Image property with additional properties",
- request: api.ExternalSchedulerRequest{
- Spec: api.NovaObject[api.NovaSpec]{
- Data: api.NovaSpec{
- Flavor: api.NovaObject[api.NovaFlavor]{
- Data: api.NovaFlavor{
- ExtraSpecs: map[string]string{},
- },
- },
- Image: api.NovaObject[api.NovaImageMeta]{
- Data: api.NovaImageMeta{
- Properties: api.NovaObject[map[string]any]{
- Data: map[string]any{
- "hw_virtio_packed_ring": "true",
- "hw_disk_bus": "virtio",
- "hw_vif_model": "virtio",
- },
- },
- },
- },
- },
- },
- Hosts: []api.ExternalSchedulerHost{
- {ComputeHost: "host2"},
- {ComputeHost: "host4"},
- },
- },
- expectedHosts: []string{"host2"},
- filteredHosts: []string{"host4"},
- },
- }
-
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- step := &FilterPackedVirtqueueStep{}
- step.Client = fake.NewClientBuilder().
- WithScheme(scheme).
- WithObjects(hvs...).
- Build()
-
- result, err := step.Run(slog.Default(), tt.request)
- if err != nil {
- t.Fatalf("expected no error, got %v", err)
- }
-
- // Check expected hosts are present
- for _, host := range tt.expectedHosts {
- if _, ok := result.Activations[host]; !ok {
- t.Errorf("expected host %s to be present in activations", host)
- }
- }
-
- // Check filtered hosts are not present
- for _, host := range tt.filteredHosts {
- if _, ok := result.Activations[host]; ok {
- t.Errorf("expected host %s to be filtered out", host)
- }
- }
-
- // Check total count
- if len(result.Activations) != len(tt.expectedHosts) {
- t.Errorf("expected %d hosts, got %d", len(tt.expectedHosts), len(result.Activations))
- }
- })
- }
-}