diff --git a/cmd/main.go b/cmd/main.go index 0bb89168a..cad93b9a1 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -34,8 +34,8 @@ import ( ironcorev1alpha1 "github.com/cobaltcore-dev/cortex/api/delegation/ironcore/v1alpha1" "github.com/cobaltcore-dev/cortex/api/v1alpha1" "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/prometheus" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/prometheus" "github.com/cobaltcore-dev/cortex/internal/knowledge/extractor" "github.com/cobaltcore-dev/cortex/internal/knowledge/kpis" "github.com/cobaltcore-dev/cortex/internal/scheduling/cinder" diff --git a/dist/chart/Chart.yaml b/dist/chart/Chart.yaml index 865e87880..9948da250 100644 --- a/dist/chart/Chart.yaml +++ b/dist/chart/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: cortex description: A Helm chart to distribute cortex. type: application -version: 0.0.10 -appVersion: "sha-d731bc90" +version: 0.0.11 +appVersion: "sha-53e63ba9" icon: "https://example.com/icon.png" dependencies: [] diff --git a/dist/chart/templates/rbac/role.yaml b/dist/chart/templates/rbac/role.yaml index bb6e95626..c01ab9062 100644 --- a/dist/chart/templates/rbac/role.yaml +++ b/dist/chart/templates/rbac/role.yaml @@ -15,7 +15,6 @@ rules: - reservations - decisions - deschedulings - - steps - pipelines - kpis verbs: @@ -34,7 +33,6 @@ rules: - reservations/finalizers - decisions/finalizers - deschedulings/finalizers - - steps/finalizers - pipelines/finalizers - kpis/finalizers verbs: @@ -47,7 +45,6 @@ rules: - reservations/status - decisions/status - deschedulings/status - - steps/status - pipelines/status - kpis/status verbs: diff --git a/helm/bundles/cortex-cinder/Chart.yaml b/helm/bundles/cortex-cinder/Chart.yaml index e6b4110d2..db63b3857 100644 --- a/helm/bundles/cortex-cinder/Chart.yaml +++ b/helm/bundles/cortex-cinder/Chart.yaml @@ -5,23 +5,23 @@ apiVersion: v2 name: cortex-cinder description: A Helm chart deploying Cortex for Cinder. type: application -version: 0.0.23 +version: 0.0.24 appVersion: 0.1.0 dependencies: # from: file://../../library/cortex-postgres - name: cortex-postgres repository: oci://ghcr.io/cobaltcore-dev/cortex/charts - version: 0.5.7 + version: 0.5.8 # from: file://../../../dist/chart - name: cortex repository: oci://ghcr.io/cobaltcore-dev/cortex/charts - version: 0.0.10 + version: 0.0.11 alias: cortex-knowledge-controllers # from: file://../../../dist/chart - name: cortex repository: oci://ghcr.io/cobaltcore-dev/cortex/charts - version: 0.0.10 + version: 0.0.11 alias: cortex-scheduling-controllers # Owner info adds a configmap to the kubernetes cluster with information on diff --git a/helm/bundles/cortex-crds/Chart.yaml b/helm/bundles/cortex-crds/Chart.yaml index 6cb66caf0..698c07a04 100644 --- a/helm/bundles/cortex-crds/Chart.yaml +++ b/helm/bundles/cortex-crds/Chart.yaml @@ -5,13 +5,13 @@ apiVersion: v2 name: cortex-crds description: A Helm chart deploying Cortex CRDs. type: application -version: 0.0.23 +version: 0.0.24 appVersion: 0.1.0 dependencies: # from: file://../../../dist/chart - name: cortex repository: oci://ghcr.io/cobaltcore-dev/cortex/charts - version: 0.0.10 + version: 0.0.11 # Owner info adds a configmap to the kubernetes cluster with information on # the service owner. This makes it easier to find out who to contact in case diff --git a/helm/bundles/cortex-ironcore/Chart.yaml b/helm/bundles/cortex-ironcore/Chart.yaml index 069d4fa0c..82fada699 100644 --- a/helm/bundles/cortex-ironcore/Chart.yaml +++ b/helm/bundles/cortex-ironcore/Chart.yaml @@ -5,13 +5,13 @@ apiVersion: v2 name: cortex-ironcore description: A Helm chart deploying Cortex for IronCore. type: application -version: 0.0.23 +version: 0.0.24 appVersion: 0.1.0 dependencies: # from: file://../../../dist/chart - name: cortex repository: oci://ghcr.io/cobaltcore-dev/cortex/charts - version: 0.0.10 + version: 0.0.11 # Owner info adds a configmap to the kubernetes cluster with information on # the service owner. This makes it easier to find out who to contact in case diff --git a/helm/bundles/cortex-manila/Chart.yaml b/helm/bundles/cortex-manila/Chart.yaml index 2dba1f129..4107d6ca6 100644 --- a/helm/bundles/cortex-manila/Chart.yaml +++ b/helm/bundles/cortex-manila/Chart.yaml @@ -5,23 +5,23 @@ apiVersion: v2 name: cortex-manila description: A Helm chart deploying Cortex for Manila. type: application -version: 0.0.23 +version: 0.0.24 appVersion: 0.1.0 dependencies: # from: file://../../library/cortex-postgres - name: cortex-postgres repository: oci://ghcr.io/cobaltcore-dev/cortex/charts - version: 0.5.7 + version: 0.5.8 # from: file://../../../dist/chart - name: cortex repository: oci://ghcr.io/cobaltcore-dev/cortex/charts - version: 0.0.10 + version: 0.0.11 alias: cortex-knowledge-controllers # from: file://../../../dist/chart - name: cortex repository: oci://ghcr.io/cobaltcore-dev/cortex/charts - version: 0.0.10 + version: 0.0.11 alias: cortex-scheduling-controllers # Owner info adds a configmap to the kubernetes cluster with information on diff --git a/helm/bundles/cortex-nova/Chart.yaml b/helm/bundles/cortex-nova/Chart.yaml index 6fd9c08bb..a84e9713b 100644 --- a/helm/bundles/cortex-nova/Chart.yaml +++ b/helm/bundles/cortex-nova/Chart.yaml @@ -5,23 +5,23 @@ apiVersion: v2 name: cortex-nova description: A Helm chart deploying Cortex for Nova. type: application -version: 0.0.23 +version: 0.0.24 appVersion: 0.1.0 dependencies: # from: file://../../library/cortex-postgres - name: cortex-postgres repository: oci://ghcr.io/cobaltcore-dev/cortex/charts - version: 0.5.7 + version: 0.5.8 # from: file://../../../dist/chart - name: cortex repository: oci://ghcr.io/cobaltcore-dev/cortex/charts - version: 0.0.10 + version: 0.0.11 alias: cortex-knowledge-controllers # from: file://../../../dist/chart - name: cortex repository: oci://ghcr.io/cobaltcore-dev/cortex/charts - version: 0.0.10 + version: 0.0.11 alias: cortex-scheduling-controllers # Owner info adds a configmap to the kubernetes cluster with information on diff --git a/helm/bundles/cortex-pods/Chart.yaml b/helm/bundles/cortex-pods/Chart.yaml index 9e15c0fd4..34cbcaad2 100644 --- a/helm/bundles/cortex-pods/Chart.yaml +++ b/helm/bundles/cortex-pods/Chart.yaml @@ -11,7 +11,7 @@ dependencies: # from: file://../../../dist/chart - name: cortex repository: oci://ghcr.io/cobaltcore-dev/cortex/charts - version: 0.0.10 + version: 0.0.11 # Owner info adds a configmap to the kubernetes cluster with information on # the service owner. This makes it easier to find out who to contact in case diff --git a/helm/library/cortex-postgres/Chart.yaml b/helm/library/cortex-postgres/Chart.yaml index 071e5358b..bf411feea 100644 --- a/helm/library/cortex-postgres/Chart.yaml +++ b/helm/library/cortex-postgres/Chart.yaml @@ -5,5 +5,5 @@ apiVersion: v2 name: cortex-postgres description: Postgres setup for Cortex. type: application -version: 0.5.7 -appVersion: "sha-55efebd" +version: 0.5.8 +appVersion: "sha-0c8d9290" diff --git a/internal/knowledge/datasources/openstack/cinder/cinder_api.go b/internal/knowledge/datasources/plugins/openstack/cinder/cinder_api.go similarity index 100% rename from internal/knowledge/datasources/openstack/cinder/cinder_api.go rename to internal/knowledge/datasources/plugins/openstack/cinder/cinder_api.go diff --git a/internal/knowledge/datasources/openstack/cinder/cinder_api_test.go b/internal/knowledge/datasources/plugins/openstack/cinder/cinder_api_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/cinder/cinder_api_test.go rename to internal/knowledge/datasources/plugins/openstack/cinder/cinder_api_test.go diff --git a/internal/knowledge/datasources/openstack/cinder/cinder_sync.go b/internal/knowledge/datasources/plugins/openstack/cinder/cinder_sync.go similarity index 100% rename from internal/knowledge/datasources/openstack/cinder/cinder_sync.go rename to internal/knowledge/datasources/plugins/openstack/cinder/cinder_sync.go diff --git a/internal/knowledge/datasources/openstack/cinder/cinder_sync_test.go b/internal/knowledge/datasources/plugins/openstack/cinder/cinder_sync_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/cinder/cinder_sync_test.go rename to internal/knowledge/datasources/plugins/openstack/cinder/cinder_sync_test.go diff --git a/internal/knowledge/datasources/openstack/cinder/cinder_types.go b/internal/knowledge/datasources/plugins/openstack/cinder/cinder_types.go similarity index 100% rename from internal/knowledge/datasources/openstack/cinder/cinder_types.go rename to internal/knowledge/datasources/plugins/openstack/cinder/cinder_types.go diff --git a/internal/knowledge/datasources/openstack/cinder/cinder_types_test.go b/internal/knowledge/datasources/plugins/openstack/cinder/cinder_types_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/cinder/cinder_types_test.go rename to internal/knowledge/datasources/plugins/openstack/cinder/cinder_types_test.go diff --git a/internal/knowledge/datasources/openstack/controller.go b/internal/knowledge/datasources/plugins/openstack/controller.go similarity index 100% rename from internal/knowledge/datasources/openstack/controller.go rename to internal/knowledge/datasources/plugins/openstack/controller.go diff --git a/internal/knowledge/datasources/openstack/controller_test.go b/internal/knowledge/datasources/plugins/openstack/controller_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/controller_test.go rename to internal/knowledge/datasources/plugins/openstack/controller_test.go diff --git a/internal/knowledge/datasources/openstack/identity/identity_api.go b/internal/knowledge/datasources/plugins/openstack/identity/identity_api.go similarity index 100% rename from internal/knowledge/datasources/openstack/identity/identity_api.go rename to internal/knowledge/datasources/plugins/openstack/identity/identity_api.go diff --git a/internal/knowledge/datasources/openstack/identity/identity_api_test.go b/internal/knowledge/datasources/plugins/openstack/identity/identity_api_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/identity/identity_api_test.go rename to internal/knowledge/datasources/plugins/openstack/identity/identity_api_test.go diff --git a/internal/knowledge/datasources/openstack/identity/identity_sync.go b/internal/knowledge/datasources/plugins/openstack/identity/identity_sync.go similarity index 100% rename from internal/knowledge/datasources/openstack/identity/identity_sync.go rename to internal/knowledge/datasources/plugins/openstack/identity/identity_sync.go diff --git a/internal/knowledge/datasources/openstack/identity/identity_sync_test.go b/internal/knowledge/datasources/plugins/openstack/identity/identity_sync_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/identity/identity_sync_test.go rename to internal/knowledge/datasources/plugins/openstack/identity/identity_sync_test.go diff --git a/internal/knowledge/datasources/openstack/identity/identity_types.go b/internal/knowledge/datasources/plugins/openstack/identity/identity_types.go similarity index 100% rename from internal/knowledge/datasources/openstack/identity/identity_types.go rename to internal/knowledge/datasources/plugins/openstack/identity/identity_types.go diff --git a/internal/knowledge/datasources/openstack/identity/identity_types_test.go b/internal/knowledge/datasources/plugins/openstack/identity/identity_types_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/identity/identity_types_test.go rename to internal/knowledge/datasources/plugins/openstack/identity/identity_types_test.go diff --git a/internal/knowledge/datasources/openstack/limes/limes_api.go b/internal/knowledge/datasources/plugins/openstack/limes/limes_api.go similarity index 99% rename from internal/knowledge/datasources/openstack/limes/limes_api.go rename to internal/knowledge/datasources/plugins/openstack/limes/limes_api.go index c1fd4df72..e24c74928 100644 --- a/internal/knowledge/datasources/openstack/limes/limes_api.go +++ b/internal/knowledge/datasources/plugins/openstack/limes/limes_api.go @@ -14,7 +14,7 @@ import ( "github.com/cobaltcore-dev/cortex/api/v1alpha1" "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/identity" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/identity" "github.com/cobaltcore-dev/cortex/pkg/keystone" "github.com/gophercloud/gophercloud/v2" "github.com/prometheus/client_golang/prometheus" diff --git a/internal/knowledge/datasources/openstack/limes/limes_api_test.go b/internal/knowledge/datasources/plugins/openstack/limes/limes_api_test.go similarity index 99% rename from internal/knowledge/datasources/openstack/limes/limes_api_test.go rename to internal/knowledge/datasources/plugins/openstack/limes/limes_api_test.go index 8f1acff5b..d7e5be069 100644 --- a/internal/knowledge/datasources/openstack/limes/limes_api_test.go +++ b/internal/knowledge/datasources/plugins/openstack/limes/limes_api_test.go @@ -10,7 +10,7 @@ import ( "github.com/cobaltcore-dev/cortex/api/v1alpha1" "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/identity" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/identity" "github.com/cobaltcore-dev/cortex/pkg/keystone" testlibKeystone "github.com/cobaltcore-dev/cortex/pkg/keystone/testing" ) diff --git a/internal/knowledge/datasources/openstack/limes/limes_sync.go b/internal/knowledge/datasources/plugins/openstack/limes/limes_sync.go similarity index 98% rename from internal/knowledge/datasources/openstack/limes/limes_sync.go rename to internal/knowledge/datasources/plugins/openstack/limes/limes_sync.go index db8adc283..e0011c6e2 100644 --- a/internal/knowledge/datasources/openstack/limes/limes_sync.go +++ b/internal/knowledge/datasources/plugins/openstack/limes/limes_sync.go @@ -8,7 +8,7 @@ import ( "github.com/cobaltcore-dev/cortex/api/v1alpha1" "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/identity" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/identity" "github.com/cobaltcore-dev/cortex/pkg/db" "github.com/go-gorp/gorp" ) diff --git a/internal/knowledge/datasources/openstack/limes/limes_sync_test.go b/internal/knowledge/datasources/plugins/openstack/limes/limes_sync_test.go similarity index 99% rename from internal/knowledge/datasources/openstack/limes/limes_sync_test.go rename to internal/knowledge/datasources/plugins/openstack/limes/limes_sync_test.go index def33ed24..04d83954c 100644 --- a/internal/knowledge/datasources/openstack/limes/limes_sync_test.go +++ b/internal/knowledge/datasources/plugins/openstack/limes/limes_sync_test.go @@ -10,7 +10,7 @@ import ( "github.com/cobaltcore-dev/cortex/api/v1alpha1" "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/identity" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/identity" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" testlibKeystone "github.com/cobaltcore-dev/cortex/pkg/keystone/testing" diff --git a/internal/knowledge/datasources/openstack/limes/limes_types.go b/internal/knowledge/datasources/plugins/openstack/limes/limes_types.go similarity index 100% rename from internal/knowledge/datasources/openstack/limes/limes_types.go rename to internal/knowledge/datasources/plugins/openstack/limes/limes_types.go diff --git a/internal/knowledge/datasources/openstack/limes/limes_types_test.go b/internal/knowledge/datasources/plugins/openstack/limes/limes_types_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/limes/limes_types_test.go rename to internal/knowledge/datasources/plugins/openstack/limes/limes_types_test.go diff --git a/internal/knowledge/datasources/openstack/manila/manila_api.go b/internal/knowledge/datasources/plugins/openstack/manila/manila_api.go similarity index 100% rename from internal/knowledge/datasources/openstack/manila/manila_api.go rename to internal/knowledge/datasources/plugins/openstack/manila/manila_api.go diff --git a/internal/knowledge/datasources/openstack/manila/manila_api_test.go b/internal/knowledge/datasources/plugins/openstack/manila/manila_api_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/manila/manila_api_test.go rename to internal/knowledge/datasources/plugins/openstack/manila/manila_api_test.go diff --git a/internal/knowledge/datasources/openstack/manila/manila_sync.go b/internal/knowledge/datasources/plugins/openstack/manila/manila_sync.go similarity index 100% rename from internal/knowledge/datasources/openstack/manila/manila_sync.go rename to internal/knowledge/datasources/plugins/openstack/manila/manila_sync.go diff --git a/internal/knowledge/datasources/openstack/manila/manila_sync_test.go b/internal/knowledge/datasources/plugins/openstack/manila/manila_sync_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/manila/manila_sync_test.go rename to internal/knowledge/datasources/plugins/openstack/manila/manila_sync_test.go diff --git a/internal/knowledge/datasources/openstack/manila/manila_types.go b/internal/knowledge/datasources/plugins/openstack/manila/manila_types.go similarity index 100% rename from internal/knowledge/datasources/openstack/manila/manila_types.go rename to internal/knowledge/datasources/plugins/openstack/manila/manila_types.go diff --git a/internal/knowledge/datasources/openstack/manila/manila_types_test.go b/internal/knowledge/datasources/plugins/openstack/manila/manila_types_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/manila/manila_types_test.go rename to internal/knowledge/datasources/plugins/openstack/manila/manila_types_test.go diff --git a/internal/knowledge/datasources/openstack/nova/nova_api.go b/internal/knowledge/datasources/plugins/openstack/nova/nova_api.go similarity index 100% rename from internal/knowledge/datasources/openstack/nova/nova_api.go rename to internal/knowledge/datasources/plugins/openstack/nova/nova_api.go diff --git a/internal/knowledge/datasources/openstack/nova/nova_api_test.go b/internal/knowledge/datasources/plugins/openstack/nova/nova_api_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/nova/nova_api_test.go rename to internal/knowledge/datasources/plugins/openstack/nova/nova_api_test.go diff --git a/internal/knowledge/datasources/openstack/nova/nova_sync.go b/internal/knowledge/datasources/plugins/openstack/nova/nova_sync.go similarity index 100% rename from internal/knowledge/datasources/openstack/nova/nova_sync.go rename to internal/knowledge/datasources/plugins/openstack/nova/nova_sync.go diff --git a/internal/knowledge/datasources/openstack/nova/nova_sync_test.go b/internal/knowledge/datasources/plugins/openstack/nova/nova_sync_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/nova/nova_sync_test.go rename to internal/knowledge/datasources/plugins/openstack/nova/nova_sync_test.go diff --git a/internal/knowledge/datasources/openstack/nova/nova_types.go b/internal/knowledge/datasources/plugins/openstack/nova/nova_types.go similarity index 100% rename from internal/knowledge/datasources/openstack/nova/nova_types.go rename to internal/knowledge/datasources/plugins/openstack/nova/nova_types.go diff --git a/internal/knowledge/datasources/openstack/nova/nova_types_test.go b/internal/knowledge/datasources/plugins/openstack/nova/nova_types_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/nova/nova_types_test.go rename to internal/knowledge/datasources/plugins/openstack/nova/nova_types_test.go diff --git a/internal/knowledge/datasources/openstack/placement/placement_api.go b/internal/knowledge/datasources/plugins/openstack/placement/placement_api.go similarity index 100% rename from internal/knowledge/datasources/openstack/placement/placement_api.go rename to internal/knowledge/datasources/plugins/openstack/placement/placement_api.go diff --git a/internal/knowledge/datasources/openstack/placement/placement_api_test.go b/internal/knowledge/datasources/plugins/openstack/placement/placement_api_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/placement/placement_api_test.go rename to internal/knowledge/datasources/plugins/openstack/placement/placement_api_test.go diff --git a/internal/knowledge/datasources/openstack/placement/placement_sync.go b/internal/knowledge/datasources/plugins/openstack/placement/placement_sync.go similarity index 100% rename from internal/knowledge/datasources/openstack/placement/placement_sync.go rename to internal/knowledge/datasources/plugins/openstack/placement/placement_sync.go diff --git a/internal/knowledge/datasources/openstack/placement/placement_sync_test.go b/internal/knowledge/datasources/plugins/openstack/placement/placement_sync_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/placement/placement_sync_test.go rename to internal/knowledge/datasources/plugins/openstack/placement/placement_sync_test.go diff --git a/internal/knowledge/datasources/openstack/placement/placement_types.go b/internal/knowledge/datasources/plugins/openstack/placement/placement_types.go similarity index 100% rename from internal/knowledge/datasources/openstack/placement/placement_types.go rename to internal/knowledge/datasources/plugins/openstack/placement/placement_types.go diff --git a/internal/knowledge/datasources/openstack/placement/placement_types_test.go b/internal/knowledge/datasources/plugins/openstack/placement/placement_types_test.go similarity index 100% rename from internal/knowledge/datasources/openstack/placement/placement_types_test.go rename to internal/knowledge/datasources/plugins/openstack/placement/placement_types_test.go diff --git a/internal/knowledge/datasources/openstack/supported_syncers.go b/internal/knowledge/datasources/plugins/openstack/supported_syncers.go similarity index 94% rename from internal/knowledge/datasources/openstack/supported_syncers.go rename to internal/knowledge/datasources/plugins/openstack/supported_syncers.go index 21886bfbe..232fff5a4 100644 --- a/internal/knowledge/datasources/openstack/supported_syncers.go +++ b/internal/knowledge/datasources/plugins/openstack/supported_syncers.go @@ -8,12 +8,12 @@ import ( "github.com/cobaltcore-dev/cortex/api/v1alpha1" "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/cinder" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/identity" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/limes" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/manila" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/placement" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/cinder" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/identity" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/limes" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/manila" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/placement" "github.com/cobaltcore-dev/cortex/pkg/db" "github.com/cobaltcore-dev/cortex/pkg/keystone" ) diff --git a/internal/knowledge/datasources/prometheus/controller.go b/internal/knowledge/datasources/plugins/prometheus/controller.go similarity index 100% rename from internal/knowledge/datasources/prometheus/controller.go rename to internal/knowledge/datasources/plugins/prometheus/controller.go diff --git a/internal/knowledge/datasources/prometheus/controller_test.go b/internal/knowledge/datasources/plugins/prometheus/controller_test.go similarity index 100% rename from internal/knowledge/datasources/prometheus/controller_test.go rename to internal/knowledge/datasources/plugins/prometheus/controller_test.go diff --git a/internal/knowledge/datasources/prometheus/supported_syncers.go b/internal/knowledge/datasources/plugins/prometheus/supported_syncers.go similarity index 100% rename from internal/knowledge/datasources/prometheus/supported_syncers.go rename to internal/knowledge/datasources/plugins/prometheus/supported_syncers.go diff --git a/internal/knowledge/datasources/prometheus/sync.go b/internal/knowledge/datasources/plugins/prometheus/sync.go similarity index 100% rename from internal/knowledge/datasources/prometheus/sync.go rename to internal/knowledge/datasources/plugins/prometheus/sync.go diff --git a/internal/knowledge/datasources/prometheus/sync_test.go b/internal/knowledge/datasources/plugins/prometheus/sync_test.go similarity index 100% rename from internal/knowledge/datasources/prometheus/sync_test.go rename to internal/knowledge/datasources/plugins/prometheus/sync_test.go diff --git a/internal/knowledge/datasources/prometheus/triggers.go b/internal/knowledge/datasources/plugins/prometheus/triggers.go similarity index 100% rename from internal/knowledge/datasources/prometheus/triggers.go rename to internal/knowledge/datasources/plugins/prometheus/triggers.go diff --git a/internal/knowledge/datasources/prometheus/types.go b/internal/knowledge/datasources/plugins/prometheus/types.go similarity index 100% rename from internal/knowledge/datasources/prometheus/types.go rename to internal/knowledge/datasources/plugins/prometheus/types.go diff --git a/internal/knowledge/datasources/prometheus/types_test.go b/internal/knowledge/datasources/plugins/prometheus/types_test.go similarity index 100% rename from internal/knowledge/datasources/prometheus/types_test.go rename to internal/knowledge/datasources/plugins/prometheus/types_test.go diff --git a/internal/knowledge/extractor/plugins/compute/host_az_test.go b/internal/knowledge/extractor/plugins/compute/host_az_test.go index 51c561a06..c20d03df2 100644 --- a/internal/knowledge/extractor/plugins/compute/host_az_test.go +++ b/internal/knowledge/extractor/plugins/compute/host_az_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" testlib "github.com/cobaltcore-dev/cortex/pkg/testing" diff --git a/internal/knowledge/extractor/plugins/compute/host_capabilities_test.go b/internal/knowledge/extractor/plugins/compute/host_capabilities_test.go index 68017eb4e..274a23d2b 100644 --- a/internal/knowledge/extractor/plugins/compute/host_capabilities_test.go +++ b/internal/knowledge/extractor/plugins/compute/host_capabilities_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/placement" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/placement" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" ) diff --git a/internal/knowledge/extractor/plugins/compute/host_details_test.go b/internal/knowledge/extractor/plugins/compute/host_details_test.go index d0462fff6..2272be9d3 100644 --- a/internal/knowledge/extractor/plugins/compute/host_details_test.go +++ b/internal/knowledge/extractor/plugins/compute/host_details_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/placement" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/placement" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" testlib "github.com/cobaltcore-dev/cortex/pkg/testing" diff --git a/internal/knowledge/extractor/plugins/compute/host_pinned_project_test.go b/internal/knowledge/extractor/plugins/compute/host_pinned_project_test.go index 8c8e99b41..ab57d562a 100644 --- a/internal/knowledge/extractor/plugins/compute/host_pinned_project_test.go +++ b/internal/knowledge/extractor/plugins/compute/host_pinned_project_test.go @@ -10,8 +10,8 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/identity" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/identity" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" testlib "github.com/cobaltcore-dev/cortex/pkg/testing" diff --git a/internal/knowledge/extractor/plugins/compute/host_utilization_test.go b/internal/knowledge/extractor/plugins/compute/host_utilization_test.go index de71c6d8e..daa41ebe1 100644 --- a/internal/knowledge/extractor/plugins/compute/host_utilization_test.go +++ b/internal/knowledge/extractor/plugins/compute/host_utilization_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/placement" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/placement" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" ) diff --git a/internal/knowledge/extractor/plugins/compute/libvirt_domain_cpu_steal_pct_test.go b/internal/knowledge/extractor/plugins/compute/libvirt_domain_cpu_steal_pct_test.go index 5e32e2e5c..0a5b92ec2 100644 --- a/internal/knowledge/extractor/plugins/compute/libvirt_domain_cpu_steal_pct_test.go +++ b/internal/knowledge/extractor/plugins/compute/libvirt_domain_cpu_steal_pct_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/prometheus" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/prometheus" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" "k8s.io/apimachinery/pkg/runtime" diff --git a/internal/knowledge/extractor/plugins/compute/vm_host_residency_test.go b/internal/knowledge/extractor/plugins/compute/vm_host_residency_test.go index 4143d0d81..88ca4d0a4 100644 --- a/internal/knowledge/extractor/plugins/compute/vm_host_residency_test.go +++ b/internal/knowledge/extractor/plugins/compute/vm_host_residency_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" ) diff --git a/internal/knowledge/extractor/plugins/compute/vm_life_span_test.go b/internal/knowledge/extractor/plugins/compute/vm_life_span_test.go index f3df6ad87..b1658389d 100644 --- a/internal/knowledge/extractor/plugins/compute/vm_life_span_test.go +++ b/internal/knowledge/extractor/plugins/compute/vm_life_span_test.go @@ -11,7 +11,7 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" ) diff --git a/internal/knowledge/extractor/plugins/compute/vrops_hostsystem_contention_long_term_test.go b/internal/knowledge/extractor/plugins/compute/vrops_hostsystem_contention_long_term_test.go index c1f546810..259c561fd 100644 --- a/internal/knowledge/extractor/plugins/compute/vrops_hostsystem_contention_long_term_test.go +++ b/internal/knowledge/extractor/plugins/compute/vrops_hostsystem_contention_long_term_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/prometheus" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/prometheus" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/internal/knowledge/extractor/plugins/compute/vrops_hostsystem_contention_short_term_test.go b/internal/knowledge/extractor/plugins/compute/vrops_hostsystem_contention_short_term_test.go index 75f27d3d2..54cb42c09 100644 --- a/internal/knowledge/extractor/plugins/compute/vrops_hostsystem_contention_short_term_test.go +++ b/internal/knowledge/extractor/plugins/compute/vrops_hostsystem_contention_short_term_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/prometheus" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/prometheus" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/internal/knowledge/extractor/plugins/compute/vrops_hostsystem_resolver_test.go b/internal/knowledge/extractor/plugins/compute/vrops_hostsystem_resolver_test.go index 595dabba1..bfc9e5689 100644 --- a/internal/knowledge/extractor/plugins/compute/vrops_hostsystem_resolver_test.go +++ b/internal/knowledge/extractor/plugins/compute/vrops_hostsystem_resolver_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/prometheus" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/prometheus" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" ) diff --git a/internal/knowledge/extractor/plugins/compute/vrops_project_noisiness_test.go b/internal/knowledge/extractor/plugins/compute/vrops_project_noisiness_test.go index 8313d2351..0235d8dae 100644 --- a/internal/knowledge/extractor/plugins/compute/vrops_project_noisiness_test.go +++ b/internal/knowledge/extractor/plugins/compute/vrops_project_noisiness_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/prometheus" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/prometheus" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" "k8s.io/apimachinery/pkg/runtime" diff --git a/internal/knowledge/extractor/plugins/storage/storage_pool_cpu_usage_test.go b/internal/knowledge/extractor/plugins/storage/storage_pool_cpu_usage_test.go index 20b24bda1..0778e512c 100644 --- a/internal/knowledge/extractor/plugins/storage/storage_pool_cpu_usage_test.go +++ b/internal/knowledge/extractor/plugins/storage/storage_pool_cpu_usage_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/cobaltcore-dev/cortex/api/v1alpha1" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/manila" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/prometheus" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/manila" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/prometheus" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" ) diff --git a/internal/knowledge/kpis/plugins/compute/flavor_running_vms.go b/internal/knowledge/kpis/plugins/compute/flavor_running_vms.go index 92b21d5e2..21fe754db 100644 --- a/internal/knowledge/kpis/plugins/compute/flavor_running_vms.go +++ b/internal/knowledge/kpis/plugins/compute/flavor_running_vms.go @@ -6,7 +6,8 @@ package compute import ( "log/slog" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/identity" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" "github.com/cobaltcore-dev/cortex/internal/knowledge/kpis/plugins" "github.com/cobaltcore-dev/cortex/pkg/conf" "github.com/cobaltcore-dev/cortex/pkg/db" @@ -19,6 +20,7 @@ type FlavorRunningVMs struct { AvailabilityZone string `db:"availability_zone"` RunningVMs float64 `db:"running_vms"` ProjectID string `db:"project_id"` + ProjectName string `db:"project_name"` } type FlavorRunningVMsKPI struct { @@ -42,6 +44,7 @@ func (k *FlavorRunningVMsKPI) Init(db *db.DB, client client.Client, opts conf.Ra "flavor_name", "availability_zone", "project_id", + "project_name", }, nil, ) @@ -57,19 +60,22 @@ func (k *FlavorRunningVMsKPI) Collect(ch chan<- prometheus.Metric) { query := ` SELECT - tenant_id AS project_id, - flavor_name, - COALESCE(os_ext_az_availability_zone, 'unknown') AS availability_zone, + os.tenant_id AS project_id, + p.name AS project_name, + os.flavor_name, + COALESCE(os.os_ext_az_availability_zone, 'unknown') AS availability_zone, COUNT(*) AS running_vms - FROM ` + nova.Server{}.TableName() + ` + FROM ` + nova.Server{}.TableName() + ` os + JOIN ` + identity.Project{}.TableName() + ` p ON p.id = os.tenant_id WHERE status != 'DELETED' GROUP BY - project_id, - flavor_name, - os_ext_az_availability_zone + os.tenant_id, + p.name, + os.flavor_name, + os.os_ext_az_availability_zone ORDER BY - project_id; + os.tenant_id; ` if _, err := k.DB.Select(&results, query); err != nil { @@ -84,6 +90,7 @@ func (k *FlavorRunningVMsKPI) Collect(ch chan<- prometheus.Metric) { r.FlavorName, r.AvailabilityZone, r.ProjectID, + r.ProjectName, ) } } diff --git a/internal/knowledge/kpis/plugins/compute/flavor_running_vms_test.go b/internal/knowledge/kpis/plugins/compute/flavor_running_vms_test.go index 644624ad5..76b7dcf16 100644 --- a/internal/knowledge/kpis/plugins/compute/flavor_running_vms_test.go +++ b/internal/knowledge/kpis/plugins/compute/flavor_running_vms_test.go @@ -7,7 +7,8 @@ import ( "reflect" "testing" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/identity" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" "github.com/cobaltcore-dev/cortex/pkg/conf" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" @@ -31,6 +32,7 @@ func TestFlavorRunningVMsKPI_Collect(t *testing.T) { defer dbEnv.Close() if err := testDB.CreateTable( testDB.AddTable(nova.Server{}), + testDB.AddTable(identity.Project{}), ); err != nil { t.Fatalf("expected no error, got %v", err) } @@ -66,6 +68,15 @@ func TestFlavorRunningVMsKPI_Collect(t *testing.T) { OSEXTAvailabilityZone: "zone2", TenantID: "project-2", }, + + &identity.Project{ + ID: "project-1", + Name: "Project One", + }, + &identity.Project{ + ID: "project-2", + Name: "Project Two", + }, } if err := testDB.Insert(mockData...); err != nil { @@ -86,6 +97,7 @@ func TestFlavorRunningVMsKPI_Collect(t *testing.T) { AvailabilityZone string RunningVMs float64 ProjectID string + ProjectName string } metrics := make(map[string]FlavorRunningVMsMetric, 0) @@ -104,6 +116,7 @@ func TestFlavorRunningVMsKPI_Collect(t *testing.T) { flavor := labels["flavor_name"] availabilityZone := labels["availability_zone"] projectID := labels["project_id"] + projectName := labels["project_name"] key := flavor + "|" + availabilityZone + "|" + projectID @@ -111,6 +124,7 @@ func TestFlavorRunningVMsKPI_Collect(t *testing.T) { FlavorName: flavor, AvailabilityZone: availabilityZone, ProjectID: projectID, + ProjectName: projectName, RunningVMs: m.GetGauge().GetValue(), } } @@ -120,18 +134,21 @@ func TestFlavorRunningVMsKPI_Collect(t *testing.T) { FlavorName: "small", AvailabilityZone: "zone1", ProjectID: "project-1", + ProjectName: "Project One", RunningVMs: 1, }, "medium|zone1|project-1": { FlavorName: "medium", AvailabilityZone: "zone1", ProjectID: "project-1", + ProjectName: "Project One", RunningVMs: 1, }, "medium|zone2|project-1": { FlavorName: "medium", AvailabilityZone: "zone2", ProjectID: "project-1", + ProjectName: "Project One", RunningVMs: 2, }, "medium|zone2|project-2": { @@ -139,6 +156,7 @@ func TestFlavorRunningVMsKPI_Collect(t *testing.T) { AvailabilityZone: "zone2", RunningVMs: 1, ProjectID: "project-2", + ProjectName: "Project Two", }, } diff --git a/internal/knowledge/kpis/plugins/compute/vm_commitments.go b/internal/knowledge/kpis/plugins/compute/vm_commitments.go index 299d400b4..8dbe08830 100644 --- a/internal/knowledge/kpis/plugins/compute/vm_commitments.go +++ b/internal/knowledge/kpis/plugins/compute/vm_commitments.go @@ -8,8 +8,8 @@ import ( "log/slog" "strings" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/limes" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/limes" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" "github.com/cobaltcore-dev/cortex/internal/knowledge/kpis/plugins" "github.com/cobaltcore-dev/cortex/pkg/conf" "github.com/cobaltcore-dev/cortex/pkg/db" diff --git a/internal/knowledge/kpis/plugins/compute/vm_commitments_test.go b/internal/knowledge/kpis/plugins/compute/vm_commitments_test.go index 1ae810878..992cfc5b4 100644 --- a/internal/knowledge/kpis/plugins/compute/vm_commitments_test.go +++ b/internal/knowledge/kpis/plugins/compute/vm_commitments_test.go @@ -6,8 +6,8 @@ package compute import ( "testing" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/limes" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/limes" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" "github.com/cobaltcore-dev/cortex/pkg/conf" "github.com/cobaltcore-dev/cortex/pkg/db" testlibDB "github.com/cobaltcore-dev/cortex/pkg/db/testing" diff --git a/internal/scheduling/cinder/filter_weigher_pipeline_controller.go b/internal/scheduling/cinder/filter_weigher_pipeline_controller.go index b6c456b99..eaf07f77a 100644 --- a/internal/scheduling/cinder/filter_weigher_pipeline_controller.go +++ b/internal/scheduling/cinder/filter_weigher_pipeline_controller.go @@ -16,6 +16,8 @@ import ( "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/cobaltcore-dev/cortex/internal/scheduling/cinder/plugins/filters" + "github.com/cobaltcore-dev/cortex/internal/scheduling/cinder/plugins/weighers" "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" "github.com/cobaltcore-dev/cortex/pkg/conf" "github.com/cobaltcore-dev/cortex/pkg/multicluster" @@ -148,8 +150,8 @@ func (c *FilterWeigherPipelineController) InitPipeline( return lib.InitNewFilterWeigherPipeline( ctx, c.Client, p.Name, - supportedFilters, p.Spec.Filters, - supportedWeighers, p.Spec.Weighers, + filters.Index, p.Spec.Filters, + weighers.Index, p.Spec.Weighers, c.Monitor, ) } diff --git a/internal/scheduling/cinder/supported_filters.go b/internal/scheduling/cinder/plugins/filters/zz_index.go similarity index 81% rename from internal/scheduling/cinder/supported_filters.go rename to internal/scheduling/cinder/plugins/filters/zz_index.go index f751ee9dd..3ef598240 100644 --- a/internal/scheduling/cinder/supported_filters.go +++ b/internal/scheduling/cinder/plugins/filters/zz_index.go @@ -1,7 +1,7 @@ // Copyright SAP SE // SPDX-License-Identifier: Apache-2.0 -package cinder +package filters import ( api "github.com/cobaltcore-dev/cortex/api/delegation/cinder" @@ -11,4 +11,4 @@ import ( type CinderFilter = lib.Filter[api.ExternalSchedulerRequest] // Configuration of filters supported by the cinder scheduling. -var supportedFilters = map[string]func() CinderFilter{} +var Index = map[string]func() CinderFilter{} diff --git a/internal/scheduling/cinder/supported_weighers.go b/internal/scheduling/cinder/plugins/weighers/zz_index.go similarity index 81% rename from internal/scheduling/cinder/supported_weighers.go rename to internal/scheduling/cinder/plugins/weighers/zz_index.go index cc45cf26e..e8e415b19 100644 --- a/internal/scheduling/cinder/supported_weighers.go +++ b/internal/scheduling/cinder/plugins/weighers/zz_index.go @@ -1,7 +1,7 @@ // Copyright SAP SE // SPDX-License-Identifier: Apache-2.0 -package cinder +package weighers import ( api "github.com/cobaltcore-dev/cortex/api/delegation/cinder" @@ -11,4 +11,4 @@ import ( type CinderWeigher = lib.Weigher[api.ExternalSchedulerRequest] // Configuration of weighers supported by the cinder scheduling. -var supportedWeighers = map[string]func() CinderWeigher{} +var Index = map[string]func() CinderWeigher{} diff --git a/internal/scheduling/machines/filter_weigher_pipeline_controller.go b/internal/scheduling/machines/filter_weigher_pipeline_controller.go index f7b4a0134..55931c962 100644 --- a/internal/scheduling/machines/filter_weigher_pipeline_controller.go +++ b/internal/scheduling/machines/filter_weigher_pipeline_controller.go @@ -17,6 +17,8 @@ import ( "github.com/cobaltcore-dev/cortex/pkg/multicluster" "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" + "github.com/cobaltcore-dev/cortex/internal/scheduling/machines/plugins/filters" + "github.com/cobaltcore-dev/cortex/internal/scheduling/machines/plugins/weighers" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -190,8 +192,8 @@ func (c *FilterWeigherPipelineController) InitPipeline( return lib.InitNewFilterWeigherPipeline( ctx, c.Client, p.Name, - supportedFilters, p.Spec.Filters, - supportedWeighers, p.Spec.Weighers, + filters.Index, p.Spec.Filters, + weighers.Index, p.Spec.Weighers, c.Monitor, ) } diff --git a/internal/scheduling/machines/noop.go b/internal/scheduling/machines/plugins/filters/filter_noop.go similarity index 88% rename from internal/scheduling/machines/noop.go rename to internal/scheduling/machines/plugins/filters/filter_noop.go index ce4d52226..33801f9f9 100644 --- a/internal/scheduling/machines/noop.go +++ b/internal/scheduling/machines/plugins/filters/filter_noop.go @@ -1,4 +1,7 @@ -package machines +// Copyright SAP SE +// SPDX-License-Identifier: Apache-2.0 + +package filters import ( "context" @@ -33,3 +36,7 @@ func (NoopFilter) Run(traceLog *slog.Logger, request ironcore.MachinePipelineReq } return &lib.FilterWeigherPipelineStepResult{Activations: activations, Statistics: stats}, nil } + +func init() { + Index["noop"] = func() MachineFilter { return &NoopFilter{} } +} diff --git a/internal/scheduling/machines/noop_test.go b/internal/scheduling/machines/plugins/filters/filter_noop_test.go similarity index 99% rename from internal/scheduling/machines/noop_test.go rename to internal/scheduling/machines/plugins/filters/filter_noop_test.go index 3204d27b6..a38b38552 100644 --- a/internal/scheduling/machines/noop_test.go +++ b/internal/scheduling/machines/plugins/filters/filter_noop_test.go @@ -1,7 +1,7 @@ // Copyright SAP SE // SPDX-License-Identifier: Apache-2.0 -package machines +package filters import ( "log/slog" diff --git a/internal/scheduling/machines/supported_filters.go b/internal/scheduling/machines/plugins/filters/zz_index.go similarity index 71% rename from internal/scheduling/machines/supported_filters.go rename to internal/scheduling/machines/plugins/filters/zz_index.go index 5dcee9a54..68033f564 100644 --- a/internal/scheduling/machines/supported_filters.go +++ b/internal/scheduling/machines/plugins/filters/zz_index.go @@ -1,7 +1,7 @@ // Copyright SAP SE // SPDX-License-Identifier: Apache-2.0 -package machines +package filters import ( "github.com/cobaltcore-dev/cortex/api/delegation/ironcore" @@ -11,6 +11,4 @@ import ( type MachineFilter = lib.Filter[ironcore.MachinePipelineRequest] // Configuration of filters supported by the machine scheduling. -var supportedFilters = map[string]func() MachineFilter{ - "noop": func() MachineFilter { return &NoopFilter{} }, -} +var Index = map[string]func() MachineFilter{} diff --git a/internal/scheduling/machines/supported_weighers.go b/internal/scheduling/machines/plugins/weighers/zz_index.go similarity index 81% rename from internal/scheduling/machines/supported_weighers.go rename to internal/scheduling/machines/plugins/weighers/zz_index.go index 329606cc1..3e2ceac3f 100644 --- a/internal/scheduling/machines/supported_weighers.go +++ b/internal/scheduling/machines/plugins/weighers/zz_index.go @@ -1,7 +1,7 @@ // Copyright SAP SE // SPDX-License-Identifier: Apache-2.0 -package machines +package weighers import ( "github.com/cobaltcore-dev/cortex/api/delegation/ironcore" @@ -11,4 +11,4 @@ import ( type MachineWeigher = lib.Weigher[ironcore.MachinePipelineRequest] // Configuration of weighers supported by the machine scheduling. -var supportedWeighers = map[string]func() MachineWeigher{} +var Index = map[string]func() MachineWeigher{} diff --git a/internal/scheduling/manila/filter_weigher_pipeline_controller.go b/internal/scheduling/manila/filter_weigher_pipeline_controller.go index ceb0320f2..925ae4416 100644 --- a/internal/scheduling/manila/filter_weigher_pipeline_controller.go +++ b/internal/scheduling/manila/filter_weigher_pipeline_controller.go @@ -17,6 +17,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" + "github.com/cobaltcore-dev/cortex/internal/scheduling/manila/plugins/filters" + "github.com/cobaltcore-dev/cortex/internal/scheduling/manila/plugins/weighers" "github.com/cobaltcore-dev/cortex/pkg/conf" "github.com/cobaltcore-dev/cortex/pkg/multicluster" ctrl "sigs.k8s.io/controller-runtime" @@ -148,8 +150,8 @@ func (c *FilterWeigherPipelineController) InitPipeline( return lib.InitNewFilterWeigherPipeline( ctx, c.Client, p.Name, - supportedFilters, p.Spec.Filters, - supportedWeighers, p.Spec.Weighers, + filters.Index, p.Spec.Filters, + weighers.Index, p.Spec.Weighers, c.Monitor, ) } diff --git a/internal/scheduling/manila/supported_filters.go b/internal/scheduling/manila/plugins/filters/zz_index.go similarity index 81% rename from internal/scheduling/manila/supported_filters.go rename to internal/scheduling/manila/plugins/filters/zz_index.go index ed86e3f5f..aec3aac23 100644 --- a/internal/scheduling/manila/supported_filters.go +++ b/internal/scheduling/manila/plugins/filters/zz_index.go @@ -1,7 +1,7 @@ // Copyright SAP SE // SPDX-License-Identifier: Apache-2.0 -package manila +package filters import ( api "github.com/cobaltcore-dev/cortex/api/delegation/manila" @@ -11,4 +11,4 @@ import ( type ManilaFilter = lib.Filter[api.ExternalSchedulerRequest] // Configuration of filters supported by the manila scheduler. -var supportedFilters = map[string]func() ManilaFilter{} +var Index = map[string]func() ManilaFilter{} diff --git a/internal/scheduling/manila/plugins/weighers/netapp_cpu_usage_balancing.go b/internal/scheduling/manila/plugins/weighers/netapp_cpu_usage_balancing.go index 5eb9474b5..6897d8614 100644 --- a/internal/scheduling/manila/plugins/weighers/netapp_cpu_usage_balancing.go +++ b/internal/scheduling/manila/plugins/weighers/netapp_cpu_usage_balancing.go @@ -106,3 +106,9 @@ func (s *NetappCPUUsageBalancingStep) Run(traceLog *slog.Logger, request api.Ext } return result, nil } + +func init() { + Index["netapp_cpu_usage_balancing"] = func() lib.Weigher[api.ExternalSchedulerRequest] { + return &NetappCPUUsageBalancingStep{} + } +} diff --git a/internal/scheduling/manila/supported_weighers.go b/internal/scheduling/manila/plugins/weighers/zz_index.go similarity index 55% rename from internal/scheduling/manila/supported_weighers.go rename to internal/scheduling/manila/plugins/weighers/zz_index.go index 3e9a5b6cb..ee37f1392 100644 --- a/internal/scheduling/manila/supported_weighers.go +++ b/internal/scheduling/manila/plugins/weighers/zz_index.go @@ -1,17 +1,14 @@ // Copyright SAP SE // SPDX-License-Identifier: Apache-2.0 -package manila +package weighers import ( api "github.com/cobaltcore-dev/cortex/api/delegation/manila" "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" - "github.com/cobaltcore-dev/cortex/internal/scheduling/manila/plugins/weighers" ) type ManilaWeigher = lib.Weigher[api.ExternalSchedulerRequest] // Configuration of weighers supported by the manila scheduler. -var supportedWeighers = map[string]func() ManilaWeigher{ - "netapp_cpu_usage_balancing": func() ManilaWeigher { return &weighers.NetappCPUUsageBalancingStep{} }, -} +var Index = map[string]func() ManilaWeigher{} diff --git a/internal/scheduling/nova/deschedulings_executor.go b/internal/scheduling/nova/deschedulings_executor.go index 1e1cd17e1..87f011eef 100644 --- a/internal/scheduling/nova/deschedulings_executor.go +++ b/internal/scheduling/nova/deschedulings_executor.go @@ -32,8 +32,8 @@ type DeschedulingsExecutor struct { // Kubernetes scheme to use for the deschedulings. Scheme *runtime.Scheme - // Nova API to execute the descheduling operations. - NovaAPI NovaAPI + // Nova client to execute the descheduling operations. + NovaClient NovaClient // Configuration for the descheduler. Conf conf.Config // Monitor for tracking the descheduler execution. @@ -111,7 +111,7 @@ func (e *DeschedulingsExecutor) Reconcile(ctx context.Context, req ctrl.Request) } vmId := descheduling.Spec.Ref - server, err := e.NovaAPI.Get(ctx, vmId) + server, err := e.NovaClient.Get(ctx, vmId) if err != nil { // Delete the descheduling if the VM was not found. log.Info("VM not found, deleting descheduling", "vmId", vmId) @@ -168,7 +168,7 @@ func (e *DeschedulingsExecutor) Reconcile(ctx context.Context, req ctrl.Request) } log.Info("descheduler: executing migration for VM", "vmId", vmId) - if err := e.NovaAPI.LiveMigrate(ctx, vmId); err != nil { + if err := e.NovaClient.LiveMigrate(ctx, vmId); err != nil { log.Error(err, "descheduler: failed to live-migrate VM", "vmId", vmId, "error", err) old := descheduling.DeepCopy() meta.SetStatusCondition(&descheduling.Status.Conditions, metav1.Condition{ @@ -187,7 +187,7 @@ func (e *DeschedulingsExecutor) Reconcile(ctx context.Context, req ctrl.Request) // Wait for the migration to complete. log.Info("descheduler: live-migration started", "vmId", vmId) for { - server, err = e.NovaAPI.Get(ctx, vmId) + server, err = e.NovaClient.Get(ctx, vmId) if err != nil { log.Error(err, "descheduler: failed to get VM status", "vmId", vmId) // Consider migration as failed diff --git a/internal/scheduling/nova/deschedulings_executor_test.go b/internal/scheduling/nova/deschedulings_executor_test.go index 54eace86d..ff20bf932 100644 --- a/internal/scheduling/nova/deschedulings_executor_test.go +++ b/internal/scheduling/nova/deschedulings_executor_test.go @@ -23,7 +23,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" ) -type mockExecutorNovaAPI struct { +type mockExecutorNovaClient struct { servers map[string]server migrations map[string][]migration getError error @@ -31,11 +31,11 @@ type mockExecutorNovaAPI struct { migrationDelay time.Duration } -func (m *mockExecutorNovaAPI) Init(ctx context.Context, client client.Client, conf conf.Config) error { +func (m *mockExecutorNovaClient) Init(ctx context.Context, client client.Client, conf conf.Config) error { return nil } -func (m *mockExecutorNovaAPI) Get(ctx context.Context, id string) (server, error) { +func (m *mockExecutorNovaClient) Get(ctx context.Context, id string) (server, error) { if m.getError != nil { return server{}, m.getError } @@ -45,7 +45,7 @@ func (m *mockExecutorNovaAPI) Get(ctx context.Context, id string) (server, error return server{}, errors.New("server not found") } -func (m *mockExecutorNovaAPI) LiveMigrate(ctx context.Context, id string) error { +func (m *mockExecutorNovaClient) LiveMigrate(ctx context.Context, id string) error { if m.migrateError != nil { return m.migrateError } @@ -68,7 +68,7 @@ func (m *mockExecutorNovaAPI) LiveMigrate(ctx context.Context, id string) error return nil } -func (m *mockExecutorNovaAPI) GetServerMigrations(ctx context.Context, id string) ([]migration, error) { +func (m *mockExecutorNovaClient) GetServerMigrations(ctx context.Context, id string) ([]migration, error) { if migs, ok := m.migrations[id]; ok { return migs, nil } @@ -90,7 +90,7 @@ func TestExecutor_Reconcile(t *testing.T) { tests := []struct { name string descheduling *v1alpha1.Descheduling - novaAPI *mockExecutorNovaAPI + novaAPI *mockExecutorNovaClient config conf.Config expectedReady bool expectedInProgress bool @@ -112,7 +112,7 @@ func TestExecutor_Reconcile(t *testing.T) { }, Status: v1alpha1.DeschedulingStatus{}, }, - novaAPI: &mockExecutorNovaAPI{ + novaAPI: &mockExecutorNovaClient{ servers: map[string]server{ "vm-123": {ID: "vm-123", Status: "ACTIVE", ComputeHost: "old-host"}, }, @@ -137,7 +137,7 @@ func TestExecutor_Reconcile(t *testing.T) { }, Status: v1alpha1.DeschedulingStatus{}, }, - novaAPI: &mockExecutorNovaAPI{ + novaAPI: &mockExecutorNovaClient{ servers: map[string]server{ "vm-123": {ID: "vm-123", Status: "ACTIVE", ComputeHost: "old-host"}, }, @@ -161,7 +161,7 @@ func TestExecutor_Reconcile(t *testing.T) { }, Status: v1alpha1.DeschedulingStatus{}, }, - novaAPI: &mockExecutorNovaAPI{}, + novaAPI: &mockExecutorNovaClient{}, expectedReady: false, expectedInProgress: false, expectedError: "unsupported refType: unsupported-type", @@ -180,7 +180,7 @@ func TestExecutor_Reconcile(t *testing.T) { }, Status: v1alpha1.DeschedulingStatus{}, }, - novaAPI: &mockExecutorNovaAPI{}, + novaAPI: &mockExecutorNovaClient{}, expectedReady: false, expectedInProgress: false, expectedError: "unsupported prevHostType: unsupported-host-type", @@ -199,7 +199,7 @@ func TestExecutor_Reconcile(t *testing.T) { }, Status: v1alpha1.DeschedulingStatus{}, }, - novaAPI: &mockExecutorNovaAPI{}, + novaAPI: &mockExecutorNovaClient{}, expectedReady: false, expectedInProgress: false, expectedError: "missing ref", @@ -218,7 +218,7 @@ func TestExecutor_Reconcile(t *testing.T) { }, Status: v1alpha1.DeschedulingStatus{}, }, - novaAPI: &mockExecutorNovaAPI{servers: map[string]server{}}, + novaAPI: &mockExecutorNovaClient{servers: map[string]server{}}, expectDeletion: true, }, { @@ -236,7 +236,7 @@ func TestExecutor_Reconcile(t *testing.T) { }, Status: v1alpha1.DeschedulingStatus{}, }, - novaAPI: &mockExecutorNovaAPI{ + novaAPI: &mockExecutorNovaClient{ servers: map[string]server{ "vm-123": {ID: "vm-123", Status: "ACTIVE", ComputeHost: "different-host"}, }, @@ -259,7 +259,7 @@ func TestExecutor_Reconcile(t *testing.T) { }, Status: v1alpha1.DeschedulingStatus{}, }, - novaAPI: &mockExecutorNovaAPI{ + novaAPI: &mockExecutorNovaClient{ servers: map[string]server{ "vm-123": {ID: "vm-123", Status: "SHUTOFF", ComputeHost: "host1"}, }, @@ -282,7 +282,7 @@ func TestExecutor_Reconcile(t *testing.T) { }, Status: v1alpha1.DeschedulingStatus{}, }, - novaAPI: &mockExecutorNovaAPI{ + novaAPI: &mockExecutorNovaClient{ servers: map[string]server{ "vm-123": {ID: "vm-123", Status: "ACTIVE", ComputeHost: "host1"}, }, @@ -317,7 +317,7 @@ func TestExecutor_Reconcile(t *testing.T) { }, }, }, - novaAPI: &mockExecutorNovaAPI{}, + novaAPI: &mockExecutorNovaClient{}, expectDeletion: false, expectedReady: false, expectedInProgress: true, @@ -334,11 +334,11 @@ func TestExecutor_Reconcile(t *testing.T) { Build() executor := &DeschedulingsExecutor{ - Client: client, - Scheme: scheme, - NovaAPI: tt.novaAPI, - Conf: tt.config, - Monitor: newMockMonitor(), + Client: client, + Scheme: scheme, + NovaClient: tt.novaAPI, + Conf: tt.config, + Monitor: newMockMonitor(), } req := ctrl.Request{ @@ -414,10 +414,10 @@ func TestDeschedulingsExecutor_ReconcileNotFound(t *testing.T) { client := fake.NewClientBuilder().WithScheme(scheme).Build() executor := &DeschedulingsExecutor{ - Client: client, - Scheme: scheme, - NovaAPI: &mockExecutorNovaAPI{}, - Monitor: newMockMonitor(), + Client: client, + Scheme: scheme, + NovaClient: &mockExecutorNovaClient{}, + Monitor: newMockMonitor(), } req := ctrl.Request{ diff --git a/internal/scheduling/nova/detector_cycle_breaker.go b/internal/scheduling/nova/detector_cycle_breaker.go index fd3a1bd00..47b2665db 100644 --- a/internal/scheduling/nova/detector_cycle_breaker.go +++ b/internal/scheduling/nova/detector_cycle_breaker.go @@ -14,23 +14,23 @@ import ( type detectorCycleBreaker struct { // Nova API to get needed information for cycle detection. - novaAPI NovaAPI + novaClient NovaClient } func NewDetectorCycleBreaker() lib.DetectorCycleBreaker[plugins.VMDetection] { - return &detectorCycleBreaker{novaAPI: NewNovaAPI()} + return &detectorCycleBreaker{novaClient: NewNovaClient()} } // Initialize the cycle detector. func (c *detectorCycleBreaker) Init(ctx context.Context, client client.Client, conf conf.Config) error { - return c.novaAPI.Init(ctx, client, conf) + return c.novaClient.Init(ctx, client, conf) } func (c *detectorCycleBreaker) Filter(ctx context.Context, decisions []plugins.VMDetection) ([]plugins.VMDetection, error) { keep := make(map[string]struct{}, len(decisions)) for _, decision := range decisions { // Get the migrations for the VM. - migrations, err := c.novaAPI.GetServerMigrations(ctx, decision.VMID) + migrations, err := c.novaClient.GetServerMigrations(ctx, decision.VMID) if err != nil { return nil, err } diff --git a/internal/scheduling/nova/detector_cycle_breaker_test.go b/internal/scheduling/nova/detector_cycle_breaker_test.go index a242ff0d0..b08759c27 100644 --- a/internal/scheduling/nova/detector_cycle_breaker_test.go +++ b/internal/scheduling/nova/detector_cycle_breaker_test.go @@ -14,24 +14,24 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" ) -type mockDetectorCycleBreakerNovaAPI struct { +type mockDetectorCycleBreakerNovaClient struct { migrations map[string][]migration getError error } -func (m *mockDetectorCycleBreakerNovaAPI) Init(ctx context.Context, client client.Client, conf conf.Config) error { +func (m *mockDetectorCycleBreakerNovaClient) Init(ctx context.Context, client client.Client, conf conf.Config) error { return nil } -func (m *mockDetectorCycleBreakerNovaAPI) Get(ctx context.Context, id string) (server, error) { +func (m *mockDetectorCycleBreakerNovaClient) Get(ctx context.Context, id string) (server, error) { return server{}, errors.New("not implemented") } -func (m *mockDetectorCycleBreakerNovaAPI) LiveMigrate(ctx context.Context, id string) error { +func (m *mockDetectorCycleBreakerNovaClient) LiveMigrate(ctx context.Context, id string) error { return errors.New("not implemented") } -func (m *mockDetectorCycleBreakerNovaAPI) GetServerMigrations(ctx context.Context, id string) ([]migration, error) { +func (m *mockDetectorCycleBreakerNovaClient) GetServerMigrations(ctx context.Context, id string) ([]migration, error) { if m.getError != nil { return nil, m.getError } @@ -171,7 +171,7 @@ func TestDetectorCycleBreaker_Filter(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - mockAPI := &mockDetectorCycleBreakerNovaAPI{ + mockAPI := &mockDetectorCycleBreakerNovaClient{ migrations: tt.migrations, } @@ -179,7 +179,7 @@ func TestDetectorCycleBreaker_Filter(t *testing.T) { mockAPI.getError = errors.New("API error") } - detector := detectorCycleBreaker{novaAPI: mockAPI} + detector := detectorCycleBreaker{novaClient: mockAPI} ctx := context.Background() result, err := detector.Filter(ctx, tt.decisions) @@ -229,11 +229,11 @@ func TestDetectorCycleBreaker_Filter(t *testing.T) { } func TestDetectorCycleBreaker_Filter_EmptyVMDetections(t *testing.T) { - mockAPI := &mockDetectorCycleBreakerNovaAPI{ + mockAPI := &mockDetectorCycleBreakerNovaClient{ migrations: map[string][]migration{}, } - detector := detectorCycleBreaker{novaAPI: mockAPI} + detector := detectorCycleBreaker{novaClient: mockAPI} ctx := context.Background() result, err := detector.Filter(ctx, []plugins.VMDetection{}) @@ -260,30 +260,30 @@ func TestNewDetectorCycleBreaker(t *testing.T) { t.Errorf("expected *detectorCycleBreaker, got %T", detector) } - // Verify the novaAPI field is initialized + // Verify the novaClient field is initialized detectorImpl := detector.(*detectorCycleBreaker) - if detectorImpl.novaAPI == nil { - t.Error("expected novaAPI to be initialized") + if detectorImpl.novaClient == nil { + t.Error("expected novaClient to be initialized") } } func TestDetectorCycleBreaker_Init(t *testing.T) { tests := []struct { name string - setupMock func() NovaAPI + setupMock func() NovaClient expectErr bool }{ { name: "successful initialization", - setupMock: func() NovaAPI { - return &mockDetectorCycleBreakerNovaAPI{} + setupMock: func() NovaClient { + return &mockDetectorCycleBreakerNovaClient{} }, expectErr: false, }, { name: "initialization with error", - setupMock: func() NovaAPI { - return &mockDetectorCycleBreakerNovaAPIWithInitError{} + setupMock: func() NovaClient { + return &mockDetectorCycleBreakerNovaClientWithInitError{} }, expectErr: true, }, @@ -292,7 +292,7 @@ func TestDetectorCycleBreaker_Init(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { detector := &detectorCycleBreaker{ - novaAPI: tt.setupMock(), + novaClient: tt.setupMock(), } ctx := context.Background() @@ -312,11 +312,11 @@ func TestDetectorCycleBreaker_Init(t *testing.T) { } } -// mockDetectorCycleBreakerNovaAPIWithInitError is a mock that returns an error on Init -type mockDetectorCycleBreakerNovaAPIWithInitError struct { - mockDetectorCycleBreakerNovaAPI +// mockDetectorCycleBreakerNovaClientWithInitError is a mock that returns an error on Init +type mockDetectorCycleBreakerNovaClientWithInitError struct { + mockDetectorCycleBreakerNovaClient } -func (m *mockDetectorCycleBreakerNovaAPIWithInitError) Init(ctx context.Context, client client.Client, conf conf.Config) error { +func (m *mockDetectorCycleBreakerNovaClientWithInitError) Init(ctx context.Context, client client.Client, conf conf.Config) error { return errors.New("init error") } diff --git a/internal/scheduling/nova/detector_pipeline_controller.go b/internal/scheduling/nova/detector_pipeline_controller.go index 7bd773245..d8a31548e 100644 --- a/internal/scheduling/nova/detector_pipeline_controller.go +++ b/internal/scheduling/nova/detector_pipeline_controller.go @@ -12,6 +12,7 @@ import ( "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" "github.com/cobaltcore-dev/cortex/internal/scheduling/nova/plugins" + "github.com/cobaltcore-dev/cortex/internal/scheduling/nova/plugins/detectors" "github.com/cobaltcore-dev/cortex/pkg/conf" "github.com/cobaltcore-dev/cortex/pkg/multicluster" "github.com/sapcc/go-bits/jobloop" @@ -57,7 +58,7 @@ func (c *DetectorPipelineController) InitPipeline( DetectorCycleBreaker: c.DetectorCycleBreaker, Monitor: c.Monitor.SubPipeline(p.Name), } - errs := pipeline.Init(ctx, p.Spec.Detectors, supportedDetectors) + errs := pipeline.Init(ctx, p.Spec.Detectors, detectors.Index) return lib.PipelineInitResult[*lib.DetectorPipeline[plugins.VMDetection]]{ Pipeline: pipeline, DetectorErrors: errs, diff --git a/internal/scheduling/nova/e2e_checks.go b/internal/scheduling/nova/e2e_checks.go index 641087d4a..39ad72b68 100644 --- a/internal/scheduling/nova/e2e_checks.go +++ b/internal/scheduling/nova/e2e_checks.go @@ -15,8 +15,8 @@ import ( "strings" api "github.com/cobaltcore-dev/cortex/api/delegation/nova" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/identity" - "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/openstack/nova" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/identity" + "github.com/cobaltcore-dev/cortex/internal/knowledge/datasources/plugins/openstack/nova" "github.com/cobaltcore-dev/cortex/pkg/conf" "github.com/cobaltcore-dev/cortex/pkg/keystone" "github.com/cobaltcore-dev/cortex/pkg/sso" diff --git a/internal/scheduling/nova/filter_weigher_pipeline_controller.go b/internal/scheduling/nova/filter_weigher_pipeline_controller.go index 8d4b29c6c..d64d29aeb 100644 --- a/internal/scheduling/nova/filter_weigher_pipeline_controller.go +++ b/internal/scheduling/nova/filter_weigher_pipeline_controller.go @@ -17,6 +17,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" + "github.com/cobaltcore-dev/cortex/internal/scheduling/nova/plugins/filters" + "github.com/cobaltcore-dev/cortex/internal/scheduling/nova/plugins/weighers" "github.com/cobaltcore-dev/cortex/pkg/conf" "github.com/cobaltcore-dev/cortex/pkg/multicluster" hv1 "github.com/cobaltcore-dev/openstack-hypervisor-operator/api/v1" @@ -155,8 +157,8 @@ func (c *FilterWeigherPipelineController) InitPipeline( return lib.InitNewFilterWeigherPipeline( ctx, c.Client, p.Name, - supportedFilters, p.Spec.Filters, - supportedWeighers, p.Spec.Weighers, + filters.Index, p.Spec.Filters, + weighers.Index, p.Spec.Weighers, c.Monitor, ) } diff --git a/internal/scheduling/nova/nova_api.go b/internal/scheduling/nova/nova_client.go similarity index 90% rename from internal/scheduling/nova/nova_api.go rename to internal/scheduling/nova/nova_client.go index 3efafcbc2..f1fecc580 100644 --- a/internal/scheduling/nova/nova_api.go +++ b/internal/scheduling/nova/nova_client.go @@ -30,7 +30,7 @@ type migration struct { DestCompute string `json:"dest_compute"` } -type NovaAPI interface { +type NovaClient interface { // Initialize the Nova API with the Keystone authentication. Init(ctx context.Context, client client.Client, conf conf.Config) error // Get a server by ID. @@ -41,16 +41,16 @@ type NovaAPI interface { GetServerMigrations(ctx context.Context, id string) ([]migration, error) } -type novaAPI struct { +type novaClient struct { // Authenticated OpenStack service client to fetch the data. sc *gophercloud.ServiceClient } -func NewNovaAPI() NovaAPI { - return &novaAPI{} +func NewNovaClient() NovaClient { + return &novaClient{} } -func (api *novaAPI) Init(ctx context.Context, client client.Client, conf conf.Config) error { +func (api *novaClient) Init(ctx context.Context, client client.Client, conf conf.Config) error { var authenticatedHTTP = http.DefaultClient if conf.SSOSecretRef != nil { var err error @@ -88,7 +88,7 @@ func (api *novaAPI) Init(ctx context.Context, client client.Client, conf conf.Co } // Get a server by ID. -func (api *novaAPI) Get(ctx context.Context, id string) (server, error) { +func (api *novaClient) Get(ctx context.Context, id string) (server, error) { var s server if err := servers.Get(ctx, api.sc, id).ExtractInto(&s); err != nil { return server{}, err @@ -97,7 +97,7 @@ func (api *novaAPI) Get(ctx context.Context, id string) (server, error) { } // Live migrate a server to a new host (doesn't wait for it to complete). -func (api *novaAPI) LiveMigrate(ctx context.Context, id string) error { +func (api *novaClient) LiveMigrate(ctx context.Context, id string) error { blockMigration := false lmo := servers.LiveMigrateOpts{ Host: nil, @@ -108,7 +108,7 @@ func (api *novaAPI) LiveMigrate(ctx context.Context, id string) error { } // Get migrations for a server by ID. -func (api *novaAPI) GetServerMigrations(ctx context.Context, id string) ([]migration, error) { +func (api *novaClient) GetServerMigrations(ctx context.Context, id string) ([]migration, error) { // Note: currently we need to fetch this without gophercloud. // See: https://github.com/gophercloud/gophercloud/pull/3244 initialURL := api.sc.Endpoint + "os-migrations" + "?instance_uuid=" + id diff --git a/internal/scheduling/nova/nova_api_test.go b/internal/scheduling/nova/nova_client_test.go similarity index 92% rename from internal/scheduling/nova/nova_api_test.go rename to internal/scheduling/nova/nova_client_test.go index 0bb68ee84..9213ab6e1 100644 --- a/internal/scheduling/nova/nova_api_test.go +++ b/internal/scheduling/nova/nova_client_test.go @@ -18,14 +18,14 @@ func setupNovaMockServer(handler http.HandlerFunc) (*httptest.Server, keystone.K return server, &testlibKeystone.MockKeystoneClient{Url: server.URL + "/"} } -func TestNewNovaAPI(t *testing.T) { - api := NewNovaAPI() +func TestNewNovaClient(t *testing.T) { + api := NewNovaClient() if api == nil { t.Fatal("expected non-nil api") } } -func TestNovaAPI_GetServer(t *testing.T) { +func TestNovaClient_GetServer(t *testing.T) { handler := func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { t.Fatalf("expected GET method, got %s", r.Method) @@ -39,7 +39,7 @@ func TestNovaAPI_GetServer(t *testing.T) { } server, k := setupNovaMockServer(handler) defer server.Close() - nova := novaAPI{} + nova := novaClient{} nova.sc = &gophercloud.ServiceClient{ ProviderClient: k.Client(), Endpoint: server.URL + "/", @@ -57,7 +57,7 @@ func TestNovaAPI_GetServer(t *testing.T) { } } -func TestNovaAPI_LiveMigrate(t *testing.T) { +func TestNovaClient_LiveMigrate(t *testing.T) { handler := func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { t.Fatalf("expected POST method, got %s", r.Method) @@ -66,7 +66,7 @@ func TestNovaAPI_LiveMigrate(t *testing.T) { } server, k := setupNovaMockServer(handler) defer server.Close() - nova := novaAPI{} + nova := novaClient{} nova.sc = &gophercloud.ServiceClient{ ProviderClient: k.Client(), Endpoint: server.URL + "/", @@ -81,7 +81,7 @@ func TestNovaAPI_LiveMigrate(t *testing.T) { } } -func TestNovaAPI_GetServerMigrations(t *testing.T) { +func TestNovaClient_GetServerMigrations(t *testing.T) { migrationsResponse := `{"migrations": [ {"instance_uuid": "server-123", "source_compute": "host-1", "dest_compute": "host-2"}, {"instance_uuid": "server-123", "source_compute": "host-2", "dest_compute": "host-3"} @@ -100,7 +100,7 @@ func TestNovaAPI_GetServerMigrations(t *testing.T) { } server, k := setupNovaMockServer(handler) defer server.Close() - nova := novaAPI{} + nova := novaClient{} nova.sc = &gophercloud.ServiceClient{ ProviderClient: k.Client(), Endpoint: server.URL + "/", diff --git a/internal/scheduling/nova/plugins/detectors/avoid_high_steal_pct.go b/internal/scheduling/nova/plugins/detectors/avoid_high_steal_pct.go index b956fd26c..dae180c5a 100644 --- a/internal/scheduling/nova/plugins/detectors/avoid_high_steal_pct.go +++ b/internal/scheduling/nova/plugins/detectors/avoid_high_steal_pct.go @@ -72,3 +72,7 @@ func (s *AvoidHighStealPctStep) Run() ([]plugins.VMDetection, error) { } return decisions, nil } + +func init() { + Index["avoid_high_steal_pct"] = &AvoidHighStealPctStep{} +} diff --git a/internal/scheduling/nova/supported_detectors.go b/internal/scheduling/nova/plugins/detectors/zz_index.go similarity index 60% rename from internal/scheduling/nova/supported_detectors.go rename to internal/scheduling/nova/plugins/detectors/zz_index.go index 680437962..e643edd13 100644 --- a/internal/scheduling/nova/supported_detectors.go +++ b/internal/scheduling/nova/plugins/detectors/zz_index.go @@ -1,16 +1,13 @@ // Copyright SAP SE // SPDX-License-Identifier: Apache-2.0 -package nova +package detectors import ( "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" "github.com/cobaltcore-dev/cortex/internal/scheduling/nova/plugins" - "github.com/cobaltcore-dev/cortex/internal/scheduling/nova/plugins/detectors" ) // Configuration of steps supported by the descheduler. // The steps actually used by the scheduler are defined through the configuration file. -var supportedDetectors = map[string]lib.Detector[plugins.VMDetection]{ - "avoid_high_steal_pct": &detectors.AvoidHighStealPctStep{}, -} +var Index = map[string]lib.Detector[plugins.VMDetection]{} diff --git a/internal/scheduling/nova/plugins/filters/filter_allowed_projects.go b/internal/scheduling/nova/plugins/filters/filter_allowed_projects.go index 16c75d5d7..c973eae32 100644 --- a/internal/scheduling/nova/plugins/filters/filter_allowed_projects.go +++ b/internal/scheduling/nova/plugins/filters/filter_allowed_projects.go @@ -45,3 +45,7 @@ func (s *FilterAllowedProjectsStep) Run(traceLog *slog.Logger, request api.Exter } return result, nil } + +func init() { + Index["filter_allowed_projects"] = func() NovaFilter { return &FilterAllowedProjectsStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_capabilities.go b/internal/scheduling/nova/plugins/filters/filter_capabilities.go index 0366df41f..d5e14a3a8 100644 --- a/internal/scheduling/nova/plugins/filters/filter_capabilities.go +++ b/internal/scheduling/nova/plugins/filters/filter_capabilities.go @@ -112,3 +112,7 @@ func (s *FilterCapabilitiesStep) Run(traceLog *slog.Logger, request api.External } return result, nil } + +func init() { + Index["filter_capabilities"] = func() NovaFilter { return &FilterCapabilitiesStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_correct_az.go b/internal/scheduling/nova/plugins/filters/filter_correct_az.go index f91b57d9a..dd23f7e3e 100644 --- a/internal/scheduling/nova/plugins/filters/filter_correct_az.go +++ b/internal/scheduling/nova/plugins/filters/filter_correct_az.go @@ -59,3 +59,7 @@ func (s *FilterCorrectAZStep) Run(traceLog *slog.Logger, request api.ExternalSch } return result, nil } + +func init() { + Index["filter_correct_az"] = func() NovaFilter { return &FilterCorrectAZStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_external_customer.go b/internal/scheduling/nova/plugins/filters/filter_external_customer.go index 49d9de046..11e7e0b4f 100644 --- a/internal/scheduling/nova/plugins/filters/filter_external_customer.go +++ b/internal/scheduling/nova/plugins/filters/filter_external_customer.go @@ -80,3 +80,7 @@ func (s *FilterExternalCustomerStep) Run(traceLog *slog.Logger, request api.Exte } return result, nil } + +func init() { + Index["filter_external_customer"] = func() NovaFilter { return &FilterExternalCustomerStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_has_accelerators.go b/internal/scheduling/nova/plugins/filters/filter_has_accelerators.go index 1e3bdb726..874ac3e75 100644 --- a/internal/scheduling/nova/plugins/filters/filter_has_accelerators.go +++ b/internal/scheduling/nova/plugins/filters/filter_has_accelerators.go @@ -51,3 +51,7 @@ func (s *FilterHasAcceleratorsStep) Run(traceLog *slog.Logger, request api.Exter } return result, nil } + +func init() { + Index["filter_has_accelerators"] = func() NovaFilter { return &FilterHasAcceleratorsStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_has_enough_capacity.go b/internal/scheduling/nova/plugins/filters/filter_has_enough_capacity.go index 7bd12c69f..a45f46845 100644 --- a/internal/scheduling/nova/plugins/filters/filter_has_enough_capacity.go +++ b/internal/scheduling/nova/plugins/filters/filter_has_enough_capacity.go @@ -176,3 +176,7 @@ func (s *FilterHasEnoughCapacity) Run(traceLog *slog.Logger, request api.Externa } return result, nil } + +func init() { + Index["filter_has_enough_capacity"] = func() NovaFilter { return &FilterHasEnoughCapacity{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_has_requested_traits.go b/internal/scheduling/nova/plugins/filters/filter_has_requested_traits.go index 05095ac67..c617f16d3 100644 --- a/internal/scheduling/nova/plugins/filters/filter_has_requested_traits.go +++ b/internal/scheduling/nova/plugins/filters/filter_has_requested_traits.go @@ -80,3 +80,7 @@ func (s *FilterHasRequestedTraits) Run(traceLog *slog.Logger, request api.Extern } return result, nil } + +func init() { + Index["filter_has_requested_traits"] = func() NovaFilter { return &FilterHasRequestedTraits{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_host_instructions.go b/internal/scheduling/nova/plugins/filters/filter_host_instructions.go index 42562d244..509c5df40 100644 --- a/internal/scheduling/nova/plugins/filters/filter_host_instructions.go +++ b/internal/scheduling/nova/plugins/filters/filter_host_instructions.go @@ -36,3 +36,7 @@ func (s *FilterHostInstructionsStep) Run(traceLog *slog.Logger, request api.Exte } return result, nil } + +func init() { + Index["filter_host_instructions"] = func() NovaFilter { return &FilterHostInstructionsStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_instance_group_affinity.go b/internal/scheduling/nova/plugins/filters/filter_instance_group_affinity.go index ec5569d23..574b57aa2 100644 --- a/internal/scheduling/nova/plugins/filters/filter_instance_group_affinity.go +++ b/internal/scheduling/nova/plugins/filters/filter_instance_group_affinity.go @@ -49,3 +49,7 @@ func (s *FilterInstanceGroupAffinityStep) Run( } return result, nil } + +func init() { + Index["filter_instance_group_affinity"] = func() NovaFilter { return &FilterInstanceGroupAffinityStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_instance_group_anti_affinity.go b/internal/scheduling/nova/plugins/filters/filter_instance_group_anti_affinity.go index bdd6c0910..fa97089a0 100644 --- a/internal/scheduling/nova/plugins/filters/filter_instance_group_anti_affinity.go +++ b/internal/scheduling/nova/plugins/filters/filter_instance_group_anti_affinity.go @@ -95,3 +95,7 @@ func (s *FilterInstanceGroupAntiAffinityStep) Run( } return result, nil } + +func init() { + Index["filter_instance_group_anti_affinity"] = func() NovaFilter { return &FilterInstanceGroupAntiAffinityStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_live_migratable.go b/internal/scheduling/nova/plugins/filters/filter_live_migratable.go index 4ae1a2365..8295118f6 100644 --- a/internal/scheduling/nova/plugins/filters/filter_live_migratable.go +++ b/internal/scheduling/nova/plugins/filters/filter_live_migratable.go @@ -114,3 +114,7 @@ func (s *FilterLiveMigratableStep) Run( } return result, nil } + +func init() { + Index["filter_live_migratable"] = func() NovaFilter { return &FilterLiveMigratableStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_maintenance.go b/internal/scheduling/nova/plugins/filters/filter_maintenance.go index de81adefc..41fd7faed 100644 --- a/internal/scheduling/nova/plugins/filters/filter_maintenance.go +++ b/internal/scheduling/nova/plugins/filters/filter_maintenance.go @@ -63,3 +63,7 @@ func (s *FilterMaintenanceStep) Run(traceLog *slog.Logger, request api.ExternalS } return result, nil } + +func init() { + Index["filter_maintenance"] = func() NovaFilter { return &FilterMaintenanceStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_packed_virtqueue.go b/internal/scheduling/nova/plugins/filters/filter_packed_virtqueue.go index 248ebe6a8..28825163b 100644 --- a/internal/scheduling/nova/plugins/filters/filter_packed_virtqueue.go +++ b/internal/scheduling/nova/plugins/filters/filter_packed_virtqueue.go @@ -52,3 +52,7 @@ func (s *FilterPackedVirtqueueStep) Run(traceLog *slog.Logger, request api.Exter } return result, nil } + +func init() { + Index["filter_packed_virtqueue"] = func() NovaFilter { return &FilterPackedVirtqueueStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_requested_destination.go b/internal/scheduling/nova/plugins/filters/filter_requested_destination.go index 55e542c32..2f3c2bf51 100644 --- a/internal/scheduling/nova/plugins/filters/filter_requested_destination.go +++ b/internal/scheduling/nova/plugins/filters/filter_requested_destination.go @@ -85,3 +85,7 @@ func (s *FilterRequestedDestinationStep) Run( return result, nil } + +func init() { + Index["filter_requested_destination"] = func() NovaFilter { return &FilterRequestedDestinationStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/filter_status_conditions.go b/internal/scheduling/nova/plugins/filters/filter_status_conditions.go index daa1a5249..dc859587a 100644 --- a/internal/scheduling/nova/plugins/filters/filter_status_conditions.go +++ b/internal/scheduling/nova/plugins/filters/filter_status_conditions.go @@ -80,3 +80,7 @@ func (s *FilterStatusConditionsStep) Run(traceLog *slog.Logger, request api.Exte } return result, nil } + +func init() { + Index["filter_status_conditions"] = func() NovaFilter { return &FilterStatusConditionsStep{} } +} diff --git a/internal/scheduling/nova/plugins/filters/zz_index.go b/internal/scheduling/nova/plugins/filters/zz_index.go new file mode 100644 index 000000000..23e183879 --- /dev/null +++ b/internal/scheduling/nova/plugins/filters/zz_index.go @@ -0,0 +1,14 @@ +// Copyright SAP SE +// SPDX-License-Identifier: Apache-2.0 + +package filters + +import ( + api "github.com/cobaltcore-dev/cortex/api/delegation/nova" + "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" +) + +type NovaFilter = lib.Filter[api.ExternalSchedulerRequest] + +// Configuration of filters supported by the nova scheduler. +var Index = map[string]func() NovaFilter{} diff --git a/internal/scheduling/nova/plugins/weighers/vmware_anti_affinity_noisy_projects.go b/internal/scheduling/nova/plugins/weighers/vmware_anti_affinity_noisy_projects.go index 181cada8b..829c21bc9 100644 --- a/internal/scheduling/nova/plugins/weighers/vmware_anti_affinity_noisy_projects.go +++ b/internal/scheduling/nova/plugins/weighers/vmware_anti_affinity_noisy_projects.go @@ -94,3 +94,9 @@ func (s *VMwareAntiAffinityNoisyProjectsStep) Run(traceLog *slog.Logger, request } return result, nil } + +func init() { + Index["vmware_anti_affinity_noisy_projects"] = func() lib.Weigher[api.ExternalSchedulerRequest] { + return &VMwareAntiAffinityNoisyProjectsStep{} + } +} diff --git a/internal/scheduling/nova/plugins/weighers/vmware_avoid_long_term_contended_hosts.go b/internal/scheduling/nova/plugins/weighers/vmware_avoid_long_term_contended_hosts.go index e58679f55..a462546c1 100644 --- a/internal/scheduling/nova/plugins/weighers/vmware_avoid_long_term_contended_hosts.go +++ b/internal/scheduling/nova/plugins/weighers/vmware_avoid_long_term_contended_hosts.go @@ -112,3 +112,9 @@ func (s *VMwareAvoidLongTermContendedHostsStep) Run(traceLog *slog.Logger, reque } return result, nil } + +func init() { + Index["vmware_avoid_long_term_contended_hosts"] = func() lib.Weigher[api.ExternalSchedulerRequest] { + return &VMwareAvoidLongTermContendedHostsStep{} + } +} diff --git a/internal/scheduling/nova/plugins/weighers/vmware_avoid_short_term_contended_hosts.go b/internal/scheduling/nova/plugins/weighers/vmware_avoid_short_term_contended_hosts.go index 21a55ced6..105616d84 100644 --- a/internal/scheduling/nova/plugins/weighers/vmware_avoid_short_term_contended_hosts.go +++ b/internal/scheduling/nova/plugins/weighers/vmware_avoid_short_term_contended_hosts.go @@ -112,3 +112,9 @@ func (s *VMwareAvoidShortTermContendedHostsStep) Run(traceLog *slog.Logger, requ } return result, nil } + +func init() { + Index["vmware_avoid_short_term_contended_hosts"] = func() lib.Weigher[api.ExternalSchedulerRequest] { + return &VMwareAvoidShortTermContendedHostsStep{} + } +} diff --git a/internal/scheduling/nova/plugins/weighers/vmware_general_purpose_balancing.go b/internal/scheduling/nova/plugins/weighers/vmware_general_purpose_balancing.go index db2086a86..dba5eb46b 100644 --- a/internal/scheduling/nova/plugins/weighers/vmware_general_purpose_balancing.go +++ b/internal/scheduling/nova/plugins/weighers/vmware_general_purpose_balancing.go @@ -134,3 +134,9 @@ func (s *VMwareGeneralPurposeBalancingStep) Run(traceLog *slog.Logger, request a return result, nil } + +func init() { + Index["vmware_general_purpose_balancing"] = func() lib.Weigher[api.ExternalSchedulerRequest] { + return &VMwareGeneralPurposeBalancingStep{} + } +} diff --git a/internal/scheduling/nova/plugins/weighers/vmware_hana_binpacking.go b/internal/scheduling/nova/plugins/weighers/vmware_hana_binpacking.go index 704d66ba6..e96ee981b 100644 --- a/internal/scheduling/nova/plugins/weighers/vmware_hana_binpacking.go +++ b/internal/scheduling/nova/plugins/weighers/vmware_hana_binpacking.go @@ -151,3 +151,9 @@ func (s *VMwareHanaBinpackingStep) Run(traceLog *slog.Logger, request api.Extern return result, nil } + +func init() { + Index["vmware_hana_binpacking"] = func() lib.Weigher[api.ExternalSchedulerRequest] { + return &VMwareHanaBinpackingStep{} + } +} diff --git a/internal/scheduling/nova/plugins/weighers/zz_index.go b/internal/scheduling/nova/plugins/weighers/zz_index.go new file mode 100644 index 000000000..8fd923f4e --- /dev/null +++ b/internal/scheduling/nova/plugins/weighers/zz_index.go @@ -0,0 +1,14 @@ +// Copyright SAP SE +// SPDX-License-Identifier: Apache-2.0 + +package weighers + +import ( + api "github.com/cobaltcore-dev/cortex/api/delegation/nova" + "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" +) + +type NovaWeigher = lib.Weigher[api.ExternalSchedulerRequest] + +// Configuration of weighers supported by the nova scheduler. +var Index = map[string]func() NovaWeigher{} diff --git a/internal/scheduling/nova/supported_filters.go b/internal/scheduling/nova/supported_filters.go deleted file mode 100644 index 2b5554b1f..000000000 --- a/internal/scheduling/nova/supported_filters.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright SAP SE -// SPDX-License-Identifier: Apache-2.0 - -package nova - -import ( - api "github.com/cobaltcore-dev/cortex/api/delegation/nova" - "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" - "github.com/cobaltcore-dev/cortex/internal/scheduling/nova/plugins/filters" -) - -type NovaFilter = lib.Filter[api.ExternalSchedulerRequest] - -// Configuration of filters supported by the nova scheduler. -var supportedFilters = map[string]func() NovaFilter{ - "filter_has_accelerators": func() NovaFilter { return &filters.FilterHasAcceleratorsStep{} }, - "filter_correct_az": func() NovaFilter { return &filters.FilterCorrectAZStep{} }, - "filter_status_conditions": func() NovaFilter { return &filters.FilterStatusConditionsStep{} }, - "filter_maintenance": func() NovaFilter { return &filters.FilterMaintenanceStep{} }, - "filter_packed_virtqueue": func() NovaFilter { return &filters.FilterPackedVirtqueueStep{} }, - "filter_external_customer": func() NovaFilter { return &filters.FilterExternalCustomerStep{} }, - "filter_allowed_projects": func() NovaFilter { return &filters.FilterAllowedProjectsStep{} }, - "filter_capabilities": func() NovaFilter { return &filters.FilterCapabilitiesStep{} }, - "filter_has_requested_traits": func() NovaFilter { return &filters.FilterHasRequestedTraits{} }, - "filter_has_enough_capacity": func() NovaFilter { return &filters.FilterHasEnoughCapacity{} }, - "filter_host_instructions": func() NovaFilter { return &filters.FilterHostInstructionsStep{} }, - "filter_instance_group_affinity": func() NovaFilter { return &filters.FilterInstanceGroupAffinityStep{} }, - "filter_instance_group_anti_affinity": func() NovaFilter { return &filters.FilterInstanceGroupAntiAffinityStep{} }, - "filter_live_migratable": func() NovaFilter { return &filters.FilterLiveMigratableStep{} }, - "filter_requested_destination": func() NovaFilter { return &filters.FilterRequestedDestinationStep{} }, -} diff --git a/internal/scheduling/nova/supported_weighers.go b/internal/scheduling/nova/supported_weighers.go deleted file mode 100644 index 11bfb28eb..000000000 --- a/internal/scheduling/nova/supported_weighers.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright SAP SE -// SPDX-License-Identifier: Apache-2.0 - -package nova - -import ( - api "github.com/cobaltcore-dev/cortex/api/delegation/nova" - "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" - "github.com/cobaltcore-dev/cortex/internal/scheduling/nova/plugins/weighers" -) - -type NovaWeigher = lib.Weigher[api.ExternalSchedulerRequest] - -// Configuration of weighers supported by the nova scheduler. -var supportedWeighers = map[string]func() NovaWeigher{ - "vmware_anti_affinity_noisy_projects": func() NovaWeigher { return &weighers.VMwareAntiAffinityNoisyProjectsStep{} }, - "vmware_avoid_long_term_contended_hosts": func() NovaWeigher { return &weighers.VMwareAvoidLongTermContendedHostsStep{} }, - "vmware_avoid_short_term_contended_hosts": func() NovaWeigher { return &weighers.VMwareAvoidShortTermContendedHostsStep{} }, - "vmware_hana_binpacking": func() NovaWeigher { return &weighers.VMwareHanaBinpackingStep{} }, - "vmware_general_purpose_balancing": func() NovaWeigher { return &weighers.VMwareGeneralPurposeBalancingStep{} }, -} diff --git a/internal/scheduling/pods/filter_weigher_pipeline_controller.go b/internal/scheduling/pods/filter_weigher_pipeline_controller.go index 888fcabcc..6ae6cdf7d 100644 --- a/internal/scheduling/pods/filter_weigher_pipeline_controller.go +++ b/internal/scheduling/pods/filter_weigher_pipeline_controller.go @@ -16,6 +16,8 @@ import ( "github.com/cobaltcore-dev/cortex/pkg/multicluster" "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" + "github.com/cobaltcore-dev/cortex/internal/scheduling/pods/plugins/filters" + "github.com/cobaltcore-dev/cortex/internal/scheduling/pods/plugins/weighers" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -201,8 +203,8 @@ func (c *FilterWeigherPipelineController) InitPipeline( return lib.InitNewFilterWeigherPipeline( ctx, c.Client, p.Name, - supportedFilters, p.Spec.Filters, - supportedWeighers, p.Spec.Weighers, + filters.Index, p.Spec.Filters, + weighers.Index, p.Spec.Weighers, c.Monitor, ) } diff --git a/internal/scheduling/pods/plugins/filters/filter_node_affinity.go b/internal/scheduling/pods/plugins/filters/filter_node_affinity.go index c378fe6c5..aac981e56 100644 --- a/internal/scheduling/pods/plugins/filters/filter_node_affinity.go +++ b/internal/scheduling/pods/plugins/filters/filter_node_affinity.go @@ -116,3 +116,7 @@ func matchesNodeSelectorRequirement(node corev1.Node, req corev1.NodeSelectorReq return false } } + +func init() { + Index["nodeaffinity"] = func() PodFilter { return &NodeAffinityFilter{} } +} diff --git a/internal/scheduling/pods/plugins/filters/filter_node_available.go b/internal/scheduling/pods/plugins/filters/filter_node_available.go index 02aca3896..d49dd1c22 100644 --- a/internal/scheduling/pods/plugins/filters/filter_node_available.go +++ b/internal/scheduling/pods/plugins/filters/filter_node_available.go @@ -66,3 +66,7 @@ func isNodeHealthy(node corev1.Node) bool { func isNodeSchedulable(node corev1.Node) bool { return !node.Spec.Unschedulable } + +func init() { + Index["nodeavailable"] = func() PodFilter { return &NodeAvailableFilter{} } +} diff --git a/internal/scheduling/pods/plugins/filters/filter_node_capacity.go b/internal/scheduling/pods/plugins/filters/filter_node_capacity.go index f148aaecf..7188e7a73 100644 --- a/internal/scheduling/pods/plugins/filters/filter_node_capacity.go +++ b/internal/scheduling/pods/plugins/filters/filter_node_capacity.go @@ -52,3 +52,7 @@ func hasCapacityForPod(node corev1.Node, podRequests corev1.ResourceList) bool { return true } + +func init() { + Index["nodecapacity"] = func() PodFilter { return &NodeCapacityFilter{} } +} diff --git a/internal/scheduling/pods/plugins/filters/filter_noop.go b/internal/scheduling/pods/plugins/filters/filter_noop.go index 006c2d868..399ffe202 100644 --- a/internal/scheduling/pods/plugins/filters/filter_noop.go +++ b/internal/scheduling/pods/plugins/filters/filter_noop.go @@ -36,3 +36,7 @@ func (NoopFilter) Run(traceLog *slog.Logger, request pods.PodPipelineRequest) (* } return &lib.FilterWeigherPipelineStepResult{Activations: activations, Statistics: stats}, nil } + +func init() { + Index["noop"] = func() PodFilter { return &NoopFilter{} } +} diff --git a/internal/scheduling/pods/plugins/filters/filter_taint.go b/internal/scheduling/pods/plugins/filters/filter_taint.go index d02af1849..d3e467351 100644 --- a/internal/scheduling/pods/plugins/filters/filter_taint.go +++ b/internal/scheduling/pods/plugins/filters/filter_taint.go @@ -59,3 +59,7 @@ func hasToleration(pod corev1.Pod, taint corev1.Taint) bool { } return false } + +func init() { + Index["taint"] = func() PodFilter { return &TaintFilter{} } +} diff --git a/internal/scheduling/pods/plugins/filters/zz_index.go b/internal/scheduling/pods/plugins/filters/zz_index.go new file mode 100644 index 000000000..9662dfd72 --- /dev/null +++ b/internal/scheduling/pods/plugins/filters/zz_index.go @@ -0,0 +1,14 @@ +// Copyright SAP SE +// SPDX-License-Identifier: Apache-2.0 + +package filters + +import ( + "github.com/cobaltcore-dev/cortex/api/delegation/pods" + "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" +) + +type PodFilter = lib.Filter[pods.PodPipelineRequest] + +// Configuration of filters supported by the pods scheduler. +var Index = map[string]func() PodFilter{} diff --git a/internal/scheduling/pods/plugins/weighers/binpack.go b/internal/scheduling/pods/plugins/weighers/binpack.go index 62a345694..c151cf9cf 100644 --- a/internal/scheduling/pods/plugins/weighers/binpack.go +++ b/internal/scheduling/pods/plugins/weighers/binpack.go @@ -79,3 +79,7 @@ func (s *BinpackingStep) calculateBinpackScore(node corev1.Node, podResources co return math.Min(1.0, totalWeightedUtilization/totalWeight) } + +func init() { + Index["binpack"] = func() PodWeigher { return &BinpackingStep{} } +} diff --git a/internal/scheduling/pods/supported_weighers.go b/internal/scheduling/pods/plugins/weighers/zz_index.go similarity index 58% rename from internal/scheduling/pods/supported_weighers.go rename to internal/scheduling/pods/plugins/weighers/zz_index.go index 7fae5b073..f4e1a8035 100644 --- a/internal/scheduling/pods/supported_weighers.go +++ b/internal/scheduling/pods/plugins/weighers/zz_index.go @@ -1,17 +1,14 @@ // Copyright SAP SE // SPDX-License-Identifier: Apache-2.0 -package pods +package weighers import ( "github.com/cobaltcore-dev/cortex/api/delegation/pods" "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" - "github.com/cobaltcore-dev/cortex/internal/scheduling/pods/plugins/weighers" ) type PodWeigher = lib.Weigher[pods.PodPipelineRequest] // Configuration of weighers supported by the pods scheduler. -var supportedWeighers = map[string]func() PodWeigher{ - "binpack": func() PodWeigher { return &weighers.BinpackingStep{} }, -} +var Index = map[string]func() PodWeigher{} diff --git a/internal/scheduling/pods/supported_filters.go b/internal/scheduling/pods/supported_filters.go deleted file mode 100644 index 4c39652d3..000000000 --- a/internal/scheduling/pods/supported_filters.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright SAP SE -// SPDX-License-Identifier: Apache-2.0 - -package pods - -import ( - "github.com/cobaltcore-dev/cortex/api/delegation/pods" - "github.com/cobaltcore-dev/cortex/internal/scheduling/lib" - "github.com/cobaltcore-dev/cortex/internal/scheduling/pods/plugins/filters" -) - -type PodFilter = lib.Filter[pods.PodPipelineRequest] - -// Configuration of filters supported by the pods scheduler. -var supportedFilters = map[string]func() PodFilter{ - "noop": func() PodFilter { return &filters.NoopFilter{} }, - "taint": func() PodFilter { return &filters.TaintFilter{} }, - "nodeaffinity": func() PodFilter { return &filters.NodeAffinityFilter{} }, - "nodecapacity": func() PodFilter { return &filters.NodeCapacityFilter{} }, -} diff --git a/postgres/Dockerfile b/postgres/Dockerfile index bc16cface..b29fb9edd 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -1,4 +1,4 @@ -# Last updated: 18 Nov 2025 +# Last updated: 28 Jan 2026 FROM debian:trixie-slim # explicitly set user/group IDs