diff --git a/api/v1alpha1/common_types.go b/api/v1alpha1/common_types.go new file mode 100644 index 00000000..a6ba2db3 --- /dev/null +++ b/api/v1alpha1/common_types.go @@ -0,0 +1,28 @@ +// Copyright SAP SE +// SPDX-License-Identifier: Apache-2.0 + +package v1alpha1 + +// SchedulingDomain reflects the logical domain for scheduling. +type SchedulingDomain string + +const ( + // SchedulingDomainNova indicates scheduling related to the + // openstack Nova service, which is the compute service responsible for + // managing virtual machines in an openstack cloud infrastructure. + SchedulingDomainNova SchedulingDomain = "nova" + // SchedulingDomainCinder indicates scheduling related to the + // openstack Cinder service, which is the block storage service responsible + // for managing volumes in an openstack cloud infrastructure. + SchedulingDomainCinder SchedulingDomain = "cinder" + // SchedulingDomainManila indicates scheduling related to the openstack + // Manila service, which is the shared file system service responsible + // for managing shared file systems in an openstack cloud infrastructure. + SchedulingDomainManila SchedulingDomain = "manila" + // SchedulingDomainMachines indicates scheduling related to the ironcore + // machines, which are virtual machines managed by the ironcore platform. + SchedulingDomainMachines SchedulingDomain = "machines" + // SchedulingDomainPods indicates scheduling related to Kubernetes pods, + // which are the smallest deployable units in a Kubernetes cluster. + SchedulingDomainPods SchedulingDomain = "pods" +) diff --git a/api/v1alpha1/datasource_types.go b/api/v1alpha1/datasource_types.go index 5677d48b..edf0af56 100644 --- a/api/v1alpha1/datasource_types.go +++ b/api/v1alpha1/datasource_types.go @@ -193,8 +193,9 @@ const ( ) type DatasourceSpec struct { - // The operator by which this datasource should be synced. - Operator string `json:"operator,omitempty"` + // SchedulingDomain defines in which scheduling domain this datasource + // is used (e.g., nova, cinder, manila). + SchedulingDomain SchedulingDomain `json:"schedulingDomain"` // If given, configures a Prometheus datasource to fetch. // Type must be set to "prometheus" if this is used. diff --git a/api/v1alpha1/decision_types.go b/api/v1alpha1/decision_types.go index b4d96ed1..bca60953 100644 --- a/api/v1alpha1/decision_types.go +++ b/api/v1alpha1/decision_types.go @@ -9,27 +9,10 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) -// The type of decision. -type DecisionType string - -const ( - // The decision was created by the nova external scheduler call. - // Usually we refer to this as nova initial placement, it also includes - // migrations or resizes. - DecisionTypeNovaServer DecisionType = "nova-server" - // The decision was created by the cinder external scheduler call. - DecisionTypeCinderVolume DecisionType = "cinder-volume" - // The decision was created by the manila external scheduler call. - DecisionTypeManilaShare DecisionType = "manila-share" - // The decision was created by spawning an ironcore machine. - DecisionTypeIroncoreMachine DecisionType = "ironcore-machine" - // The decision was created for a pod. - DecisionTypePod DecisionType = "pod" -) - type DecisionSpec struct { - // The operator by which this decision should be extracted. - Operator string `json:"operator,omitempty"` + // SchedulingDomain defines in which scheduling domain this decision + // was or is processed (e.g., nova, cinder, manila). + SchedulingDomain SchedulingDomain `json:"schedulingDomain"` // A reference to the pipeline that should be used for this decision. // This reference can be used to look up the pipeline definition and its @@ -41,8 +24,6 @@ type DecisionSpec struct { // This can be used to correlate multiple decisions for the same resource. ResourceID string `json:"resourceID"` - // The type of decision, indicating what has initiated this decision. - Type DecisionType `json:"type"` // If the type is "nova", this field contains the raw nova decision request. // +kubebuilder:validation:Optional NovaRaw *runtime.RawExtension `json:"novaRaw,omitempty"` diff --git a/api/v1alpha1/knowledge_types.go b/api/v1alpha1/knowledge_types.go index b478e915..b567a882 100644 --- a/api/v1alpha1/knowledge_types.go +++ b/api/v1alpha1/knowledge_types.go @@ -35,8 +35,9 @@ type KnowledgeExtractorSpec struct { } type KnowledgeSpec struct { - // The operator by which this knowledge should be extracted. - Operator string `json:"operator,omitempty"` + // SchedulingDomain defines in which scheduling domain this knowledge + // is used (e.g., nova, cinder, manila). + SchedulingDomain SchedulingDomain `json:"schedulingDomain"` // The feature extractor to use for extracting this knowledge. Extractor KnowledgeExtractorSpec `json:"extractor,omitempty"` diff --git a/api/v1alpha1/kpi_types.go b/api/v1alpha1/kpi_types.go index ffb552d2..67ca509b 100644 --- a/api/v1alpha1/kpi_types.go +++ b/api/v1alpha1/kpi_types.go @@ -24,8 +24,9 @@ type KPIDependenciesSpec struct { } type KPISpec struct { - // The operator by which this kpi should be executed. - Operator string `json:"operator,omitempty"` + // SchedulingDomain defines in which scheduling domain this kpi + // is used (e.g., nova, cinder, manila). + SchedulingDomain SchedulingDomain `json:"schedulingDomain"` // The name of the kpi in the cortex implementation. Impl string `json:"impl"` diff --git a/api/v1alpha1/pipeline_types.go b/api/v1alpha1/pipeline_types.go index 250f2551..7e98765c 100644 --- a/api/v1alpha1/pipeline_types.go +++ b/api/v1alpha1/pipeline_types.go @@ -28,8 +28,9 @@ const ( ) type PipelineSpec struct { - // The operator by which this pipeline should be handled. - Operator string `json:"operator,omitempty"` + // SchedulingDomain defines in which scheduling domain this pipeline + // is used (e.g., nova, cinder, manila). + SchedulingDomain SchedulingDomain `json:"schedulingDomain"` // An optional description of the pipeline. // +kubebuilder:validation:Optional Description string `json:"description,omitempty"` diff --git a/api/v1alpha1/step_types.go b/api/v1alpha1/step_types.go index 23df33c9..7356adc3 100644 --- a/api/v1alpha1/step_types.go +++ b/api/v1alpha1/step_types.go @@ -39,8 +39,9 @@ type WeigherSpec struct { } type StepSpec struct { - // The operator by which this step should be executed. - Operator string `json:"operator,omitempty"` + // SchedulingDomain defines in which scheduling domain this step + // is used (e.g., nova, cinder, manila). + SchedulingDomain SchedulingDomain `json:"schedulingDomain"` // The type of the scheduler step. Type StepType `json:"type"` diff --git a/cmd/main.go b/cmd/main.go index 35a7f271..61930393 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -301,7 +301,6 @@ func main() { } // Inferred through the base controller. decisionController.Client = multiclusterClient - decisionController.OperatorName = config.Operator if err := (decisionController).SetupWithManager(mgr, multiclusterClient); err != nil { setupLog.Error(err, "unable to create controller", "controller", "DecisionReconciler") os.Exit(1) @@ -319,7 +318,6 @@ func main() { } // Inferred through the base controller. deschedulingsController.Client = multiclusterClient - deschedulingsController.OperatorName = config.Operator if err := (deschedulingsController).SetupWithManager(mgr, multiclusterClient); err != nil { setupLog.Error(err, "unable to create controller", "controller", "DeschedulingsReconciler") os.Exit(1) @@ -341,7 +339,6 @@ func main() { } // Inferred through the base controller. controller.Client = multiclusterClient - controller.OperatorName = config.Operator if err := (controller).SetupWithManager(mgr, multiclusterClient); err != nil { setupLog.Error(err, "unable to create controller", "controller", "DecisionReconciler") os.Exit(1) @@ -355,7 +352,6 @@ func main() { } // Inferred through the base controller. controller.Client = multiclusterClient - controller.OperatorName = config.Operator if err := (controller).SetupWithManager(mgr, multiclusterClient); err != nil { setupLog.Error(err, "unable to create controller", "controller", "DecisionReconciler") os.Exit(1) @@ -369,7 +365,6 @@ func main() { } // Inferred through the base controller. controller.Client = multiclusterClient - controller.OperatorName = config.Operator if err := (controller).SetupWithManager(mgr, multiclusterClient); err != nil { setupLog.Error(err, "unable to create controller", "controller", "DecisionReconciler") os.Exit(1) @@ -382,7 +377,6 @@ func main() { } // Inferred through the base controller. controller.Client = multiclusterClient - controller.OperatorName = config.Operator if err := (controller).SetupWithManager(mgr, multiclusterClient); err != nil { setupLog.Error(err, "unable to create controller", "controller", "DecisionReconciler") os.Exit(1) @@ -392,8 +386,10 @@ func main() { // Setup a controller which will reconcile the history and explanation for // decision resources. explanationController := &explanation.Controller{ - Client: multiclusterClient, - OperatorName: config.Operator, + Client: multiclusterClient, + // The explanation controller is compatible with multiple scheduling + // domains. + SchedulingDomain: config.SchedulingDomain, } if err := explanationController.SetupWithManager(mgr, multiclusterClient); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ExplanationController") @@ -458,8 +454,10 @@ func main() { } if slices.Contains(config.EnabledControllers, "kpis-controller") { if err := (&kpis.Controller{ - Client: multiclusterClient, - OperatorName: config.Operator, + Client: multiclusterClient, + // The kpis controller is compatible with multiple scheduling + // domains. + SchedulingDomain: config.SchedulingDomain, }).SetupWithManager(mgr, multiclusterClient); err != nil { setupLog.Error(err, "unable to create controller", "controller", "KPIController") os.Exit(1) diff --git a/config/crd/bases/cortex.cloud_datasources.yaml b/config/crd/bases/cortex.cloud_datasources.yaml index 5c7db43c..04be7c46 100644 --- a/config/crd/bases/cortex.cloud_datasources.yaml +++ b/config/crd/bases/cortex.cloud_datasources.yaml @@ -191,9 +191,6 @@ spec: - syncInterval - type type: object - operator: - description: The operator by which this datasource should be synced. - type: string prometheus: description: |- If given, configures a Prometheus datasource to fetch. @@ -250,6 +247,11 @@ spec: - timeRange - type type: object + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this datasource + is used (e.g., nova, cinder, manila). + type: string ssoSecretRef: description: |- Kubernetes secret ref for an optional sso certificate to access the host. @@ -270,6 +272,7 @@ spec: type: string required: - databaseSecretRef + - schedulingDomain - type type: object status: diff --git a/config/crd/bases/cortex.cloud_decisions.yaml b/config/crd/bases/cortex.cloud_decisions.yaml index 90542a9d..a2240e73 100644 --- a/config/crd/bases/cortex.cloud_decisions.yaml +++ b/config/crd/bases/cortex.cloud_decisions.yaml @@ -123,9 +123,6 @@ spec: decision request. type: object x-kubernetes-preserve-unknown-fields: true - operator: - description: The operator by which this decision should be extracted. - type: string pipelineRef: description: |- A reference to the pipeline that should be used for this decision. @@ -221,14 +218,15 @@ spec: For example, this can be the UUID of a nova instance or cinder volume. This can be used to correlate multiple decisions for the same resource. type: string - type: - description: The type of decision, indicating what has initiated this - decision. + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this decision + was or is processed (e.g., nova, cinder, manila). type: string required: - pipelineRef - resourceID - - type + - schedulingDomain type: object status: description: status defines the observed state of Decision diff --git a/config/crd/bases/cortex.cloud_knowledges.yaml b/config/crd/bases/cortex.cloud_knowledges.yaml index 75cbb552..796269fc 100644 --- a/config/crd/bases/cortex.cloud_knowledges.yaml +++ b/config/crd/bases/cortex.cloud_knowledges.yaml @@ -173,17 +173,20 @@ spec: description: The name of the extractor. type: string type: object - operator: - description: The operator by which this knowledge should be extracted. - type: string recency: default: 60s description: |- The desired recency of this knowledge, i.e. how old it can be until it needs to be re-extracted. type: string + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this knowledge + is used (e.g., nova, cinder, manila). + type: string required: - recency + - schedulingDomain type: object status: description: status defines the observed state of Knowledge diff --git a/config/crd/bases/cortex.cloud_kpis.yaml b/config/crd/bases/cortex.cloud_kpis.yaml index 25381bc2..48f96ac7 100644 --- a/config/crd/bases/cortex.cloud_kpis.yaml +++ b/config/crd/bases/cortex.cloud_kpis.yaml @@ -158,16 +158,19 @@ spec: impl: description: The name of the kpi in the cortex implementation. type: string - operator: - description: The operator by which this kpi should be executed. - type: string opts: description: Additional configuration for the extractor that can be used type: object x-kubernetes-preserve-unknown-fields: true + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this kpi + is used (e.g., nova, cinder, manila). + type: string required: - impl + - schedulingDomain type: object status: description: status defines the observed state of KPI diff --git a/config/crd/bases/cortex.cloud_pipelines.yaml b/config/crd/bases/cortex.cloud_pipelines.yaml index 2b8e8194..7b9f4baa 100644 --- a/config/crd/bases/cortex.cloud_pipelines.yaml +++ b/config/crd/bases/cortex.cloud_pipelines.yaml @@ -64,8 +64,10 @@ spec: description: description: An optional description of the pipeline. type: string - operator: - description: The operator by which this pipeline should be handled. + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this pipeline + is used (e.g., nova, cinder, manila). type: string steps: description: The ordered list of steps that make up this pipeline. @@ -128,6 +130,7 @@ spec: description: The type of the pipeline. type: string required: + - schedulingDomain - type type: object status: diff --git a/config/crd/bases/cortex.cloud_steps.yaml b/config/crd/bases/cortex.cloud_steps.yaml index b66e46ad..1fc817a6 100644 --- a/config/crd/bases/cortex.cloud_steps.yaml +++ b/config/crd/bases/cortex.cloud_steps.yaml @@ -110,14 +110,16 @@ spec: type: object x-kubernetes-map-type: atomic type: array - operator: - description: The operator by which this step should be executed. - type: string opts: description: Additional configuration for the extractor that can be used type: object x-kubernetes-preserve-unknown-fields: true + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this step + is used (e.g., nova, cinder, manila). + type: string type: description: The type of the scheduler step. type: string @@ -146,6 +148,7 @@ spec: type: object required: - impl + - schedulingDomain - type type: object status: diff --git a/config/crd/cortex.cloud_datasources.yaml b/config/crd/cortex.cloud_datasources.yaml index 5c7db43c..04be7c46 100644 --- a/config/crd/cortex.cloud_datasources.yaml +++ b/config/crd/cortex.cloud_datasources.yaml @@ -191,9 +191,6 @@ spec: - syncInterval - type type: object - operator: - description: The operator by which this datasource should be synced. - type: string prometheus: description: |- If given, configures a Prometheus datasource to fetch. @@ -250,6 +247,11 @@ spec: - timeRange - type type: object + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this datasource + is used (e.g., nova, cinder, manila). + type: string ssoSecretRef: description: |- Kubernetes secret ref for an optional sso certificate to access the host. @@ -270,6 +272,7 @@ spec: type: string required: - databaseSecretRef + - schedulingDomain - type type: object status: diff --git a/config/crd/cortex.cloud_decisions.yaml b/config/crd/cortex.cloud_decisions.yaml index 90542a9d..a2240e73 100644 --- a/config/crd/cortex.cloud_decisions.yaml +++ b/config/crd/cortex.cloud_decisions.yaml @@ -123,9 +123,6 @@ spec: decision request. type: object x-kubernetes-preserve-unknown-fields: true - operator: - description: The operator by which this decision should be extracted. - type: string pipelineRef: description: |- A reference to the pipeline that should be used for this decision. @@ -221,14 +218,15 @@ spec: For example, this can be the UUID of a nova instance or cinder volume. This can be used to correlate multiple decisions for the same resource. type: string - type: - description: The type of decision, indicating what has initiated this - decision. + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this decision + was or is processed (e.g., nova, cinder, manila). type: string required: - pipelineRef - resourceID - - type + - schedulingDomain type: object status: description: status defines the observed state of Decision diff --git a/config/crd/cortex.cloud_knowledges.yaml b/config/crd/cortex.cloud_knowledges.yaml index 75cbb552..796269fc 100644 --- a/config/crd/cortex.cloud_knowledges.yaml +++ b/config/crd/cortex.cloud_knowledges.yaml @@ -173,17 +173,20 @@ spec: description: The name of the extractor. type: string type: object - operator: - description: The operator by which this knowledge should be extracted. - type: string recency: default: 60s description: |- The desired recency of this knowledge, i.e. how old it can be until it needs to be re-extracted. type: string + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this knowledge + is used (e.g., nova, cinder, manila). + type: string required: - recency + - schedulingDomain type: object status: description: status defines the observed state of Knowledge diff --git a/config/crd/cortex.cloud_kpis.yaml b/config/crd/cortex.cloud_kpis.yaml index 25381bc2..48f96ac7 100644 --- a/config/crd/cortex.cloud_kpis.yaml +++ b/config/crd/cortex.cloud_kpis.yaml @@ -158,16 +158,19 @@ spec: impl: description: The name of the kpi in the cortex implementation. type: string - operator: - description: The operator by which this kpi should be executed. - type: string opts: description: Additional configuration for the extractor that can be used type: object x-kubernetes-preserve-unknown-fields: true + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this kpi + is used (e.g., nova, cinder, manila). + type: string required: - impl + - schedulingDomain type: object status: description: status defines the observed state of KPI diff --git a/config/crd/cortex.cloud_pipelines.yaml b/config/crd/cortex.cloud_pipelines.yaml index 2b8e8194..7b9f4baa 100644 --- a/config/crd/cortex.cloud_pipelines.yaml +++ b/config/crd/cortex.cloud_pipelines.yaml @@ -64,8 +64,10 @@ spec: description: description: An optional description of the pipeline. type: string - operator: - description: The operator by which this pipeline should be handled. + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this pipeline + is used (e.g., nova, cinder, manila). type: string steps: description: The ordered list of steps that make up this pipeline. @@ -128,6 +130,7 @@ spec: description: The type of the pipeline. type: string required: + - schedulingDomain - type type: object status: diff --git a/config/crd/cortex.cloud_steps.yaml b/config/crd/cortex.cloud_steps.yaml index b66e46ad..1fc817a6 100644 --- a/config/crd/cortex.cloud_steps.yaml +++ b/config/crd/cortex.cloud_steps.yaml @@ -110,14 +110,16 @@ spec: type: object x-kubernetes-map-type: atomic type: array - operator: - description: The operator by which this step should be executed. - type: string opts: description: Additional configuration for the extractor that can be used type: object x-kubernetes-preserve-unknown-fields: true + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this step + is used (e.g., nova, cinder, manila). + type: string type: description: The type of the scheduler step. type: string @@ -146,6 +148,7 @@ spec: type: object required: - impl + - schedulingDomain - type type: object status: diff --git a/dist/chart/templates/crd/cortex.cloud_datasources.yaml b/dist/chart/templates/crd/cortex.cloud_datasources.yaml index 1e1b4e3b..8783eb50 100644 --- a/dist/chart/templates/crd/cortex.cloud_datasources.yaml +++ b/dist/chart/templates/crd/cortex.cloud_datasources.yaml @@ -197,9 +197,6 @@ spec: - syncInterval - type type: object - operator: - description: The operator by which this datasource should be synced. - type: string prometheus: description: |- If given, configures a Prometheus datasource to fetch. @@ -256,6 +253,11 @@ spec: - timeRange - type type: object + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this datasource + is used (e.g., nova, cinder, manila). + type: string ssoSecretRef: description: |- Kubernetes secret ref for an optional sso certificate to access the host. @@ -276,6 +278,7 @@ spec: type: string required: - databaseSecretRef + - schedulingDomain - type type: object status: diff --git a/dist/chart/templates/crd/cortex.cloud_decisions.yaml b/dist/chart/templates/crd/cortex.cloud_decisions.yaml index f0d72b62..768e4dd0 100644 --- a/dist/chart/templates/crd/cortex.cloud_decisions.yaml +++ b/dist/chart/templates/crd/cortex.cloud_decisions.yaml @@ -129,9 +129,6 @@ spec: decision request. type: object x-kubernetes-preserve-unknown-fields: true - operator: - description: The operator by which this decision should be extracted. - type: string pipelineRef: description: |- A reference to the pipeline that should be used for this decision. @@ -227,14 +224,15 @@ spec: For example, this can be the UUID of a nova instance or cinder volume. This can be used to correlate multiple decisions for the same resource. type: string - type: - description: The type of decision, indicating what has initiated this - decision. + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this decision + was or is processed (e.g., nova, cinder, manila). type: string required: - pipelineRef - resourceID - - type + - schedulingDomain type: object status: description: status defines the observed state of Decision diff --git a/dist/chart/templates/crd/cortex.cloud_knowledges.yaml b/dist/chart/templates/crd/cortex.cloud_knowledges.yaml index 237b9b82..0e152eb3 100644 --- a/dist/chart/templates/crd/cortex.cloud_knowledges.yaml +++ b/dist/chart/templates/crd/cortex.cloud_knowledges.yaml @@ -179,17 +179,20 @@ spec: description: The name of the extractor. type: string type: object - operator: - description: The operator by which this knowledge should be extracted. - type: string recency: default: 60s description: |- The desired recency of this knowledge, i.e. how old it can be until it needs to be re-extracted. type: string + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this knowledge + is used (e.g., nova, cinder, manila). + type: string required: - recency + - schedulingDomain type: object status: description: status defines the observed state of Knowledge diff --git a/dist/chart/templates/crd/cortex.cloud_kpis.yaml b/dist/chart/templates/crd/cortex.cloud_kpis.yaml index de2dd6b5..85e95ff6 100644 --- a/dist/chart/templates/crd/cortex.cloud_kpis.yaml +++ b/dist/chart/templates/crd/cortex.cloud_kpis.yaml @@ -164,16 +164,19 @@ spec: impl: description: The name of the kpi in the cortex implementation. type: string - operator: - description: The operator by which this kpi should be executed. - type: string opts: description: Additional configuration for the extractor that can be used type: object x-kubernetes-preserve-unknown-fields: true + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this kpi + is used (e.g., nova, cinder, manila). + type: string required: - impl + - schedulingDomain type: object status: description: status defines the observed state of KPI diff --git a/dist/chart/templates/crd/cortex.cloud_pipelines.yaml b/dist/chart/templates/crd/cortex.cloud_pipelines.yaml index 71d27865..d5e20e8b 100644 --- a/dist/chart/templates/crd/cortex.cloud_pipelines.yaml +++ b/dist/chart/templates/crd/cortex.cloud_pipelines.yaml @@ -70,8 +70,10 @@ spec: description: description: An optional description of the pipeline. type: string - operator: - description: The operator by which this pipeline should be handled. + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this pipeline + is used (e.g., nova, cinder, manila). type: string steps: description: The ordered list of steps that make up this pipeline. @@ -134,6 +136,7 @@ spec: description: The type of the pipeline. type: string required: + - schedulingDomain - type type: object status: diff --git a/dist/chart/templates/crd/cortex.cloud_steps.yaml b/dist/chart/templates/crd/cortex.cloud_steps.yaml index 3d3379fd..10825841 100644 --- a/dist/chart/templates/crd/cortex.cloud_steps.yaml +++ b/dist/chart/templates/crd/cortex.cloud_steps.yaml @@ -116,14 +116,16 @@ spec: type: object x-kubernetes-map-type: atomic type: array - operator: - description: The operator by which this step should be executed. - type: string opts: description: Additional configuration for the extractor that can be used type: object x-kubernetes-preserve-unknown-fields: true + schedulingDomain: + description: |- + SchedulingDomain defines in which scheduling domain this step + is used (e.g., nova, cinder, manila). + type: string type: description: The type of the scheduler step. type: string @@ -152,6 +154,7 @@ spec: type: object required: - impl + - schedulingDomain - type type: object status: diff --git a/dist/chart/values.yaml b/dist/chart/values.yaml index 4ced4388..50a9d48c 100644 --- a/dist/chart/values.yaml +++ b/dist/chart/values.yaml @@ -102,8 +102,8 @@ global: # Use this to unambiguate multiple cortex deployments in the same cluster. namePrefix: cortex conf: - # The operator will only touch CRs with this operator name. - operator: cortex + # The scheduling domain this operator is responsible for. + schedulingDomain: cortex # Used to differentiate different cortex deployments in the same cluster (e.g. leader election ID) leaderElectionID: cortex-unknown enabledControllers: diff --git a/helm/bundles/cortex-cinder/templates/datasources.yaml b/helm/bundles/cortex-cinder/templates/datasources.yaml index c7e51607..340f225b 100644 --- a/helm/bundles/cortex-cinder/templates/datasources.yaml +++ b/helm/bundles/cortex-cinder/templates/datasources.yaml @@ -4,7 +4,7 @@ kind: Datasource metadata: name: netapp-aggr-labels-cinder spec: - operator: cortex-cinder + schedulingDomain: cinder databaseSecretRef: name: cortex-cinder-postgres namespace: {{ .Release.Namespace }} @@ -27,7 +27,7 @@ kind: Datasource metadata: name: netapp-node-cpu-busy-cinder spec: - operator: cortex-cinder + schedulingDomain: cinder databaseSecretRef: name: cortex-cinder-postgres namespace: {{ .Release.Namespace }} @@ -50,7 +50,7 @@ kind: Datasource metadata: name: netapp-volume-aggr-labels spec: - operator: cortex-cinder + schedulingDomain: cinder databaseSecretRef: name: cortex-cinder-postgres namespace: {{ .Release.Namespace }} @@ -73,7 +73,7 @@ kind: Datasource metadata: name: cinder-storage-pools spec: - operator: cortex-cinder + schedulingDomain: cinder databaseSecretRef: name: cortex-cinder-postgres namespace: {{ .Release.Namespace }} diff --git a/helm/bundles/cortex-cinder/templates/knowledges.yaml b/helm/bundles/cortex-cinder/templates/knowledges.yaml index c5de6f88..9a0be3e2 100644 --- a/helm/bundles/cortex-cinder/templates/knowledges.yaml +++ b/helm/bundles/cortex-cinder/templates/knowledges.yaml @@ -4,7 +4,7 @@ kind: Knowledge metadata: name: netapp-storage-pool-cpu-usage-cinder spec: - operator: cortex-cinder + schedulingDomain: cinder extractor: name: netapp_storage_pool_cpu_usage_extractor description: | diff --git a/helm/bundles/cortex-cinder/templates/kpis.yaml b/helm/bundles/cortex-cinder/templates/kpis.yaml index b91e68e2..9f3d7634 100644 --- a/helm/bundles/cortex-cinder/templates/kpis.yaml +++ b/helm/bundles/cortex-cinder/templates/kpis.yaml @@ -4,10 +4,10 @@ kind: KPI metadata: name: cortex-cinder-datasource-state spec: - operator: cortex-cinder + schedulingDomain: cinder impl: datasource_state_kpi opts: - datasourceOperator: cortex-cinder + datasourceSchedulingDomain: cortex-cinder description: | This KPI tracks the state of datasource resources managed by cortex. --- @@ -16,10 +16,10 @@ kind: KPI metadata: name: cortex-cinder-knowledge-state spec: - operator: cortex-cinder + schedulingDomain: cinder impl: knowledge_state_kpi opts: - knowledgeOperator: cortex-cinder + knowledgeSchedulingDomain: cortex-cinder description: | This KPI tracks the state of knowledge resources managed by cortex. --- @@ -28,10 +28,10 @@ kind: KPI metadata: name: cortex-cinder-decision-state spec: - operator: cortex-cinder + schedulingDomain: cinder impl: decision_state_kpi opts: - decisionOperator: cortex-cinder + decisionSchedulingDomain: cortex-cinder description: | This aggregated KPI tracks the state of decision resources managed by cortex. --- @@ -40,10 +40,10 @@ kind: KPI metadata: name: cortex-cinder-kpi-state spec: - operator: cortex-cinder + schedulingDomain: cinder impl: kpi_state_kpi opts: - kpiOperator: cortex-cinder + kpiSchedulingDomain: cortex-cinder description: | This KPI tracks the state of kpi resources managed by cortex. --- @@ -52,10 +52,10 @@ kind: KPI metadata: name: cortex-cinder-pipeline-state spec: - operator: cortex-cinder + schedulingDomain: cinder impl: pipeline_state_kpi opts: - pipelineOperator: cortex-cinder + pipelineSchedulingDomain: cortex-cinder description: | This KPI tracks the state of pipeline resources managed by cortex. --- @@ -64,9 +64,9 @@ kind: KPI metadata: name: cortex-cinder-step-state spec: - operator: cortex-cinder + schedulingDomain: cinder impl: step_state_kpi opts: - stepOperator: cortex-cinder + stepSchedulingDomain: cortex-cinder description: | This KPI tracks the state of step resources managed by cortex. diff --git a/helm/bundles/cortex-cinder/templates/pipelines.yaml b/helm/bundles/cortex-cinder/templates/pipelines.yaml index d5d18a27..1e876cff 100644 --- a/helm/bundles/cortex-cinder/templates/pipelines.yaml +++ b/helm/bundles/cortex-cinder/templates/pipelines.yaml @@ -4,7 +4,7 @@ kind: Pipeline metadata: name: cinder-external-scheduler spec: - operator: cortex-cinder + schedulingDomain: cinder description: | Cinder provides block storage volume placement on storage hosts for OpenStack. After applying its own filtering and weighing logic, it delegates to cortex diff --git a/helm/bundles/cortex-cinder/values.yaml b/helm/bundles/cortex-cinder/values.yaml index b3b48d90..33f28772 100644 --- a/helm/bundles/cortex-cinder/values.yaml +++ b/helm/bundles/cortex-cinder/values.yaml @@ -69,7 +69,7 @@ cortex: &cortex metrics: {enable: false} prometheus: {enable: false} conf: &cortexConf - operator: cortex-cinder + schedulingDomain: cinder keystoneSecretRef: name: cortex-cinder-openstack-keystone namespace: default diff --git a/helm/bundles/cortex-ironcore/templates/pipelines.yaml b/helm/bundles/cortex-ironcore/templates/pipelines.yaml index 6b087bfb..60d7dae1 100644 --- a/helm/bundles/cortex-ironcore/templates/pipelines.yaml +++ b/helm/bundles/cortex-ironcore/templates/pipelines.yaml @@ -4,7 +4,7 @@ kind: Pipeline metadata: name: machines-scheduler spec: - operator: cortex-ironcore + schedulingDomain: machines description: | This pipeline is used to schedule ironcore machines onto machinepools. type: filter-weigher diff --git a/helm/bundles/cortex-ironcore/templates/steps.yaml b/helm/bundles/cortex-ironcore/templates/steps.yaml index 76266f84..f2a15990 100644 --- a/helm/bundles/cortex-ironcore/templates/steps.yaml +++ b/helm/bundles/cortex-ironcore/templates/steps.yaml @@ -4,7 +4,7 @@ kind: Step metadata: name: machinepools-noop spec: - operator: cortex-ironcore + schedulingDomain: machines type: weigher impl: noop description: | diff --git a/helm/bundles/cortex-ironcore/values.yaml b/helm/bundles/cortex-ironcore/values.yaml index 5f6b7b2e..29458a2b 100644 --- a/helm/bundles/cortex-ironcore/values.yaml +++ b/helm/bundles/cortex-ironcore/values.yaml @@ -25,8 +25,8 @@ cortex: # Use this to unambiguate multiple cortex deployments in the same cluster. namePrefix: cortex-ironcore conf: - # The operator will only touch CRs with this operator name. - operator: cortex-ironcore + # The operator will only touch CRs with this scheduling domain name. + schedulingDomain: machines enabledControllers: - ironcore-decisions-pipeline-controller - explanation-controller diff --git a/helm/bundles/cortex-manila/templates/datasources.yaml b/helm/bundles/cortex-manila/templates/datasources.yaml index e4c0d056..b940e718 100644 --- a/helm/bundles/cortex-manila/templates/datasources.yaml +++ b/helm/bundles/cortex-manila/templates/datasources.yaml @@ -4,7 +4,7 @@ kind: Datasource metadata: name: netapp-aggr-labels-manila spec: - operator: cortex-manila + schedulingDomain: manila databaseSecretRef: name: cortex-manila-postgres namespace: {{ .Release.Namespace }} @@ -27,7 +27,7 @@ kind: Datasource metadata: name: netapp-node-cpu-busy-manila spec: - operator: cortex-manila + schedulingDomain: manila databaseSecretRef: name: cortex-manila-postgres namespace: {{ .Release.Namespace }} @@ -50,7 +50,7 @@ kind: Datasource metadata: name: manila-storage-pools spec: - operator: cortex-manila + schedulingDomain: manila databaseSecretRef: name: cortex-manila-postgres namespace: {{ .Release.Namespace }} diff --git a/helm/bundles/cortex-manila/templates/knowledges.yaml b/helm/bundles/cortex-manila/templates/knowledges.yaml index e0346fd2..2ae77d9d 100644 --- a/helm/bundles/cortex-manila/templates/knowledges.yaml +++ b/helm/bundles/cortex-manila/templates/knowledges.yaml @@ -4,7 +4,7 @@ kind: Knowledge metadata: name: netapp-storage-pool-cpu-usage-manila spec: - operator: cortex-manila + schedulingDomain: manila extractor: name: netapp_storage_pool_cpu_usage_extractor description: | diff --git a/helm/bundles/cortex-manila/templates/kpis.yaml b/helm/bundles/cortex-manila/templates/kpis.yaml index 1197a578..efac5e5e 100644 --- a/helm/bundles/cortex-manila/templates/kpis.yaml +++ b/helm/bundles/cortex-manila/templates/kpis.yaml @@ -4,7 +4,7 @@ kind: KPI metadata: name: netapp-storage-pool-cpu-usage-manila spec: - operator: cortex-manila + schedulingDomain: manila impl: netapp_storage_pool_cpu_usage_kpi dependencies: knowledges: @@ -17,7 +17,7 @@ kind: KPI metadata: name: cortex-manila-datasource-state spec: - operator: cortex-manila + schedulingDomain: manila impl: datasource_state_kpi opts: datasourceOperator: cortex-manila @@ -29,7 +29,7 @@ kind: KPI metadata: name: cortex-manila-knowledge-state spec: - operator: cortex-manila + schedulingDomain: manila impl: knowledge_state_kpi opts: knowledgeOperator: cortex-manila @@ -41,7 +41,7 @@ kind: KPI metadata: name: cortex-manila-decision-state spec: - operator: cortex-manila + schedulingDomain: manila impl: decision_state_kpi opts: decisionOperator: cortex-manila @@ -53,7 +53,7 @@ kind: KPI metadata: name: cortex-manila-kpi-state spec: - operator: cortex-manila + schedulingDomain: manila impl: kpi_state_kpi opts: kpiOperator: cortex-manila @@ -65,7 +65,7 @@ kind: KPI metadata: name: cortex-manila-pipeline-state spec: - operator: cortex-manila + schedulingDomain: manila impl: pipeline_state_kpi opts: pipelineOperator: cortex-manila @@ -77,7 +77,7 @@ kind: KPI metadata: name: cortex-manila-step-state spec: - operator: cortex-manila + schedulingDomain: manila impl: step_state_kpi opts: stepOperator: cortex-manila diff --git a/helm/bundles/cortex-manila/templates/pipelines.yaml b/helm/bundles/cortex-manila/templates/pipelines.yaml index 0291e9a3..60970fb1 100644 --- a/helm/bundles/cortex-manila/templates/pipelines.yaml +++ b/helm/bundles/cortex-manila/templates/pipelines.yaml @@ -4,7 +4,7 @@ kind: Pipeline metadata: name: manila-external-scheduler spec: - operator: cortex-manila + schedulingDomain: manila description: | Manila provides shared file system placement on storage hosts for OpenStack. After applying its own filtering and weighing logic, it delegates to cortex diff --git a/helm/bundles/cortex-manila/templates/steps.yaml b/helm/bundles/cortex-manila/templates/steps.yaml index 5197bdf6..5ec8882d 100644 --- a/helm/bundles/cortex-manila/templates/steps.yaml +++ b/helm/bundles/cortex-manila/templates/steps.yaml @@ -4,7 +4,7 @@ kind: Step metadata: name: netapp-cpu-usage-balancing-manila spec: - operator: cortex-manila + schedulingDomain: manila type: weigher impl: netapp_cpu_usage_balancing description: | diff --git a/helm/bundles/cortex-manila/values.yaml b/helm/bundles/cortex-manila/values.yaml index 9af9fb54..cf74e444 100644 --- a/helm/bundles/cortex-manila/values.yaml +++ b/helm/bundles/cortex-manila/values.yaml @@ -69,7 +69,7 @@ cortex: &cortex metrics: {enable: false} prometheus: {enable: false} conf: &cortexConf - operator: cortex-manila + schedulingDomain: manila keystoneSecretRef: name: cortex-manila-openstack-keystone namespace: default diff --git a/helm/bundles/cortex-nova/templates/datasources.yaml b/helm/bundles/cortex-nova/templates/datasources.yaml index 89e0d434..8da1906a 100644 --- a/helm/bundles/cortex-nova/templates/datasources.yaml +++ b/helm/bundles/cortex-nova/templates/datasources.yaml @@ -4,7 +4,7 @@ kind: Datasource metadata: name: vrops-virtualmachine-cpu-demand-ratio spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -27,7 +27,7 @@ kind: Datasource metadata: name: vrops-hostsystem-cpu-contention-long-term-percentage spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -50,7 +50,7 @@ kind: Datasource metadata: name: vrops-hostsystem-cpu-contention-short-term-percentage spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -76,7 +76,7 @@ kind: Datasource metadata: name: kvm-libvirt-domain-steal-pct spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -105,7 +105,7 @@ kind: Datasource metadata: name: nova-servers spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -128,7 +128,7 @@ kind: Datasource metadata: name: nova-deleted-servers spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -151,7 +151,7 @@ kind: Datasource metadata: name: nova-hypervisors spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -174,7 +174,7 @@ kind: Datasource metadata: name: nova-flavors spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -197,7 +197,7 @@ kind: Datasource metadata: name: nova-migrations spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -220,7 +220,7 @@ kind: Datasource metadata: name: nova-aggregates spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -243,7 +243,7 @@ kind: Datasource metadata: name: placement-resource-providers spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -266,7 +266,7 @@ kind: Datasource metadata: name: placement-resource-provider-traits spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -289,7 +289,7 @@ kind: Datasource metadata: name: placement-resource-provider-inventory-usages spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -312,7 +312,7 @@ kind: Datasource metadata: name: identity-domains spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -335,7 +335,7 @@ kind: Datasource metadata: name: identity-projects spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} @@ -358,7 +358,7 @@ kind: Datasource metadata: name: limes-project-commitments spec: - operator: cortex-nova + schedulingDomain: nova databaseSecretRef: name: cortex-nova-postgres namespace: {{ .Release.Namespace }} diff --git a/helm/bundles/cortex-nova/templates/knowledges.yaml b/helm/bundles/cortex-nova/templates/knowledges.yaml index b142fecb..28952fd1 100644 --- a/helm/bundles/cortex-nova/templates/knowledges.yaml +++ b/helm/bundles/cortex-nova/templates/knowledges.yaml @@ -4,7 +4,7 @@ kind: Knowledge metadata: name: vmware-resolved-hostsystems spec: - operator: cortex-nova + schedulingDomain: nova extractor: name: vrops_hostsystem_resolver description: | @@ -24,7 +24,7 @@ kind: Knowledge metadata: name: vmware-project-noisiness spec: - operator: cortex-nova + schedulingDomain: nova extractor: name: vrops_project_noisiness_extractor description: | @@ -42,7 +42,7 @@ kind: Knowledge metadata: name: vmware-long-term-contended-hosts spec: - operator: cortex-nova + schedulingDomain: nova extractor: name: vrops_hostsystem_contention_long_term_extractor description: | @@ -59,7 +59,7 @@ kind: Knowledge metadata: name: vmware-short-term-contended-hosts spec: - operator: cortex-nova + schedulingDomain: nova extractor: name: vrops_hostsystem_contention_short_term_extractor description: | @@ -76,7 +76,7 @@ kind: Knowledge metadata: name: kvm-libvirt-domain-cpu-steal-pct spec: - operator: cortex-nova + schedulingDomain: nova extractor: name: kvm_libvirt_domain_cpu_steal_pct_extractor description: | @@ -92,7 +92,7 @@ kind: Knowledge metadata: name: host-pinned-projects spec: - operator: cortex-nova + schedulingDomain: nova extractor: name: host_pinned_projects_extractor description: | @@ -109,7 +109,7 @@ kind: Knowledge metadata: name: host-utilization spec: - operator: cortex-nova + schedulingDomain: nova extractor: name: host_utilization_extractor description: | @@ -126,7 +126,7 @@ kind: Knowledge metadata: name: host-capabilities spec: - operator: cortex-nova + schedulingDomain: nova extractor: name: host_capabilities_extractor description: | @@ -142,7 +142,7 @@ kind: Knowledge metadata: name: vm-host-residency spec: - operator: cortex-nova + schedulingDomain: nova extractor: name: vm_host_residency_extractor description: | @@ -160,7 +160,7 @@ kind: Knowledge metadata: name: vm-life-span spec: - operator: cortex-nova + schedulingDomain: nova extractor: name: vm_life_span_histogram_extractor description: | @@ -178,7 +178,7 @@ kind: Knowledge metadata: name: host-az spec: - operator: cortex-nova + schedulingDomain: nova extractor: name: host_az_extractor description: | @@ -194,7 +194,7 @@ kind: Knowledge metadata: name: host-details spec: - operator: cortex-nova + schedulingDomain: nova extractor: name: sap_host_details_extractor description: | diff --git a/helm/bundles/cortex-nova/templates/kpis.yaml b/helm/bundles/cortex-nova/templates/kpis.yaml index eb3bcaa2..903a9bb9 100644 --- a/helm/bundles/cortex-nova/templates/kpis.yaml +++ b/helm/bundles/cortex-nova/templates/kpis.yaml @@ -4,7 +4,7 @@ kind: KPI metadata: name: vmware-host-contention spec: - operator: cortex-nova + schedulingDomain: nova impl: vmware_host_contention_kpi dependencies: knowledges: @@ -18,7 +18,7 @@ kind: KPI metadata: name: vmware-project-noisiness spec: - operator: cortex-nova + schedulingDomain: nova impl: vmware_project_noisiness_kpi dependencies: knowledges: @@ -32,7 +32,7 @@ kind: KPI metadata: name: host-total-allocatable-capacity spec: - operator: cortex-nova + schedulingDomain: nova impl: host_total_allocatable_capacity_kpi dependencies: knowledges: @@ -46,7 +46,7 @@ kind: KPI metadata: name: host-capacity spec: - operator: cortex-nova + schedulingDomain: nova impl: host_capacity_kpi dependencies: knowledges: @@ -60,7 +60,7 @@ kind: KPI metadata: name: host-running-vms spec: - operator: cortex-nova + schedulingDomain: nova impl: host_running_vms_kpi dependencies: knowledges: @@ -74,7 +74,7 @@ kind: KPI metadata: name: flavors-running-vms spec: - operator: cortex-nova + schedulingDomain: nova impl: flavor_running_vms_kpi dependencies: datasources: @@ -87,7 +87,7 @@ kind: KPI metadata: name: vm-migration-statistics spec: - operator: cortex-nova + schedulingDomain: nova impl: vm_migration_statistics_kpi dependencies: knowledges: @@ -100,7 +100,7 @@ kind: KPI metadata: name: vm-life-span spec: - operator: cortex-nova + schedulingDomain: nova impl: vm_life_span_kpi dependencies: knowledges: @@ -113,7 +113,7 @@ kind: KPI metadata: name: vm-commitments spec: - operator: cortex-nova + schedulingDomain: nova impl: vm_commitments_kpi dependencies: datasources: @@ -127,7 +127,7 @@ kind: KPI metadata: name: kvm-host-capacity spec: - operator: cortex-nova + schedulingDomain: nova impl: kvm_host_capacity_kpi dependencies: knowledges: @@ -141,7 +141,7 @@ kind: KPI metadata: name: cortex-nova-datasource-state spec: - operator: cortex-nova + schedulingDomain: nova impl: datasource_state_kpi opts: datasourceOperator: cortex-nova @@ -153,7 +153,7 @@ kind: KPI metadata: name: cortex-nova-knowledge-state spec: - operator: cortex-nova + schedulingDomain: nova impl: knowledge_state_kpi opts: knowledgeOperator: cortex-nova @@ -165,7 +165,7 @@ kind: KPI metadata: name: cortex-nova-decision-state spec: - operator: cortex-nova + schedulingDomain: nova impl: decision_state_kpi opts: decisionOperator: cortex-nova @@ -177,7 +177,7 @@ kind: KPI metadata: name: cortex-nova-kpi-state spec: - operator: cortex-nova + schedulingDomain: nova impl: kpi_state_kpi opts: kpiOperator: cortex-nova @@ -189,7 +189,7 @@ kind: KPI metadata: name: cortex-nova-pipeline-state spec: - operator: cortex-nova + schedulingDomain: nova impl: pipeline_state_kpi opts: pipelineOperator: cortex-nova @@ -201,7 +201,7 @@ kind: KPI metadata: name: cortex-nova-step-state spec: - operator: cortex-nova + schedulingDomain: nova impl: step_state_kpi opts: stepOperator: cortex-nova diff --git a/helm/bundles/cortex-nova/templates/pipelines.yaml b/helm/bundles/cortex-nova/templates/pipelines.yaml index 86665690..981ab4b5 100644 --- a/helm/bundles/cortex-nova/templates/pipelines.yaml +++ b/helm/bundles/cortex-nova/templates/pipelines.yaml @@ -5,7 +5,7 @@ kind: Pipeline metadata: name: nova-external-scheduler-vmware spec: - operator: cortex-nova + schedulingDomain: nova description: | Nova provides virtual machine placement on compute hosts for OpenStack. After applying its own filtering and weighing logic, it delegates to cortex @@ -29,7 +29,7 @@ kind: Pipeline metadata: name: nova-external-scheduler-kvm spec: - operator: cortex-nova + schedulingDomain: nova description: | Nova provides virtual machine placement on compute hosts for OpenStack. After applying its own filtering and weighing logic, it delegates to cortex @@ -47,7 +47,7 @@ kind: Pipeline metadata: name: nova-external-scheduler-kvm-all-filters-enabled spec: - operator: cortex-nova + schedulingDomain: nova description: | This pipeline can be used to place reservations the same way nova would place its virtual machines. It uses the same filtering steps as implemented in the @@ -76,7 +76,7 @@ kind: Pipeline metadata: name: nova-descheduler-kvm spec: - operator: cortex-nova + schedulingDomain: nova description: This pipeline runs steps that select virtual machines to deschedule from compute hosts in order to optimize resource usage and performance. diff --git a/helm/bundles/cortex-nova/templates/steps.yaml b/helm/bundles/cortex-nova/templates/steps.yaml index 3c4c118b..c958f74e 100644 --- a/helm/bundles/cortex-nova/templates/steps.yaml +++ b/helm/bundles/cortex-nova/templates/steps.yaml @@ -4,7 +4,7 @@ kind: Step metadata: name: vmware-hana-binpacking spec: - operator: cortex-nova + schedulingDomain: nova type: weigher impl: vmware_hana_binpacking description: | @@ -25,7 +25,7 @@ kind: Step metadata: name: vmware-general-purpose-balancing spec: - operator: cortex-nova + schedulingDomain: nova type: weigher impl: vmware_general_purpose_balancing description: | @@ -46,7 +46,7 @@ kind: Step metadata: name: vmware-avoid-long-term-contended-hosts spec: - operator: cortex-nova + schedulingDomain: nova type: weigher impl: vmware_avoid_long_term_contended_hosts description: | @@ -71,7 +71,7 @@ kind: Step metadata: name: vmware-avoid-short-term-contended-hosts spec: - operator: cortex-nova + schedulingDomain: nova type: weigher impl: vmware_avoid_short_term_contended_hosts description: | @@ -96,7 +96,7 @@ kind: Step metadata: name: filter-host-instructions spec: - operator: cortex-nova + schedulingDomain: nova type: filter impl: filter_host_instructions description: | @@ -110,7 +110,7 @@ kind: Step metadata: name: filter-has-enough-capacity spec: - operator: cortex-nova + schedulingDomain: nova type: filter impl: filter_has_enough_capacity description: | @@ -129,7 +129,7 @@ kind: Step metadata: name: filter-has-requested-traits spec: - operator: cortex-nova + schedulingDomain: nova type: filter impl: filter_has_requested_traits description: | @@ -143,7 +143,7 @@ kind: Step metadata: name: filter-has-accelerators spec: - operator: cortex-nova + schedulingDomain: nova type: filter impl: filter_has_accelerators description: | @@ -155,7 +155,7 @@ kind: Step metadata: name: filter-correct-az spec: - operator: cortex-nova + schedulingDomain: nova type: filter impl: filter_correct_az description: | @@ -167,7 +167,7 @@ kind: Step metadata: name: filter-status-conditions spec: - operator: cortex-nova + schedulingDomain: nova type: filter impl: filter_status_conditions description: | @@ -180,7 +180,7 @@ kind: Step metadata: name: filter-maintenance spec: - operator: cortex-nova + schedulingDomain: nova type: filter impl: filter_maintenance description: | @@ -192,7 +192,7 @@ kind: Step metadata: name: filter-external-customer spec: - operator: cortex-nova + schedulingDomain: nova type: filter impl: filter_external_customer description: | @@ -208,7 +208,7 @@ kind: Step metadata: name: filter-packed-virtqueue spec: - operator: cortex-nova + schedulingDomain: nova type: filter impl: filter_packed_virtqueue description: | @@ -221,7 +221,7 @@ kind: Step metadata: name: filter-allowed-projects spec: - operator: cortex-nova + schedulingDomain: nova type: filter impl: filter_allowed_projects description: | @@ -235,7 +235,7 @@ kind: Step metadata: name: filter-capabilities spec: - operator: cortex-nova + schedulingDomain: nova type: filter impl: filter_capabilities description: | @@ -252,7 +252,7 @@ kind: Step metadata: name: avoid-high-steal-pct spec: - operator: cortex-nova + schedulingDomain: nova type: descheduler impl: avoid_high_steal_pct description: | diff --git a/helm/bundles/cortex-nova/values.yaml b/helm/bundles/cortex-nova/values.yaml index 7fbfbc90..9c78ebbf 100644 --- a/helm/bundles/cortex-nova/values.yaml +++ b/helm/bundles/cortex-nova/values.yaml @@ -74,7 +74,7 @@ cortex: &cortex prometheus: {enable: false} namePrefix: cortex-nova conf: &cortexConf - operator: cortex-nova + schedulingDomain: nova keystoneSecretRef: name: cortex-nova-openstack-keystone namespace: default diff --git a/helm/bundles/cortex-pods/templates/pipelines.yaml b/helm/bundles/cortex-pods/templates/pipelines.yaml index a30f0b79..6059547e 100644 --- a/helm/bundles/cortex-pods/templates/pipelines.yaml +++ b/helm/bundles/cortex-pods/templates/pipelines.yaml @@ -4,7 +4,7 @@ kind: Pipeline metadata: name: pods-scheduler spec: - operator: cortex + schedulingDomain: pods description: | This pipeline is used to schedule pods onto nodes. type: filter-weigher diff --git a/helm/bundles/cortex-pods/templates/steps.yaml b/helm/bundles/cortex-pods/templates/steps.yaml index 8aeec470..ad926bf0 100644 --- a/helm/bundles/cortex-pods/templates/steps.yaml +++ b/helm/bundles/cortex-pods/templates/steps.yaml @@ -4,7 +4,7 @@ kind: Step metadata: name: pods-noop spec: - operator: cortex + schedulingDomain: pods type: filter impl: noop description: | diff --git a/helm/bundles/cortex-pods/values.yaml b/helm/bundles/cortex-pods/values.yaml index 56ceeaad..59828300 100644 --- a/helm/bundles/cortex-pods/values.yaml +++ b/helm/bundles/cortex-pods/values.yaml @@ -25,8 +25,8 @@ cortex: # Use this to unambiguate multiple cortex deployments in the same cluster. namePrefix: cortex-pods conf: - # The operator will only touch CRs with this operator name. - operator: cortex + # The operator will only touch CRs with this scheduling domain name. + schedulingDomain: pods enabledControllers: - pods-decisions-pipeline-controller - explanation-controller diff --git a/internal/knowledge/datasources/openstack/controller.go b/internal/knowledge/datasources/openstack/controller.go index 1110c63c..eb4da8d6 100644 --- a/internal/knowledge/datasources/openstack/controller.go +++ b/internal/knowledge/datasources/openstack/controller.go @@ -217,7 +217,7 @@ func (r *OpenStackDatasourceReconciler) SetupWithManager(mgr manager.Manager, mc builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool { // Only react to datasources matching the operator. ds := obj.(*v1alpha1.Datasource) - if ds.Spec.Operator != r.Conf.Operator { + if ds.Spec.SchedulingDomain != r.Conf.SchedulingDomain { return false } // Only react to openstack datasources. diff --git a/internal/knowledge/datasources/openstack/controller_test.go b/internal/knowledge/datasources/openstack/controller_test.go index 74489665..d498d6eb 100644 --- a/internal/knowledge/datasources/openstack/controller_test.go +++ b/internal/knowledge/datasources/openstack/controller_test.go @@ -32,7 +32,7 @@ func TestOpenStackDatasourceReconciler_Creation(t *testing.T) { Client: client, Scheme: scheme, Monitor: datasources.Monitor{}, - Conf: conf.Config{Operator: "test-operator"}, + Conf: conf.Config{SchedulingDomain: "test-operator"}, } if reconciler.Client == nil { @@ -43,8 +43,8 @@ func TestOpenStackDatasourceReconciler_Creation(t *testing.T) { t.Error("Scheme should not be nil") } - if reconciler.Conf.Operator != "test-operator" { - t.Errorf("Expected operator 'test-operator', got %s", reconciler.Conf.Operator) + if reconciler.Conf.SchedulingDomain != "test-operator" { + t.Errorf("Expected scheduling domain 'test-operator', got %s", reconciler.Conf.SchedulingDomain) } } diff --git a/internal/knowledge/datasources/prometheus/controller.go b/internal/knowledge/datasources/prometheus/controller.go index 31d97f99..6c612da2 100644 --- a/internal/knowledge/datasources/prometheus/controller.go +++ b/internal/knowledge/datasources/prometheus/controller.go @@ -183,7 +183,7 @@ func (r *PrometheusDatasourceReconciler) SetupWithManager(mgr manager.Manager, m builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool { // Only react to datasources matching the operator. ds := obj.(*v1alpha1.Datasource) - if ds.Spec.Operator != r.Conf.Operator { + if ds.Spec.SchedulingDomain != r.Conf.SchedulingDomain { return false } // Only react to prometheus datasources. diff --git a/internal/knowledge/datasources/prometheus/controller_test.go b/internal/knowledge/datasources/prometheus/controller_test.go index 97baaa7a..67b07f83 100644 --- a/internal/knowledge/datasources/prometheus/controller_test.go +++ b/internal/knowledge/datasources/prometheus/controller_test.go @@ -32,7 +32,7 @@ func TestPrometheusDatasourceReconciler_Creation(t *testing.T) { reconciler := &PrometheusDatasourceReconciler{ Client: client, Scheme: scheme, - Conf: conf.Config{Operator: "test-operator"}, + Conf: conf.Config{SchedulingDomain: "test-operator"}, Monitor: datasources.Monitor{}, } @@ -44,8 +44,8 @@ func TestPrometheusDatasourceReconciler_Creation(t *testing.T) { t.Error("Scheme should not be nil") } - if reconciler.Conf.Operator != "test-operator" { - t.Errorf("Expected operator 'test-operator', got %s", reconciler.Conf.Operator) + if reconciler.Conf.SchedulingDomain != "test-operator" { + t.Errorf("Expected scheduling domain 'test-operator', got %s", reconciler.Conf.SchedulingDomain) } } @@ -111,8 +111,8 @@ func TestDatasourceTypeConstants(t *testing.T) { func TestDatasourceSpec(t *testing.T) { // Test creating a complete datasource spec spec := v1alpha1.DatasourceSpec{ - Operator: "test-operator", - Type: v1alpha1.DatasourceTypePrometheus, + SchedulingDomain: "test-operator", + Type: v1alpha1.DatasourceTypePrometheus, Prometheus: v1alpha1.PrometheusDatasource{ Query: "node_cpu_seconds_total", Alias: "node_exporter_host_cpu_usage", @@ -135,8 +135,8 @@ func TestDatasourceSpec(t *testing.T) { }, } - if spec.Operator != "test-operator" { - t.Errorf("Expected operator 'test-operator', got %s", spec.Operator) + if spec.SchedulingDomain != "test-operator" { + t.Errorf("Expected scheduling domain 'test-operator', got %s", spec.SchedulingDomain) } if spec.Type != v1alpha1.DatasourceTypePrometheus { diff --git a/internal/knowledge/extractor/controller.go b/internal/knowledge/extractor/controller.go index 3f74c090..cb7cbad5 100644 --- a/internal/knowledge/extractor/controller.go +++ b/internal/knowledge/extractor/controller.go @@ -200,7 +200,7 @@ func (r *KnowledgeReconciler) SetupWithManager(mgr manager.Manager, mcl *multicl builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool { // Only react to datasources matching the operator. ds := obj.(*v1alpha1.Knowledge) - return ds.Spec.Operator == r.Conf.Operator + return ds.Spec.SchedulingDomain == r.Conf.SchedulingDomain })), ). Complete(r) diff --git a/internal/knowledge/extractor/controller_test.go b/internal/knowledge/extractor/controller_test.go index 6f7a1a89..5e89d351 100644 --- a/internal/knowledge/extractor/controller_test.go +++ b/internal/knowledge/extractor/controller_test.go @@ -37,7 +37,7 @@ func TestKnowledgeReconciler_Reconcile_NonExistentResource(t *testing.T) { Client: fakeClient, Scheme: scheme, Monitor: NewMonitor(), - Conf: conf.Config{Operator: "test-operator"}, + Conf: conf.Config{SchedulingDomain: "test-operator"}, } req := ctrl.Request{ @@ -68,7 +68,7 @@ func TestKnowledgeReconciler_Reconcile_SkipRecentExtraction(t *testing.T) { Client: fakeClient, Scheme: scheme, Monitor: NewMonitor(), - Conf: conf.Config{Operator: "test-operator"}, + Conf: conf.Config{SchedulingDomain: "test-operator"}, } // Create knowledge that was extracted recently @@ -76,8 +76,8 @@ func TestKnowledgeReconciler_Reconcile_SkipRecentExtraction(t *testing.T) { knowledge := &v1alpha1.Knowledge{ ObjectMeta: metav1.ObjectMeta{Name: "recent-knowledge"}, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, Extractor: v1alpha1.KnowledgeExtractorSpec{ Name: "host_utilization_extractor", }, @@ -117,8 +117,8 @@ func TestKnowledgeReconciler_Reconcile_UnsupportedExtractor(t *testing.T) { knowledge := &v1alpha1.Knowledge{ ObjectMeta: metav1.ObjectMeta{Name: "unsupported-extractor"}, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, Extractor: v1alpha1.KnowledgeExtractorSpec{ Name: "unsupported_extractor", }, @@ -133,7 +133,7 @@ func TestKnowledgeReconciler_Reconcile_UnsupportedExtractor(t *testing.T) { Client: fakeClient, Scheme: scheme, Monitor: NewMonitor(), - Conf: conf.Config{Operator: "test-operator"}, + Conf: conf.Config{SchedulingDomain: "test-operator"}, } req := ctrl.Request{ @@ -172,8 +172,8 @@ func TestKnowledgeReconciler_Reconcile_MissingDatasource(t *testing.T) { knowledge := &v1alpha1.Knowledge{ ObjectMeta: metav1.ObjectMeta{Name: "missing-datasource"}, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, Extractor: v1alpha1.KnowledgeExtractorSpec{ Name: "host_utilization_extractor", }, @@ -193,7 +193,7 @@ func TestKnowledgeReconciler_Reconcile_MissingDatasource(t *testing.T) { Client: fakeClient, Scheme: scheme, Monitor: NewMonitor(), - Conf: conf.Config{Operator: "test-operator"}, + Conf: conf.Config{SchedulingDomain: "test-operator"}, } req := ctrl.Request{ @@ -233,7 +233,7 @@ func TestKnowledgeReconciler_Reconcile_DifferentDatabaseSecrets(t *testing.T) { datasource1 := &v1alpha1.Datasource{ ObjectMeta: metav1.ObjectMeta{Name: "datasource-1"}, Spec: v1alpha1.DatasourceSpec{ - Operator: "test-operator", + SchedulingDomain: "test-operator", Type: v1alpha1.DatasourceTypePrometheus, DatabaseSecretRef: corev1.SecretReference{Name: "db-secret-1"}, }, @@ -242,7 +242,7 @@ func TestKnowledgeReconciler_Reconcile_DifferentDatabaseSecrets(t *testing.T) { datasource2 := &v1alpha1.Datasource{ ObjectMeta: metav1.ObjectMeta{Name: "datasource-2"}, Spec: v1alpha1.DatasourceSpec{ - Operator: "test-operator", + SchedulingDomain: "test-operator", Type: v1alpha1.DatasourceTypePrometheus, DatabaseSecretRef: corev1.SecretReference{Name: "db-secret-2"}, }, @@ -251,8 +251,8 @@ func TestKnowledgeReconciler_Reconcile_DifferentDatabaseSecrets(t *testing.T) { knowledge := &v1alpha1.Knowledge{ ObjectMeta: metav1.ObjectMeta{Name: "different-db-secrets"}, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, Extractor: v1alpha1.KnowledgeExtractorSpec{ Name: "host_utilization_extractor", }, @@ -273,7 +273,7 @@ func TestKnowledgeReconciler_Reconcile_DifferentDatabaseSecrets(t *testing.T) { Client: fakeClient, Scheme: scheme, Monitor: NewMonitor(), - Conf: conf.Config{Operator: "test-operator"}, + Conf: conf.Config{SchedulingDomain: "test-operator"}, } req := ctrl.Request{ @@ -310,7 +310,7 @@ func TestKnowledgeReconciler_Reconcile_SameDatabaseSecrets(t *testing.T) { datasource1 := &v1alpha1.Datasource{ ObjectMeta: metav1.ObjectMeta{Name: "datasource-1"}, Spec: v1alpha1.DatasourceSpec{ - Operator: "test-operator", + SchedulingDomain: "test-operator", Type: v1alpha1.DatasourceTypePrometheus, DatabaseSecretRef: corev1.SecretReference{Name: "shared-db-secret"}, }, @@ -319,7 +319,7 @@ func TestKnowledgeReconciler_Reconcile_SameDatabaseSecrets(t *testing.T) { datasource2 := &v1alpha1.Datasource{ ObjectMeta: metav1.ObjectMeta{Name: "datasource-2"}, Spec: v1alpha1.DatasourceSpec{ - Operator: "test-operator", + SchedulingDomain: "test-operator", Type: v1alpha1.DatasourceTypePrometheus, DatabaseSecretRef: corev1.SecretReference{Name: "shared-db-secret"}, }, @@ -328,8 +328,8 @@ func TestKnowledgeReconciler_Reconcile_SameDatabaseSecrets(t *testing.T) { knowledge := &v1alpha1.Knowledge{ ObjectMeta: metav1.ObjectMeta{Name: "same-db-secrets"}, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, Extractor: v1alpha1.KnowledgeExtractorSpec{ Name: "host_utilization_extractor", }, @@ -350,7 +350,7 @@ func TestKnowledgeReconciler_Reconcile_SameDatabaseSecrets(t *testing.T) { Client: fakeClient, Scheme: scheme, Monitor: NewMonitor(), - Conf: conf.Config{Operator: "test-operator"}, + Conf: conf.Config{SchedulingDomain: "test-operator"}, } req := ctrl.Request{ @@ -394,8 +394,8 @@ func TestKnowledgeReconciler_Reconcile_NoDatasources(t *testing.T) { knowledge := &v1alpha1.Knowledge{ ObjectMeta: metav1.ObjectMeta{Name: "no-datasources"}, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, Extractor: v1alpha1.KnowledgeExtractorSpec{ Name: "host_utilization_extractor", }, @@ -410,7 +410,7 @@ func TestKnowledgeReconciler_Reconcile_NoDatasources(t *testing.T) { Client: fakeClient, Scheme: scheme, Monitor: NewMonitor(), - Conf: conf.Config{Operator: "test-operator"}, + Conf: conf.Config{SchedulingDomain: "test-operator"}, } req := ctrl.Request{ @@ -467,8 +467,8 @@ func TestKnowledgeReconciler_Reconcile_SupportedExtractors(t *testing.T) { knowledge := &v1alpha1.Knowledge{ ObjectMeta: metav1.ObjectMeta{Name: "test-" + extractorName}, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, Extractor: v1alpha1.KnowledgeExtractorSpec{ Name: extractorName, }, @@ -483,7 +483,7 @@ func TestKnowledgeReconciler_Reconcile_SupportedExtractors(t *testing.T) { Client: fakeClient, Scheme: scheme, Monitor: NewMonitor(), - Conf: conf.Config{Operator: "test-operator"}, + Conf: conf.Config{SchedulingDomain: "test-operator"}, } req := ctrl.Request{ @@ -516,26 +516,26 @@ func TestKnowledgeReconciler_Reconcile_SupportedExtractors(t *testing.T) { func TestKnowledgeReconciler_OperatorFiltering(t *testing.T) { reconciler := &KnowledgeReconciler{ - Conf: conf.Config{Operator: "test-operator"}, + Conf: conf.Config{SchedulingDomain: "test-operator"}, } // Test the predicate function logic predicateFunc := func(obj client.Object) bool { k := obj.(*v1alpha1.Knowledge) - return k.Spec.Operator == reconciler.Conf.Operator + return k.Spec.SchedulingDomain == reconciler.Conf.SchedulingDomain } knowledge1 := &v1alpha1.Knowledge{ ObjectMeta: metav1.ObjectMeta{Name: "our-operator-knowledge"}, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", // Our operator + SchedulingDomain: "test-operator", // Our operator }, } knowledge2 := &v1alpha1.Knowledge{ ObjectMeta: metav1.ObjectMeta{Name: "other-operator-knowledge"}, Spec: v1alpha1.KnowledgeSpec{ - Operator: "other-operator", // Different operator + SchedulingDomain: "other-operator", // Different operator }, } diff --git a/internal/knowledge/extractor/trigger.go b/internal/knowledge/extractor/trigger.go index 5a3581a5..818f0998 100644 --- a/internal/knowledge/extractor/trigger.go +++ b/internal/knowledge/extractor/trigger.go @@ -100,8 +100,8 @@ func (r *TriggerReconciler) findDependentKnowledge(ctx context.Context, changedR changedResourceName := changedResource.GetName() changedResourceType := getResourceType(changedResource) for _, knowledge := range knowledgeList.Items { - // Only process knowledge for our operator - if knowledge.Spec.Operator != r.Conf.Operator { + // Only process knowledge for our scheduling domain. + if knowledge.Spec.SchedulingDomain != r.Conf.SchedulingDomain { continue } @@ -209,8 +209,8 @@ func (r *TriggerReconciler) mapDatasourceToKnowledge(ctx context.Context, obj cl if !ok { return nil } - // Only process datasources for our operator - if datasource.Spec.Operator != r.Conf.Operator { + // Only process datasources for our scheduling domain + if datasource.Spec.SchedulingDomain != r.Conf.SchedulingDomain { return nil } // Return a request that will trigger our reconciler to find dependents @@ -230,8 +230,8 @@ func (r *TriggerReconciler) mapKnowledgeToKnowledge(ctx context.Context, obj cli if !ok { return nil } - // Only process knowledge for our operator - if knowledge.Spec.Operator != r.Conf.Operator { + // Only process knowledge for our scheduling domain + if knowledge.Spec.SchedulingDomain != r.Conf.SchedulingDomain { return nil } // Return a request that will trigger our reconciler to find dependents @@ -254,7 +254,7 @@ func (r *TriggerReconciler) SetupWithManager(mgr manager.Manager, mcl *multiclus handler.EnqueueRequestsFromMapFunc(r.mapDatasourceToKnowledge), predicate.NewPredicateFuncs(func(obj client.Object) bool { ds := obj.(*v1alpha1.Datasource) - return ds.Spec.Operator == r.Conf.Operator + return ds.Spec.SchedulingDomain == r.Conf.SchedulingDomain }), ). // Watch knowledge changes and map them to trigger reconciliation @@ -263,7 +263,7 @@ func (r *TriggerReconciler) SetupWithManager(mgr manager.Manager, mcl *multiclus handler.EnqueueRequestsFromMapFunc(r.mapKnowledgeToKnowledge), predicate.NewPredicateFuncs(func(obj client.Object) bool { k := obj.(*v1alpha1.Knowledge) - return k.Spec.Operator == r.Conf.Operator + return k.Spec.SchedulingDomain == r.Conf.SchedulingDomain }), ). Named("cortex-knowledge-trigger"). diff --git a/internal/knowledge/extractor/trigger_test.go b/internal/knowledge/extractor/trigger_test.go index d3ba84bb..46af5f24 100644 --- a/internal/knowledge/extractor/trigger_test.go +++ b/internal/knowledge/extractor/trigger_test.go @@ -31,7 +31,7 @@ func setupTestReconciler(t *testing.T) (*TriggerReconciler, client.Client, conte } testConf := conf.Config{ - Operator: "test-operator", + SchedulingDomain: "test-operator", } fakeClient := fake.NewClientBuilder(). @@ -56,8 +56,8 @@ func TestFindDependentKnowledge_DatasourceDependency(t *testing.T) { Name: "test-datasource", }, Spec: v1alpha1.DatasourceSpec{ - Operator: "test-operator", - Type: v1alpha1.DatasourceTypePrometheus, + SchedulingDomain: "test-operator", + Type: v1alpha1.DatasourceTypePrometheus, }, } @@ -67,7 +67,7 @@ func TestFindDependentKnowledge_DatasourceDependency(t *testing.T) { Name: "dependent-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", + SchedulingDomain: "test-operator", Dependencies: v1alpha1.KnowledgeDependenciesSpec{ Datasources: []corev1.ObjectReference{ {Name: "test-datasource"}, @@ -83,8 +83,8 @@ func TestFindDependentKnowledge_DatasourceDependency(t *testing.T) { Name: "independent-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, }, } @@ -120,8 +120,8 @@ func TestFindDependentKnowledge_KnowledgeDependency(t *testing.T) { Name: "source-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, }, } @@ -131,7 +131,7 @@ func TestFindDependentKnowledge_KnowledgeDependency(t *testing.T) { Name: "dependent-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", + SchedulingDomain: "test-operator", Dependencies: v1alpha1.KnowledgeDependenciesSpec{ Knowledges: []corev1.ObjectReference{ {Name: "source-knowledge"}, @@ -170,8 +170,8 @@ func TestFindDependentKnowledge_OperatorFiltering(t *testing.T) { Name: "test-datasource", }, Spec: v1alpha1.DatasourceSpec{ - Operator: "test-operator", - Type: v1alpha1.DatasourceTypePrometheus, + SchedulingDomain: "test-operator", + Type: v1alpha1.DatasourceTypePrometheus, }, } @@ -181,7 +181,7 @@ func TestFindDependentKnowledge_OperatorFiltering(t *testing.T) { Name: "our-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", + SchedulingDomain: "test-operator", Dependencies: v1alpha1.KnowledgeDependenciesSpec{ Datasources: []corev1.ObjectReference{ {Name: "test-datasource"}, @@ -197,7 +197,7 @@ func TestFindDependentKnowledge_OperatorFiltering(t *testing.T) { Name: "other-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "other-operator", + SchedulingDomain: "other-operator", Dependencies: v1alpha1.KnowledgeDependenciesSpec{ Datasources: []corev1.ObjectReference{ {Name: "test-datasource"}, @@ -240,8 +240,8 @@ func TestTriggerKnowledgeReconciliation_ImmediateTrigger(t *testing.T) { Name: "test-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, }, Status: v1alpha1.KnowledgeStatus{ LastExtracted: metav1.NewTime(pastTime), @@ -281,8 +281,8 @@ func TestTriggerKnowledgeReconciliation_ScheduledTrigger(t *testing.T) { Name: "test-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, }, Status: v1alpha1.KnowledgeStatus{ LastExtracted: metav1.NewTime(recentTime), @@ -321,8 +321,8 @@ func TestReconcile_DatasourceChanges(t *testing.T) { Name: "test-datasource", }, Spec: v1alpha1.DatasourceSpec{ - Operator: "test-operator", - Type: v1alpha1.DatasourceTypePrometheus, + SchedulingDomain: "test-operator", + Type: v1alpha1.DatasourceTypePrometheus, }, } @@ -333,7 +333,7 @@ func TestReconcile_DatasourceChanges(t *testing.T) { Name: "dependent-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", + SchedulingDomain: "test-operator", Dependencies: v1alpha1.KnowledgeDependenciesSpec{ Datasources: []corev1.ObjectReference{ {Name: "test-datasource"}, @@ -391,8 +391,8 @@ func TestReconcile_KnowledgeChanges(t *testing.T) { Name: "source-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, }, } @@ -403,7 +403,7 @@ func TestReconcile_KnowledgeChanges(t *testing.T) { Name: "dependent-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", + SchedulingDomain: "test-operator", Dependencies: v1alpha1.KnowledgeDependenciesSpec{ Knowledges: []corev1.ObjectReference{ {Name: "source-knowledge"}, @@ -503,8 +503,8 @@ func TestMapDatasourceToKnowledge_CorrectOperator(t *testing.T) { Name: "test-datasource", }, Spec: v1alpha1.DatasourceSpec{ - Operator: "test-operator", - Type: v1alpha1.DatasourceTypePrometheus, + SchedulingDomain: "test-operator", + Type: v1alpha1.DatasourceTypePrometheus, }, } @@ -525,8 +525,8 @@ func TestMapDatasourceToKnowledge_DifferentOperator(t *testing.T) { Name: "test-datasource", }, Spec: v1alpha1.DatasourceSpec{ - Operator: "other-operator", - Type: v1alpha1.DatasourceTypePrometheus, + SchedulingDomain: "other-operator", + Type: v1alpha1.DatasourceTypePrometheus, }, } @@ -554,8 +554,8 @@ func TestMapKnowledgeToKnowledge_CorrectOperator(t *testing.T) { Name: "test-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "test-operator", + Recency: metav1.Duration{Duration: time.Minute}, }, } @@ -576,8 +576,8 @@ func TestMapKnowledgeToKnowledge_DifferentOperator(t *testing.T) { Name: "test-knowledge", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "other-operator", - Recency: metav1.Duration{Duration: time.Minute}, + SchedulingDomain: "other-operator", + Recency: metav1.Duration{Duration: time.Minute}, }, } diff --git a/internal/knowledge/kpis/controller.go b/internal/knowledge/kpis/controller.go index 7be6580f..9f4bbd46 100644 --- a/internal/knowledge/kpis/controller.go +++ b/internal/knowledge/kpis/controller.go @@ -33,8 +33,8 @@ import ( type Controller struct { // Kubernetes client to manage/fetch resources. client.Client - // The name of the operator to scope resources to. - OperatorName string + // The scheduling domain to scope resources to. + SchedulingDomain v1alpha1.SchedulingDomain // The supported kpis to manage. supportedKPIs map[string]plugins.KPI @@ -101,7 +101,7 @@ func (c *Controller) InitAllKPIs(ctx context.Context) error { return fmt.Errorf("failed to list existing kpis: %w", err) } for _, kpi := range kpis.Items { - if kpi.Spec.Operator != c.OperatorName { + if kpi.Spec.SchedulingDomain != c.SchedulingDomain { continue } err := c.handleKPIChange(ctx, &kpi) @@ -413,9 +413,9 @@ func (c *Controller) SetupWithManager(mgr manager.Manager, mcl *multicluster.Cli DeleteFunc: c.handleDatasourceDeleted, }, predicate.NewPredicateFuncs(func(obj client.Object) bool { - // Only react to datasources matching the operator. + // Only react to datasources matching the scheduling domain. ds := obj.(*v1alpha1.Datasource) - return ds.Spec.Operator == c.OperatorName + return ds.Spec.SchedulingDomain == c.SchedulingDomain }), ). // Watch knowledge changes so that we can reconfigure kpis as needed. @@ -427,18 +427,18 @@ func (c *Controller) SetupWithManager(mgr manager.Manager, mcl *multicluster.Cli DeleteFunc: c.handleKnowledgeDeleted, }, predicate.NewPredicateFuncs(func(obj client.Object) bool { - // Only react to knowledges matching the operator. + // Only react to knowledges matching the scheduling domain. kn := obj.(*v1alpha1.Knowledge) - return kn.Spec.Operator == c.OperatorName + return kn.Spec.SchedulingDomain == c.SchedulingDomain }), ). Named("cortex-kpis"). For( &v1alpha1.KPI{}, builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool { - // Only react to datasources matching the operator. + // Only react to datasources matching the scheduling domain. ds := obj.(*v1alpha1.KPI) - return ds.Spec.Operator == c.OperatorName + return ds.Spec.SchedulingDomain == c.SchedulingDomain })), ). Complete(c) diff --git a/internal/knowledge/kpis/controller_test.go b/internal/knowledge/kpis/controller_test.go index 5c31989b..66e157a3 100644 --- a/internal/knowledge/kpis/controller_test.go +++ b/internal/knowledge/kpis/controller_test.go @@ -294,8 +294,8 @@ func TestController_Reconcile(t *testing.T) { Name: "test-kpi", }, Spec: v1alpha1.KPISpec{ - Operator: "test-operator", - Impl: "test_kpi", + SchedulingDomain: "test-operator", + Impl: "test_kpi", Dependencies: v1alpha1.KPIDependenciesSpec{ Datasources: []corev1.ObjectReference{ {Name: "test-datasource", Namespace: "default"}, @@ -310,7 +310,7 @@ func TestController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DatasourceSpec{ - Operator: "test-operator", + SchedulingDomain: "test-operator", DatabaseSecretRef: corev1.SecretReference{ Name: "db-secret", Namespace: "default", @@ -347,8 +347,8 @@ func TestController_Reconcile(t *testing.T) { Name: "test-kpi-unready", }, Spec: v1alpha1.KPISpec{ - Operator: "test-operator", - Impl: "test_kpi", + SchedulingDomain: "test-operator", + Impl: "test_kpi", Dependencies: v1alpha1.KPIDependenciesSpec{ Datasources: []corev1.ObjectReference{ {Name: "unready-datasource", Namespace: "default"}, @@ -363,7 +363,7 @@ func TestController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DatasourceSpec{ - Operator: "test-operator", + SchedulingDomain: "test-operator", DatabaseSecretRef: corev1.SecretReference{ Name: "db-secret", Namespace: "default", @@ -385,8 +385,8 @@ func TestController_Reconcile(t *testing.T) { Name: "unsupported-kpi", }, Spec: v1alpha1.KPISpec{ - Operator: "test-operator", - Impl: "unsupported_kpi", + SchedulingDomain: "test-operator", + Impl: "unsupported_kpi", }, }, expectedReady: false, @@ -400,8 +400,8 @@ func TestController_Reconcile(t *testing.T) { Name: "no-deps-kpi", }, Spec: v1alpha1.KPISpec{ - Operator: "test-operator", - Impl: "test_kpi", + SchedulingDomain: "test-operator", + Impl: "test_kpi", }, }, expectedReady: true, @@ -433,8 +433,8 @@ func TestController_Reconcile(t *testing.T) { mockKPIInstance := &mockKPI{name: "test_kpi"} baseController := Controller{ - Client: fakeClient, - OperatorName: "test-operator", + Client: fakeClient, + SchedulingDomain: "test-operator", supportedKPIs: map[string]plugins.KPI{ "test_kpi": mockKPIInstance, }, @@ -508,8 +508,8 @@ func TestController_Reconcile_KPIDeleted(t *testing.T) { mockKPIInstance := &mockKPI{name: "test_kpi"} controller := &Controller{ - Client: fakeClient, - OperatorName: "test-operator", + Client: fakeClient, + SchedulingDomain: "test-operator", supportedKPIs: map[string]plugins.KPI{ "test_kpi": mockKPIInstance, }, @@ -870,15 +870,15 @@ func TestController_InitAllKPIs(t *testing.T) { { ObjectMeta: metav1.ObjectMeta{Name: "kpi1"}, Spec: v1alpha1.KPISpec{ - Operator: "test-operator", - Impl: "test_kpi", + SchedulingDomain: "test-operator", + Impl: "test_kpi", }, }, { ObjectMeta: metav1.ObjectMeta{Name: "kpi2"}, Spec: v1alpha1.KPISpec{ - Operator: "other-operator", - Impl: "test_kpi", + SchedulingDomain: "other-operator", + Impl: "test_kpi", }, }, } @@ -896,8 +896,8 @@ func TestController_InitAllKPIs(t *testing.T) { mockKPIInstance := &mockKPI{name: "test_kpi"} baseController := Controller{ - Client: fakeClient, - OperatorName: "test-operator", + Client: fakeClient, + SchedulingDomain: "test-operator", supportedKPIs: map[string]plugins.KPI{ "test_kpi": mockKPIInstance, }, diff --git a/internal/knowledge/kpis/plugins/deployment/datasource_state.go b/internal/knowledge/kpis/plugins/deployment/datasource_state.go index b2872678..96bab6b9 100644 --- a/internal/knowledge/kpis/plugins/deployment/datasource_state.go +++ b/internal/knowledge/kpis/plugins/deployment/datasource_state.go @@ -16,8 +16,8 @@ import ( ) type DatasourceStateKPIOpts struct { - // The operator to filter datasources by. - DatasourceOperator string `yaml:"datasourceOperator"` + // The scheduling domain to filter datasources by. + DatasourceSchedulingDomain v1alpha1.SchedulingDomain `json:"datasourceSchedulingDomain"` } // KPI observing the state of datasource resources managed by cortex. @@ -57,7 +57,7 @@ func (k *DatasourceStateKPI) Collect(ch chan<- prometheus.Metric) { } var datasources []v1alpha1.Datasource for _, ds := range datasourceList.Items { - if ds.Spec.Operator != k.Options.DatasourceOperator { + if ds.Spec.SchedulingDomain != k.Options.DatasourceSchedulingDomain { continue } datasources = append(datasources, ds) @@ -77,7 +77,7 @@ func (k *DatasourceStateKPI) Collect(ch chan<- prometheus.Metric) { } ch <- prometheus.MustNewConstMetric( k.counter, prometheus.GaugeValue, 1, - k.Options.DatasourceOperator, ds.Name, state, + string(k.Options.DatasourceSchedulingDomain), ds.Name, state, ) } } diff --git a/internal/knowledge/kpis/plugins/deployment/datasource_state_test.go b/internal/knowledge/kpis/plugins/deployment/datasource_state_test.go index db4050f4..02694483 100644 --- a/internal/knowledge/kpis/plugins/deployment/datasource_state_test.go +++ b/internal/knowledge/kpis/plugins/deployment/datasource_state_test.go @@ -15,7 +15,7 @@ import ( func TestDatasourceStateKPI_Init(t *testing.T) { kpi := &DatasourceStateKPI{} - if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"datasourceOperator": "test-operator"}`)); err != nil { + if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"datasourceSchedulingDomain": "test-operator"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } } @@ -45,7 +45,7 @@ func TestDatasourceStateKPI_Collect(t *testing.T) { datasources: []v1alpha1.Datasource{ { ObjectMeta: v1.ObjectMeta{Name: "ds1"}, - Spec: v1alpha1.DatasourceSpec{Operator: "test-operator"}, + Spec: v1alpha1.DatasourceSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DatasourceStatus{ NumberOfObjects: 10, Conditions: []v1.Condition{}, @@ -61,7 +61,7 @@ func TestDatasourceStateKPI_Collect(t *testing.T) { datasources: []v1alpha1.Datasource{ { ObjectMeta: v1.ObjectMeta{Name: "ds2"}, - Spec: v1alpha1.DatasourceSpec{Operator: "test-operator"}, + Spec: v1alpha1.DatasourceSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DatasourceStatus{ Conditions: []v1.Condition{ { @@ -81,7 +81,7 @@ func TestDatasourceStateKPI_Collect(t *testing.T) { datasources: []v1alpha1.Datasource{ { ObjectMeta: v1.ObjectMeta{Name: "ds3"}, - Spec: v1alpha1.DatasourceSpec{Operator: "test-operator"}, + Spec: v1alpha1.DatasourceSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DatasourceStatus{ Conditions: []v1.Condition{ { @@ -101,7 +101,7 @@ func TestDatasourceStateKPI_Collect(t *testing.T) { datasources: []v1alpha1.Datasource{ { ObjectMeta: v1.ObjectMeta{Name: "ds-ready"}, - Spec: v1alpha1.DatasourceSpec{Operator: "test-operator"}, + Spec: v1alpha1.DatasourceSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DatasourceStatus{ NumberOfObjects: 10, Conditions: []v1.Condition{}, @@ -109,7 +109,7 @@ func TestDatasourceStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "ds-waiting"}, - Spec: v1alpha1.DatasourceSpec{Operator: "test-operator"}, + Spec: v1alpha1.DatasourceSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DatasourceStatus{ Conditions: []v1.Condition{ { @@ -121,7 +121,7 @@ func TestDatasourceStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "ds-error"}, - Spec: v1alpha1.DatasourceSpec{Operator: "test-operator"}, + Spec: v1alpha1.DatasourceSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DatasourceStatus{ Conditions: []v1.Condition{ { @@ -141,7 +141,7 @@ func TestDatasourceStateKPI_Collect(t *testing.T) { datasources: []v1alpha1.Datasource{ { ObjectMeta: v1.ObjectMeta{Name: "ds-correct-operator"}, - Spec: v1alpha1.DatasourceSpec{Operator: "test-operator"}, + Spec: v1alpha1.DatasourceSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DatasourceStatus{ NumberOfObjects: 10, Conditions: []v1.Condition{}, @@ -149,7 +149,7 @@ func TestDatasourceStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "ds-wrong-operator"}, - Spec: v1alpha1.DatasourceSpec{Operator: "other-operator"}, + Spec: v1alpha1.DatasourceSpec{SchedulingDomain: "other-operator"}, Status: v1alpha1.DatasourceStatus{ NumberOfObjects: 10, Conditions: []v1.Condition{}, @@ -165,7 +165,7 @@ func TestDatasourceStateKPI_Collect(t *testing.T) { datasources: []v1alpha1.Datasource{ { ObjectMeta: v1.ObjectMeta{Name: "ds-unknown"}, - Spec: v1alpha1.DatasourceSpec{Operator: "test-operator"}, + Spec: v1alpha1.DatasourceSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DatasourceStatus{ NumberOfObjects: 0, Conditions: []v1.Condition{}, @@ -190,7 +190,7 @@ func TestDatasourceStateKPI_Collect(t *testing.T) { client := clientBuilder.Build() kpi := &DatasourceStateKPI{} - if err := kpi.Init(nil, client, conf.NewRawOpts(`{"datasourceOperator": "`+tt.operator+`"}`)); err != nil { + if err := kpi.Init(nil, client, conf.NewRawOpts(`{"datasourceSchedulingDomain": "`+tt.operator+`"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } @@ -220,7 +220,7 @@ func TestDatasourceStateKPI_GetName(t *testing.T) { func TestDatasourceStateKPI_Describe(t *testing.T) { kpi := &DatasourceStateKPI{} - if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"datasourceOperator": "test-operator"}`)); err != nil { + if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"datasourceSchedulingDomain": "test-operator"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } diff --git a/internal/knowledge/kpis/plugins/deployment/decision_state.go b/internal/knowledge/kpis/plugins/deployment/decision_state.go index f57963a3..3d152faa 100644 --- a/internal/knowledge/kpis/plugins/deployment/decision_state.go +++ b/internal/knowledge/kpis/plugins/deployment/decision_state.go @@ -16,8 +16,8 @@ import ( ) type DecisionStateKPIOpts struct { - // The operator to filter decisions by. - DecisionOperator string `yaml:"decisionOperator"` + // The scheduling domain to filter decisions by. + DecisionSchedulingDomain v1alpha1.SchedulingDomain `json:"decisionSchedulingDomain"` } // KPI observing the state of decision resources managed by cortex. @@ -57,7 +57,7 @@ func (k *DecisionStateKPI) Collect(ch chan<- prometheus.Metric) { } var decisions []v1alpha1.Decision for _, d := range decisionList.Items { - if d.Spec.Operator != k.Options.DecisionOperator { + if d.Spec.SchedulingDomain != k.Options.DecisionSchedulingDomain { continue } decisions = append(decisions, d) @@ -76,14 +76,14 @@ func (k *DecisionStateKPI) Collect(ch chan<- prometheus.Metric) { } ch <- prometheus.MustNewConstMetric( k.counter, prometheus.GaugeValue, errorCount, - k.Options.DecisionOperator, "error", + string(k.Options.DecisionSchedulingDomain), "error", ) ch <- prometheus.MustNewConstMetric( k.counter, prometheus.GaugeValue, waitingCount, - k.Options.DecisionOperator, "waiting", + string(k.Options.DecisionSchedulingDomain), "waiting", ) ch <- prometheus.MustNewConstMetric( k.counter, prometheus.GaugeValue, successCount, - k.Options.DecisionOperator, "success", + string(k.Options.DecisionSchedulingDomain), "success", ) } diff --git a/internal/knowledge/kpis/plugins/deployment/decision_state_test.go b/internal/knowledge/kpis/plugins/deployment/decision_state_test.go index 69e25b51..204e38f2 100644 --- a/internal/knowledge/kpis/plugins/deployment/decision_state_test.go +++ b/internal/knowledge/kpis/plugins/deployment/decision_state_test.go @@ -15,7 +15,7 @@ import ( func TestDecisionStateKPI_Init(t *testing.T) { kpi := &DecisionStateKPI{} - if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"decisionOperator": "test-operator"}`)); err != nil { + if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"decisionSchedulingDomain": "test-operator"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } } @@ -53,7 +53,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { decisions: []v1alpha1.Decision{ { ObjectMeta: v1.ObjectMeta{Name: "dec1"}, - Spec: v1alpha1.DecisionSpec{Operator: "test-operator"}, + Spec: v1alpha1.DecisionSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DecisionStatus{ Conditions: []v1.Condition{ { @@ -76,7 +76,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { decisions: []v1alpha1.Decision{ { ObjectMeta: v1.ObjectMeta{Name: "dec2"}, - Spec: v1alpha1.DecisionSpec{Operator: "test-operator"}, + Spec: v1alpha1.DecisionSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DecisionStatus{ Result: &v1alpha1.DecisionResult{ TargetHost: &targetHost, @@ -96,7 +96,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { decisions: []v1alpha1.Decision{ { ObjectMeta: v1.ObjectMeta{Name: "dec3"}, - Spec: v1alpha1.DecisionSpec{Operator: "test-operator"}, + Spec: v1alpha1.DecisionSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DecisionStatus{ Result: &v1alpha1.DecisionResult{ OrderedHosts: []string{"host1", "host2"}, @@ -116,7 +116,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { decisions: []v1alpha1.Decision{ { ObjectMeta: v1.ObjectMeta{Name: "dec-error"}, - Spec: v1alpha1.DecisionSpec{Operator: "test-operator"}, + Spec: v1alpha1.DecisionSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DecisionStatus{ Conditions: []v1.Condition{ { @@ -128,7 +128,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "dec-waiting"}, - Spec: v1alpha1.DecisionSpec{Operator: "test-operator"}, + Spec: v1alpha1.DecisionSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DecisionStatus{ Result: &v1alpha1.DecisionResult{ TargetHost: &targetHost, @@ -137,7 +137,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "dec-success"}, - Spec: v1alpha1.DecisionSpec{Operator: "test-operator"}, + Spec: v1alpha1.DecisionSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DecisionStatus{ Result: &v1alpha1.DecisionResult{ OrderedHosts: []string{"host1"}, @@ -157,7 +157,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { decisions: []v1alpha1.Decision{ { ObjectMeta: v1.ObjectMeta{Name: "dec-correct-operator"}, - Spec: v1alpha1.DecisionSpec{Operator: "test-operator"}, + Spec: v1alpha1.DecisionSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DecisionStatus{ Conditions: []v1.Condition{ { @@ -169,7 +169,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "dec-wrong-operator"}, - Spec: v1alpha1.DecisionSpec{Operator: "other-operator"}, + Spec: v1alpha1.DecisionSpec{SchedulingDomain: "other-operator"}, Status: v1alpha1.DecisionStatus{ Conditions: []v1.Condition{ { @@ -192,7 +192,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { decisions: []v1alpha1.Decision{ { ObjectMeta: v1.ObjectMeta{Name: "dec-error-1"}, - Spec: v1alpha1.DecisionSpec{Operator: "test-operator"}, + Spec: v1alpha1.DecisionSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DecisionStatus{ Conditions: []v1.Condition{ { @@ -204,7 +204,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "dec-error-2"}, - Spec: v1alpha1.DecisionSpec{Operator: "test-operator"}, + Spec: v1alpha1.DecisionSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DecisionStatus{ Conditions: []v1.Condition{ { @@ -227,7 +227,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { decisions: []v1alpha1.Decision{ { ObjectMeta: v1.ObjectMeta{Name: "dec-no-result"}, - Spec: v1alpha1.DecisionSpec{Operator: "test-operator"}, + Spec: v1alpha1.DecisionSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DecisionStatus{}, }, }, @@ -243,7 +243,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { decisions: []v1alpha1.Decision{ { ObjectMeta: v1.ObjectMeta{Name: "dec-error-with-target"}, - Spec: v1alpha1.DecisionSpec{Operator: "test-operator"}, + Spec: v1alpha1.DecisionSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.DecisionStatus{ Result: &v1alpha1.DecisionResult{ TargetHost: &targetHost, @@ -278,7 +278,7 @@ func TestDecisionStateKPI_Collect(t *testing.T) { client := clientBuilder.Build() kpi := &DecisionStateKPI{} - if err := kpi.Init(nil, client, conf.NewRawOpts(`{"decisionOperator": "`+tt.operator+`"}`)); err != nil { + if err := kpi.Init(nil, client, conf.NewRawOpts(`{"decisionSchedulingDomain": "`+tt.operator+`"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } @@ -308,7 +308,7 @@ func TestDecisionStateKPI_GetName(t *testing.T) { func TestDecisionStateKPI_Describe(t *testing.T) { kpi := &DecisionStateKPI{} - if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"decisionOperator": "test-operator"}`)); err != nil { + if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"decisionSchedulingDomain": "test-operator"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } diff --git a/internal/knowledge/kpis/plugins/deployment/knowledge_state.go b/internal/knowledge/kpis/plugins/deployment/knowledge_state.go index f9e2e709..f2acbac5 100644 --- a/internal/knowledge/kpis/plugins/deployment/knowledge_state.go +++ b/internal/knowledge/kpis/plugins/deployment/knowledge_state.go @@ -16,8 +16,8 @@ import ( ) type KnowledgeStateKPIOpts struct { - // The operator to filter knowledges by. - KnowledgeOperator string `yaml:"knowledgeOperator"` + // The scheduling domain to filter knowledges by. + KnowledgeSchedulingDomain v1alpha1.SchedulingDomain `json:"knowledgeSchedulingDomain"` } // KPI observing the state of knowledge resources managed by cortex. @@ -57,7 +57,7 @@ func (k *KnowledgeStateKPI) Collect(ch chan<- prometheus.Metric) { } var knowledges []v1alpha1.Knowledge for _, kn := range knowledgeList.Items { - if kn.Spec.Operator != k.Options.KnowledgeOperator { + if kn.Spec.SchedulingDomain != k.Options.KnowledgeSchedulingDomain { continue } knowledges = append(knowledges, kn) @@ -75,7 +75,7 @@ func (k *KnowledgeStateKPI) Collect(ch chan<- prometheus.Metric) { } ch <- prometheus.MustNewConstMetric( k.counter, prometheus.GaugeValue, 1, - k.Options.KnowledgeOperator, kn.Name, state, + string(k.Options.KnowledgeSchedulingDomain), kn.Name, state, ) } } diff --git a/internal/knowledge/kpis/plugins/deployment/knowledge_state_test.go b/internal/knowledge/kpis/plugins/deployment/knowledge_state_test.go index 6ac701f7..b03f0f48 100644 --- a/internal/knowledge/kpis/plugins/deployment/knowledge_state_test.go +++ b/internal/knowledge/kpis/plugins/deployment/knowledge_state_test.go @@ -15,7 +15,7 @@ import ( func TestKnowledgeStateKPI_Init(t *testing.T) { kpi := &KnowledgeStateKPI{} - if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"knowledgeOperator": "test-operator"}`)); err != nil { + if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"knowledgeSchedulingDomain": "test-operator"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } } @@ -45,7 +45,7 @@ func TestKnowledgeStateKPI_Collect(t *testing.T) { knowledges: []v1alpha1.Knowledge{ { ObjectMeta: v1.ObjectMeta{Name: "kn1"}, - Spec: v1alpha1.KnowledgeSpec{Operator: "test-operator"}, + Spec: v1alpha1.KnowledgeSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.KnowledgeStatus{ RawLength: 10, Conditions: []v1.Condition{}, @@ -61,7 +61,7 @@ func TestKnowledgeStateKPI_Collect(t *testing.T) { knowledges: []v1alpha1.Knowledge{ { ObjectMeta: v1.ObjectMeta{Name: "kn2"}, - Spec: v1alpha1.KnowledgeSpec{Operator: "test-operator"}, + Spec: v1alpha1.KnowledgeSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.KnowledgeStatus{ Conditions: []v1.Condition{ { @@ -81,7 +81,7 @@ func TestKnowledgeStateKPI_Collect(t *testing.T) { knowledges: []v1alpha1.Knowledge{ { ObjectMeta: v1.ObjectMeta{Name: "kn-ready"}, - Spec: v1alpha1.KnowledgeSpec{Operator: "test-operator"}, + Spec: v1alpha1.KnowledgeSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.KnowledgeStatus{ RawLength: 10, Conditions: []v1.Condition{}, @@ -89,7 +89,7 @@ func TestKnowledgeStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "kn-error"}, - Spec: v1alpha1.KnowledgeSpec{Operator: "test-operator"}, + Spec: v1alpha1.KnowledgeSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.KnowledgeStatus{ Conditions: []v1.Condition{ { @@ -109,7 +109,7 @@ func TestKnowledgeStateKPI_Collect(t *testing.T) { knowledges: []v1alpha1.Knowledge{ { ObjectMeta: v1.ObjectMeta{Name: "kn-correct-operator"}, - Spec: v1alpha1.KnowledgeSpec{Operator: "test-operator"}, + Spec: v1alpha1.KnowledgeSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.KnowledgeStatus{ RawLength: 10, Conditions: []v1.Condition{}, @@ -117,7 +117,7 @@ func TestKnowledgeStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "kn-wrong-operator"}, - Spec: v1alpha1.KnowledgeSpec{Operator: "other-operator"}, + Spec: v1alpha1.KnowledgeSpec{SchedulingDomain: "other-operator"}, Status: v1alpha1.KnowledgeStatus{ RawLength: 10, Conditions: []v1.Condition{}, @@ -133,7 +133,7 @@ func TestKnowledgeStateKPI_Collect(t *testing.T) { knowledges: []v1alpha1.Knowledge{ { ObjectMeta: v1.ObjectMeta{Name: "kn-unknown"}, - Spec: v1alpha1.KnowledgeSpec{Operator: "test-operator"}, + Spec: v1alpha1.KnowledgeSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.KnowledgeStatus{ RawLength: 0, Conditions: []v1.Condition{}, @@ -158,7 +158,7 @@ func TestKnowledgeStateKPI_Collect(t *testing.T) { client := clientBuilder.Build() kpi := &KnowledgeStateKPI{} - if err := kpi.Init(nil, client, conf.NewRawOpts(`{"knowledgeOperator": "`+tt.operator+`"}`)); err != nil { + if err := kpi.Init(nil, client, conf.NewRawOpts(`{"knowledgeSchedulingDomain": "`+tt.operator+`"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } @@ -188,7 +188,7 @@ func TestKnowledgeStateKPI_GetName(t *testing.T) { func TestKnowledgeStateKPI_Describe(t *testing.T) { kpi := &KnowledgeStateKPI{} - if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"knowledgeOperator": "test-operator"}`)); err != nil { + if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"knowledgeSchedulingDomain": "test-operator"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } diff --git a/internal/knowledge/kpis/plugins/deployment/kpi_state.go b/internal/knowledge/kpis/plugins/deployment/kpi_state.go index 927e3445..32fdf31a 100644 --- a/internal/knowledge/kpis/plugins/deployment/kpi_state.go +++ b/internal/knowledge/kpis/plugins/deployment/kpi_state.go @@ -16,8 +16,8 @@ import ( ) type KPIStateKPIOpts struct { - // The operator to filter kpis by. - KPIOperator string `yaml:"kpiOperator"` + // The scheduling domain to filter kpis by. + KPISchedulingDomain v1alpha1.SchedulingDomain `json:"kpiSchedulingDomain"` } // KPI observing the state of kpi resources managed by cortex. @@ -57,7 +57,7 @@ func (k *KPIStateKPI) Collect(ch chan<- prometheus.Metric) { } var kpis []v1alpha1.KPI for _, kpi := range kpiList.Items { - if kpi.Spec.Operator != k.Options.KPIOperator { + if kpi.Spec.SchedulingDomain != k.Options.KPISchedulingDomain { continue } kpis = append(kpis, kpi) @@ -75,7 +75,7 @@ func (k *KPIStateKPI) Collect(ch chan<- prometheus.Metric) { } ch <- prometheus.MustNewConstMetric( k.counter, prometheus.GaugeValue, 1, - k.Options.KPIOperator, kpi.Name, state, + string(k.Options.KPISchedulingDomain), kpi.Name, state, ) } } diff --git a/internal/knowledge/kpis/plugins/deployment/kpi_state_test.go b/internal/knowledge/kpis/plugins/deployment/kpi_state_test.go index f4f7d1d2..7dc8f174 100644 --- a/internal/knowledge/kpis/plugins/deployment/kpi_state_test.go +++ b/internal/knowledge/kpis/plugins/deployment/kpi_state_test.go @@ -15,7 +15,7 @@ import ( func TestKPIStateKPI_Init(t *testing.T) { kpi := &KPIStateKPI{} - if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"kpiOperator": "test-operator"}`)); err != nil { + if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"kpiSchedulingDomain": "test-operator"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } } @@ -45,7 +45,7 @@ func TestKPIStateKPI_Collect(t *testing.T) { kpis: []v1alpha1.KPI{ { ObjectMeta: v1.ObjectMeta{Name: "kn1"}, - Spec: v1alpha1.KPISpec{Operator: "test-operator"}, + Spec: v1alpha1.KPISpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.KPIStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -61,7 +61,7 @@ func TestKPIStateKPI_Collect(t *testing.T) { kpis: []v1alpha1.KPI{ { ObjectMeta: v1.ObjectMeta{Name: "kn2"}, - Spec: v1alpha1.KPISpec{Operator: "test-operator"}, + Spec: v1alpha1.KPISpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.KPIStatus{ Conditions: []v1.Condition{ { @@ -81,7 +81,7 @@ func TestKPIStateKPI_Collect(t *testing.T) { kpis: []v1alpha1.KPI{ { ObjectMeta: v1.ObjectMeta{Name: "kpi-ready"}, - Spec: v1alpha1.KPISpec{Operator: "test-operator"}, + Spec: v1alpha1.KPISpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.KPIStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -89,7 +89,7 @@ func TestKPIStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "kpi-error"}, - Spec: v1alpha1.KPISpec{Operator: "test-operator"}, + Spec: v1alpha1.KPISpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.KPIStatus{ Conditions: []v1.Condition{ { @@ -109,7 +109,7 @@ func TestKPIStateKPI_Collect(t *testing.T) { kpis: []v1alpha1.KPI{ { ObjectMeta: v1.ObjectMeta{Name: "kpi-correct-operator"}, - Spec: v1alpha1.KPISpec{Operator: "test-operator"}, + Spec: v1alpha1.KPISpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.KPIStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -117,7 +117,7 @@ func TestKPIStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "kpi-wrong-operator"}, - Spec: v1alpha1.KPISpec{Operator: "other-operator"}, + Spec: v1alpha1.KPISpec{SchedulingDomain: "other-operator"}, Status: v1alpha1.KPIStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -133,7 +133,7 @@ func TestKPIStateKPI_Collect(t *testing.T) { kpis: []v1alpha1.KPI{ { ObjectMeta: v1.ObjectMeta{Name: "kpi-unknown"}, - Spec: v1alpha1.KPISpec{Operator: "test-operator"}, + Spec: v1alpha1.KPISpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.KPIStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -158,7 +158,7 @@ func TestKPIStateKPI_Collect(t *testing.T) { client := clientBuilder.Build() kpi := &KPIStateKPI{} - if err := kpi.Init(nil, client, conf.NewRawOpts(`{"kpiOperator": "`+tt.operator+`"}`)); err != nil { + if err := kpi.Init(nil, client, conf.NewRawOpts(`{"kpiSchedulingDomain": "`+tt.operator+`"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } @@ -188,7 +188,7 @@ func TestKPIStateKPI_GetName(t *testing.T) { func TestKPIStateKPI_Describe(t *testing.T) { kpi := &KPIStateKPI{} - if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"kpiOperator": "test-operator"}`)); err != nil { + if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"kpiSchedulingDomain": "test-operator"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } diff --git a/internal/knowledge/kpis/plugins/deployment/pipeline_state.go b/internal/knowledge/kpis/plugins/deployment/pipeline_state.go index a936ca51..1b9b0bd8 100644 --- a/internal/knowledge/kpis/plugins/deployment/pipeline_state.go +++ b/internal/knowledge/kpis/plugins/deployment/pipeline_state.go @@ -16,8 +16,8 @@ import ( ) type PipelineStateKPIOpts struct { - // The operator to filter pipelines by. - PipelineOperator string `yaml:"pipelineOperator"` + // The scheduling domain to filter pipelines by. + PipelineSchedulingDomain v1alpha1.SchedulingDomain `json:"pipelineSchedulingDomain"` } // KPI observing the state of pipeline resources managed by cortex. @@ -57,7 +57,7 @@ func (k *PipelineStateKPI) Collect(ch chan<- prometheus.Metric) { } var pipelines []v1alpha1.Pipeline for _, pipeline := range pipelineList.Items { - if pipeline.Spec.Operator != k.Options.PipelineOperator { + if pipeline.Spec.SchedulingDomain != k.Options.PipelineSchedulingDomain { continue } pipelines = append(pipelines, pipeline) @@ -75,7 +75,7 @@ func (k *PipelineStateKPI) Collect(ch chan<- prometheus.Metric) { } ch <- prometheus.MustNewConstMetric( k.counter, prometheus.GaugeValue, 1, - k.Options.PipelineOperator, pipeline.Name, state, + string(k.Options.PipelineSchedulingDomain), pipeline.Name, state, ) } } diff --git a/internal/knowledge/kpis/plugins/deployment/pipeline_state_test.go b/internal/knowledge/kpis/plugins/deployment/pipeline_state_test.go index 6363d8f7..7dc26319 100644 --- a/internal/knowledge/kpis/plugins/deployment/pipeline_state_test.go +++ b/internal/knowledge/kpis/plugins/deployment/pipeline_state_test.go @@ -15,7 +15,7 @@ import ( func TestPipelineStateKPI_Init(t *testing.T) { kpi := &PipelineStateKPI{} - if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"pipelineOperator": "test-operator"}`)); err != nil { + if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"pipelineSchedulingDomain": "test-operator"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } } @@ -45,7 +45,7 @@ func TestPipelineStateKPI_Collect(t *testing.T) { pipelines: []v1alpha1.Pipeline{ { ObjectMeta: v1.ObjectMeta{Name: "pipeline1"}, - Spec: v1alpha1.PipelineSpec{Operator: "test-operator"}, + Spec: v1alpha1.PipelineSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.PipelineStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -61,7 +61,7 @@ func TestPipelineStateKPI_Collect(t *testing.T) { pipelines: []v1alpha1.Pipeline{ { ObjectMeta: v1.ObjectMeta{Name: "pipeline2"}, - Spec: v1alpha1.PipelineSpec{Operator: "test-operator"}, + Spec: v1alpha1.PipelineSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.PipelineStatus{ Ready: false, Conditions: []v1.Condition{ @@ -82,7 +82,7 @@ func TestPipelineStateKPI_Collect(t *testing.T) { pipelines: []v1alpha1.Pipeline{ { ObjectMeta: v1.ObjectMeta{Name: "pipeline-ready"}, - Spec: v1alpha1.PipelineSpec{Operator: "test-operator"}, + Spec: v1alpha1.PipelineSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.PipelineStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -90,7 +90,7 @@ func TestPipelineStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "pipeline-error"}, - Spec: v1alpha1.PipelineSpec{Operator: "test-operator"}, + Spec: v1alpha1.PipelineSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.PipelineStatus{ Ready: false, Conditions: []v1.Condition{ @@ -111,7 +111,7 @@ func TestPipelineStateKPI_Collect(t *testing.T) { pipelines: []v1alpha1.Pipeline{ { ObjectMeta: v1.ObjectMeta{Name: "pipeline-correct-operator"}, - Spec: v1alpha1.PipelineSpec{Operator: "test-operator"}, + Spec: v1alpha1.PipelineSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.PipelineStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -119,7 +119,7 @@ func TestPipelineStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "pipeline-wrong-operator"}, - Spec: v1alpha1.PipelineSpec{Operator: "other-operator"}, + Spec: v1alpha1.PipelineSpec{SchedulingDomain: "other-operator"}, Status: v1alpha1.PipelineStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -135,7 +135,7 @@ func TestPipelineStateKPI_Collect(t *testing.T) { pipelines: []v1alpha1.Pipeline{ { ObjectMeta: v1.ObjectMeta{Name: "pipeline-unknown"}, - Spec: v1alpha1.PipelineSpec{Operator: "test-operator"}, + Spec: v1alpha1.PipelineSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.PipelineStatus{ Ready: false, Conditions: []v1.Condition{}, @@ -151,7 +151,7 @@ func TestPipelineStateKPI_Collect(t *testing.T) { pipelines: []v1alpha1.Pipeline{ { ObjectMeta: v1.ObjectMeta{Name: "pipeline-error-priority"}, - Spec: v1alpha1.PipelineSpec{Operator: "test-operator"}, + Spec: v1alpha1.PipelineSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.PipelineStatus{ Ready: true, Conditions: []v1.Condition{ @@ -181,7 +181,7 @@ func TestPipelineStateKPI_Collect(t *testing.T) { client := clientBuilder.Build() kpi := &PipelineStateKPI{} - if err := kpi.Init(nil, client, conf.NewRawOpts(`{"pipelineOperator": "`+tt.operator+`"}`)); err != nil { + if err := kpi.Init(nil, client, conf.NewRawOpts(`{"pipelineSchedulingDomain": "`+tt.operator+`"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } @@ -211,7 +211,7 @@ func TestPipelineStateKPI_GetName(t *testing.T) { func TestPipelineStateKPI_Describe(t *testing.T) { kpi := &PipelineStateKPI{} - if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"pipelineOperator": "test-operator"}`)); err != nil { + if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"pipelineSchedulingDomain": "test-operator"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } diff --git a/internal/knowledge/kpis/plugins/deployment/step_state.go b/internal/knowledge/kpis/plugins/deployment/step_state.go index e8cb0674..f39cffe8 100644 --- a/internal/knowledge/kpis/plugins/deployment/step_state.go +++ b/internal/knowledge/kpis/plugins/deployment/step_state.go @@ -16,8 +16,8 @@ import ( ) type StepStateKPIOpts struct { - // The operator to filter steps by. - StepOperator string `yaml:"stepOperator"` + // The scheduling domain to filter steps by. + StepSchedulingDomain v1alpha1.SchedulingDomain `json:"stepSchedulingDomain"` } // KPI observing the state of step resources managed by cortex. @@ -57,7 +57,7 @@ func (k *StepStateKPI) Collect(ch chan<- prometheus.Metric) { } var steps []v1alpha1.Step for _, step := range stepList.Items { - if step.Spec.Operator != k.Options.StepOperator { + if step.Spec.SchedulingDomain != k.Options.StepSchedulingDomain { continue } steps = append(steps, step) @@ -75,7 +75,7 @@ func (k *StepStateKPI) Collect(ch chan<- prometheus.Metric) { } ch <- prometheus.MustNewConstMetric( k.counter, prometheus.GaugeValue, 1, - k.Options.StepOperator, step.Name, state, + string(k.Options.StepSchedulingDomain), step.Name, state, ) } } diff --git a/internal/knowledge/kpis/plugins/deployment/step_state_test.go b/internal/knowledge/kpis/plugins/deployment/step_state_test.go index 3ddcd2ad..b5f96e85 100644 --- a/internal/knowledge/kpis/plugins/deployment/step_state_test.go +++ b/internal/knowledge/kpis/plugins/deployment/step_state_test.go @@ -15,7 +15,7 @@ import ( func TestStepStateKPI_Init(t *testing.T) { kpi := &StepStateKPI{} - if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"stepOperator": "test-operator"}`)); err != nil { + if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"stepSchedulingDomain": "test-operator"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } } @@ -45,7 +45,7 @@ func TestStepStateKPI_Collect(t *testing.T) { steps: []v1alpha1.Step{ { ObjectMeta: v1.ObjectMeta{Name: "step1"}, - Spec: v1alpha1.StepSpec{Operator: "test-operator"}, + Spec: v1alpha1.StepSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.StepStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -61,7 +61,7 @@ func TestStepStateKPI_Collect(t *testing.T) { steps: []v1alpha1.Step{ { ObjectMeta: v1.ObjectMeta{Name: "step2"}, - Spec: v1alpha1.StepSpec{Operator: "test-operator"}, + Spec: v1alpha1.StepSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.StepStatus{ Ready: false, Conditions: []v1.Condition{ @@ -82,7 +82,7 @@ func TestStepStateKPI_Collect(t *testing.T) { steps: []v1alpha1.Step{ { ObjectMeta: v1.ObjectMeta{Name: "step-ready"}, - Spec: v1alpha1.StepSpec{Operator: "test-operator"}, + Spec: v1alpha1.StepSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.StepStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -90,7 +90,7 @@ func TestStepStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "step-error"}, - Spec: v1alpha1.StepSpec{Operator: "test-operator"}, + Spec: v1alpha1.StepSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.StepStatus{ Ready: false, Conditions: []v1.Condition{ @@ -111,7 +111,7 @@ func TestStepStateKPI_Collect(t *testing.T) { steps: []v1alpha1.Step{ { ObjectMeta: v1.ObjectMeta{Name: "step-correct-operator"}, - Spec: v1alpha1.StepSpec{Operator: "test-operator"}, + Spec: v1alpha1.StepSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.StepStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -119,7 +119,7 @@ func TestStepStateKPI_Collect(t *testing.T) { }, { ObjectMeta: v1.ObjectMeta{Name: "step-wrong-operator"}, - Spec: v1alpha1.StepSpec{Operator: "other-operator"}, + Spec: v1alpha1.StepSpec{SchedulingDomain: "other-operator"}, Status: v1alpha1.StepStatus{ Ready: true, Conditions: []v1.Condition{}, @@ -135,7 +135,7 @@ func TestStepStateKPI_Collect(t *testing.T) { steps: []v1alpha1.Step{ { ObjectMeta: v1.ObjectMeta{Name: "step-unknown"}, - Spec: v1alpha1.StepSpec{Operator: "test-operator"}, + Spec: v1alpha1.StepSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.StepStatus{ Ready: false, Conditions: []v1.Condition{}, @@ -151,7 +151,7 @@ func TestStepStateKPI_Collect(t *testing.T) { steps: []v1alpha1.Step{ { ObjectMeta: v1.ObjectMeta{Name: "step-error-priority"}, - Spec: v1alpha1.StepSpec{Operator: "test-operator"}, + Spec: v1alpha1.StepSpec{SchedulingDomain: "test-operator"}, Status: v1alpha1.StepStatus{ Ready: true, Conditions: []v1.Condition{ @@ -181,7 +181,7 @@ func TestStepStateKPI_Collect(t *testing.T) { client := clientBuilder.Build() kpi := &StepStateKPI{} - if err := kpi.Init(nil, client, conf.NewRawOpts(`{"stepOperator": "`+tt.operator+`"}`)); err != nil { + if err := kpi.Init(nil, client, conf.NewRawOpts(`{"stepSchedulingDomain": "`+tt.operator+`"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } @@ -211,7 +211,7 @@ func TestStepStateKPI_GetName(t *testing.T) { func TestStepStateKPI_Describe(t *testing.T) { kpi := &StepStateKPI{} - if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"stepOperator": "test-operator"}`)); err != nil { + if err := kpi.Init(nil, nil, conf.NewRawOpts(`{"stepSchedulingDomain": "test-operator"}`)); err != nil { t.Fatalf("expected no error, got %v", err) } diff --git a/internal/scheduling/decisions/cinder/cleanup.go b/internal/scheduling/decisions/cinder/cleanup.go index e0a317df..b25f66aa 100644 --- a/internal/scheduling/decisions/cinder/cleanup.go +++ b/internal/scheduling/decisions/cinder/cleanup.go @@ -106,10 +106,7 @@ func Cleanup(ctx context.Context, client client.Client, conf conf.Config) error } for _, decision := range decisionList.Items { // Skip non-cinder decisions. - if decision.Spec.Operator != conf.Operator { - continue - } - if decision.Spec.Type != v1alpha1.DecisionTypeCinderVolume { + if decision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainCinder { continue } // Skip decisions for which the volume still exists. diff --git a/internal/scheduling/decisions/cinder/cleanup_test.go b/internal/scheduling/decisions/cinder/cleanup_test.go index 18ce3a48..778f508e 100644 --- a/internal/scheduling/decisions/cinder/cleanup_test.go +++ b/internal/scheduling/decisions/cinder/cleanup_test.go @@ -74,9 +74,8 @@ func TestCleanupCinder(t *testing.T) { Name: "decision-existing-volume", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeCinderVolume, - ResourceID: "volume-exists", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, + ResourceID: "volume-exists", }, }, { @@ -84,9 +83,8 @@ func TestCleanupCinder(t *testing.T) { Name: "decision-deleted-volume", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeCinderVolume, - ResourceID: "volume-deleted", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, + ResourceID: "volume-deleted", }, }, }, @@ -104,9 +102,8 @@ func TestCleanupCinder(t *testing.T) { Name: "decision-volume-1", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeCinderVolume, - ResourceID: "volume-1", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, + ResourceID: "volume-1", }, }, { @@ -114,9 +111,8 @@ func TestCleanupCinder(t *testing.T) { Name: "decision-volume-2", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeCinderVolume, - ResourceID: "volume-2", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, + ResourceID: "volume-2", }, }, }, @@ -287,7 +283,7 @@ func TestCleanupCinder(t *testing.T) { WithObjects(objects...). Build() config := conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, KeystoneSecretRef: corev1.SecretReference{ Name: "keystone-secret", Namespace: "default", @@ -370,7 +366,7 @@ func TestCleanupCinderDecisionsCancel(t *testing.T) { Build() config := conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, KeystoneSecretRef: corev1.SecretReference{ Name: "keystone-secret", Namespace: "default", diff --git a/internal/scheduling/decisions/cinder/pipeline_controller.go b/internal/scheduling/decisions/cinder/pipeline_controller.go index 949bbaeb..7220897b 100644 --- a/internal/scheduling/decisions/cinder/pipeline_controller.go +++ b/internal/scheduling/decisions/cinder/pipeline_controller.go @@ -136,6 +136,7 @@ func (c *DecisionPipelineController) InitPipeline( func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl *multicluster.Client) error { c.Initializer = c + c.SchedulingDomain = v1alpha1.SchedulingDomainCinder if err := mgr.Add(manager.RunnableFunc(c.InitAllPipelines)); err != nil { return err } @@ -150,8 +151,8 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { pipeline := obj.(*v1alpha1.Pipeline) - // Only react to pipelines matching the operator. - if pipeline.Spec.Operator != c.Conf.Operator { + // Only react to pipelines matching the scheduling domain. + if pipeline.Spec.SchedulingDomain != v1alpha1.SchedulingDomainCinder { return false } return pipeline.Spec.Type == c.PipelineType() @@ -168,8 +169,8 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { step := obj.(*v1alpha1.Step) - // Only react to steps matching the operator. - if step.Spec.Operator != c.Conf.Operator { + // Only react to steps matching the scheduling domain. + if step.Spec.SchedulingDomain != v1alpha1.SchedulingDomainCinder { return false } // Only react to filter and weigher steps. @@ -190,23 +191,22 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { knowledge := obj.(*v1alpha1.Knowledge) - // Only react to knowledge matching the operator. - return knowledge.Spec.Operator == c.Conf.Operator + // Only react to knowledge matching the scheduling domain. + return knowledge.Spec.SchedulingDomain == v1alpha1.SchedulingDomainCinder }), ). For( &v1alpha1.Decision{}, builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool { decision := obj.(*v1alpha1.Decision) - if decision.Spec.Operator != c.Conf.Operator { + if decision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainCinder { return false } // Ignore already decided schedulings. if decision.Status.Result != nil { return false } - // Only handle cinder decisions. - return decision.Spec.Type == v1alpha1.DecisionTypeCinderVolume + return true })), ). Named("cortex-cinder-decisions"). diff --git a/internal/scheduling/decisions/cinder/pipeline_controller_test.go b/internal/scheduling/decisions/cinder/pipeline_controller_test.go index da8d19b1..0acbe0d3 100644 --- a/internal/scheduling/decisions/cinder/pipeline_controller_test.go +++ b/internal/scheduling/decisions/cinder/pipeline_controller_test.go @@ -69,8 +69,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeCinderVolume, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -84,9 +83,9 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainCinder, + Steps: []v1alpha1.StepInPipeline{}, }, }, expectError: false, @@ -101,8 +100,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeCinderVolume, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -114,9 +112,9 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainCinder, + Steps: []v1alpha1.StepInPipeline{}, }, }, expectError: true, @@ -131,8 +129,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeCinderVolume, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, PipelineRef: corev1.ObjectReference{ Name: "nonexistent-pipeline", }, @@ -168,7 +165,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { }, Monitor: lib.PipelineMonitor{}, Conf: conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, }, } @@ -270,8 +267,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeCinderVolume, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -285,10 +281,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainCinder, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, createDecisions: true, @@ -305,8 +301,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeCinderVolume, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -320,10 +315,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: false, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainCinder, + CreateDecisions: false, + Steps: []v1alpha1.StepInPipeline{}, }, }, createDecisions: false, @@ -340,8 +335,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeCinderVolume, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, PipelineRef: corev1.ObjectReference{ Name: "nonexistent-pipeline", }, @@ -364,8 +358,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeCinderVolume, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -377,10 +370,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainCinder, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, createDecisions: true, @@ -412,7 +405,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { }, Monitor: lib.PipelineMonitor{}, Conf: conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, }, } @@ -445,8 +438,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { found := false for _, decision := range decisions.Items { - if decision.Spec.Type == v1alpha1.DecisionTypeCinderVolume && - decision.Spec.Operator == "test-operator" { + if decision.Spec.SchedulingDomain == v1alpha1.SchedulingDomainCinder { found = true // Verify decision properties diff --git a/internal/scheduling/decisions/explanation/controller.go b/internal/scheduling/decisions/explanation/controller.go index c3251339..3b750528 100644 --- a/internal/scheduling/decisions/explanation/controller.go +++ b/internal/scheduling/decisions/explanation/controller.go @@ -30,10 +30,10 @@ import ( type Controller struct { // The kubernetes client to use for processing decisions. client.Client - // The controller will scope to objects using this operator name. - // This allows multiple operators to coexist in the same cluster without + // The controller will scope to objects using this scheduling domain name. + // This allows multiple controllers to coexist in the same cluster without // interfering with each other's decisions. - OperatorName string + SchedulingDomain v1alpha1.SchedulingDomain // If the field indexing should be skipped (useful for testing). SkipIndexFields bool } @@ -41,7 +41,7 @@ type Controller struct { // Check if a decision should be processed by this controller. func (c *Controller) shouldReconcileDecision(decision *v1alpha1.Decision) bool { // Ignore decisions not created by this operator. - if decision.Spec.Operator != c.OperatorName { + if decision.Spec.SchedulingDomain != c.SchedulingDomain { return false } // Ignore decisions that already have an explanation. @@ -52,8 +52,7 @@ func (c *Controller) shouldReconcileDecision(decision *v1alpha1.Decision) bool { if decision.Status.Result == nil { return false } - // Only handle nova decisions. - return decision.Spec.Type == v1alpha1.DecisionTypeNovaServer + return true } // This loop will be called by the controller-runtime for each decision diff --git a/internal/scheduling/decisions/explanation/controller_test.go b/internal/scheduling/decisions/explanation/controller_test.go index 598ab416..2505b68c 100644 --- a/internal/scheduling/decisions/explanation/controller_test.go +++ b/internal/scheduling/decisions/explanation/controller_test.go @@ -18,7 +18,7 @@ import ( func TestController_shouldReconcileDecision(t *testing.T) { controller := &Controller{ - OperatorName: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, } tests := []struct { @@ -30,8 +30,7 @@ func TestController_shouldReconcileDecision(t *testing.T) { name: "should reconcile nova decision without explanation", decision: &v1alpha1.Decision{ Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, + SchedulingDomain: v1alpha1.SchedulingDomainNova, }, Status: v1alpha1.DecisionStatus{ Explanation: "", @@ -46,8 +45,7 @@ func TestController_shouldReconcileDecision(t *testing.T) { name: "should not reconcile decision from different operator", decision: &v1alpha1.Decision{ Spec: v1alpha1.DecisionSpec{ - Operator: "different-operator", - Type: v1alpha1.DecisionTypeNovaServer, + SchedulingDomain: "different-operator", }, Status: v1alpha1.DecisionStatus{ Explanation: "", @@ -59,8 +57,7 @@ func TestController_shouldReconcileDecision(t *testing.T) { name: "should not reconcile decision with existing explanation", decision: &v1alpha1.Decision{ Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, + SchedulingDomain: v1alpha1.SchedulingDomainNova, }, Status: v1alpha1.DecisionStatus{ Explanation: "Already has explanation", @@ -72,8 +69,7 @@ func TestController_shouldReconcileDecision(t *testing.T) { name: "should not reconcile non-nova decision", decision: &v1alpha1.Decision{ Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeCinderVolume, + SchedulingDomain: v1alpha1.SchedulingDomainNova, }, Status: v1alpha1.DecisionStatus{ Explanation: "", @@ -126,9 +122,8 @@ func TestController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource-1", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource-1", }, Status: v1alpha1.DecisionStatus{}, }, @@ -144,9 +139,8 @@ func TestController_Reconcile(t *testing.T) { CreationTimestamp: metav1.Time{Time: time.Now().Add(time.Hour)}, }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource-2", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource-2", }, Status: v1alpha1.DecisionStatus{}, }, @@ -158,9 +152,8 @@ func TestController_Reconcile(t *testing.T) { CreationTimestamp: metav1.Time{Time: time.Now()}, }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource-2", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource-2", }, Status: v1alpha1.DecisionStatus{ Result: &v1alpha1.DecisionResult{ @@ -190,9 +183,9 @@ func TestController_Reconcile(t *testing.T) { Build() controller := &Controller{ - Client: client, - OperatorName: "test-operator", - SkipIndexFields: true, // Skip field indexing for testing + Client: client, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + SkipIndexFields: true, // Skip field indexing for testing } req := ctrl.Request{ @@ -418,9 +411,9 @@ func TestController_reconcileHistory(t *testing.T) { Build() controller := &Controller{ - Client: client, - OperatorName: "test-operator", - SkipIndexFields: true, // Skip field indexing for testing + Client: client, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + SkipIndexFields: true, // Skip field indexing for testing } err := controller.reconcileHistory(context.Background(), tt.decision) @@ -457,8 +450,8 @@ func TestController_reconcileExplanation(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource", }, Status: v1alpha1.DecisionStatus{ History: nil, @@ -472,8 +465,8 @@ func TestController_reconcileExplanation(t *testing.T) { Build() controller := &Controller{ - Client: client, - OperatorName: "test-operator", + Client: client, + SchedulingDomain: v1alpha1.SchedulingDomainNova, } err := controller.reconcileExplanation(context.Background(), decision) @@ -503,9 +496,8 @@ func TestController_StartupCallback(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource-1", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource-1", }, Status: v1alpha1.DecisionStatus{ Explanation: "", // Empty explanation means it should be reconciled @@ -522,9 +514,8 @@ func TestController_StartupCallback(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource-2", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource-2", }, Status: v1alpha1.DecisionStatus{ Explanation: "Already has explanation", @@ -538,9 +529,8 @@ func TestController_StartupCallback(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Operator: "different-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource-3", + SchedulingDomain: "different-operator", + ResourceID: "test-resource-3", }, Status: v1alpha1.DecisionStatus{ Explanation: "", @@ -554,9 +544,9 @@ func TestController_StartupCallback(t *testing.T) { Build() controller := &Controller{ - Client: client, - OperatorName: "test-operator", - SkipIndexFields: true, // Skip field indexing for testing + Client: client, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + SkipIndexFields: true, // Skip field indexing for testing } err := controller.StartupCallback(context.Background()) diff --git a/internal/scheduling/decisions/explanation/explainer.go b/internal/scheduling/decisions/explanation/explainer.go index 10b65ac8..1dc44b74 100644 --- a/internal/scheduling/decisions/explanation/explainer.go +++ b/internal/scheduling/decisions/explanation/explainer.go @@ -43,15 +43,15 @@ func (e *Explainer) Explain(ctx context.Context, decision *v1alpha1.Decision) (s } // getResourceType returns a human-readable resource type. -func (e *Explainer) getResourceType(decisionType v1alpha1.DecisionType) string { - switch decisionType { - case v1alpha1.DecisionTypeNovaServer: +func (e *Explainer) getResourceType(schedulingDomain v1alpha1.SchedulingDomain) string { + switch schedulingDomain { + case v1alpha1.SchedulingDomainNova: return "nova server" - case v1alpha1.DecisionTypeManilaShare: + case v1alpha1.SchedulingDomainManila: return "manila share" - case v1alpha1.DecisionTypeCinderVolume: + case v1alpha1.SchedulingDomainCinder: return "cinder volume" - case v1alpha1.DecisionTypeIroncoreMachine: + case v1alpha1.SchedulingDomainMachines: return "ironcore machine" default: return "resource" @@ -395,7 +395,7 @@ func (e *Explainer) calculateStepImpacts(inputWeights map[string]float64, stepRe // buildContextData creates context data for template rendering. func (e *Explainer) buildContextData(decision *v1alpha1.Decision) ContextData { - resourceType := e.getResourceType(decision.Spec.Type) + resourceType := e.getResourceType(decision.Spec.SchedulingDomain) history := decision.Status.History isInitial := history == nil || len(*history) == 0 diff --git a/internal/scheduling/decisions/explanation/explainer_test.go b/internal/scheduling/decisions/explanation/explainer_test.go index d3c13e19..a483152f 100644 --- a/internal/scheduling/decisions/explanation/explainer_test.go +++ b/internal/scheduling/decisions/explanation/explainer_test.go @@ -32,22 +32,22 @@ func TestExplainer_Explain(t *testing.T) { }, { name: "initial cinder volume placement", - decision: WithDecisionType(WithResourceID(NewTestDecision("test-decision"), "test-resource-2"), v1alpha1.DecisionTypeCinderVolume), + decision: WithSchedulingDomain(WithResourceID(NewTestDecision("test-decision"), "test-resource-2"), v1alpha1.SchedulingDomainCinder), expectedContains: []string{"Initial placement of the cinder volume"}, }, { name: "initial manila share placement", - decision: WithDecisionType(WithResourceID(NewTestDecision("test-decision"), "test-resource-3"), v1alpha1.DecisionTypeManilaShare), + decision: WithSchedulingDomain(WithResourceID(NewTestDecision("test-decision"), "test-resource-3"), v1alpha1.SchedulingDomainManila), expectedContains: []string{"Initial placement of the manila share"}, }, { name: "initial ironcore machine placement", - decision: WithDecisionType(WithResourceID(NewTestDecision("test-decision"), "test-resource-4"), v1alpha1.DecisionTypeIroncoreMachine), + decision: WithSchedulingDomain(WithResourceID(NewTestDecision("test-decision"), "test-resource-4"), v1alpha1.SchedulingDomainMachines), expectedContains: []string{"Initial placement of the ironcore machine"}, }, { name: "unknown resource type falls back to generic", - decision: WithDecisionType(WithResourceID(NewTestDecision("test-decision"), "test-resource-5"), "unknown-type"), + decision: WithSchedulingDomain(WithResourceID(NewTestDecision("test-decision"), "test-resource-5"), "unknown-type"), expectedContains: []string{"Initial placement of the resource"}, }, { @@ -191,8 +191,8 @@ func NewTestDecision(name string) *v1alpha1.Decision { Namespace: "default", // Sensible default }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, // Most common - ResourceID: "test-resource", // Generic default + SchedulingDomain: v1alpha1.SchedulingDomainNova, // Most common + ResourceID: "test-resource", // Generic default }, Status: v1alpha1.DecisionStatus{}, } @@ -241,8 +241,8 @@ func WithSteps(decision *v1alpha1.Decision, steps ...v1alpha1.StepResult) *v1alp return decision } -func WithDecisionType(decision *v1alpha1.Decision, decisionType v1alpha1.DecisionType) *v1alpha1.Decision { - decision.Spec.Type = decisionType +func WithSchedulingDomain(decision *v1alpha1.Decision, schedulingDomain v1alpha1.SchedulingDomain) *v1alpha1.Decision { + decision.Spec.SchedulingDomain = schedulingDomain return decision } @@ -303,8 +303,8 @@ func NewDecision(name string) *DecisionBuilder { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource", }, Status: v1alpha1.DecisionStatus{}, }, @@ -316,8 +316,8 @@ func (b *DecisionBuilder) WithResourceID(resourceID string) *DecisionBuilder { return b } -func (b *DecisionBuilder) WithType(decisionType v1alpha1.DecisionType) *DecisionBuilder { - b.decision.Spec.Type = decisionType +func (b *DecisionBuilder) WithSchedulingDomain(schedulingDomain v1alpha1.SchedulingDomain) *DecisionBuilder { + b.decision.Spec.SchedulingDomain = schedulingDomain return b } @@ -899,8 +899,8 @@ func TestExplainer_GlobalChainAnalysis(t *testing.T) { CreationTimestamp: time3, }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource", }, Status: v1alpha1.DecisionStatus{ History: &[]corev1.ObjectReference{ @@ -953,8 +953,8 @@ func TestExplainer_GlobalChainAnalysis(t *testing.T) { CreationTimestamp: time3, }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource", }, Status: v1alpha1.DecisionStatus{ History: &[]corev1.ObjectReference{ @@ -1007,8 +1007,8 @@ func TestExplainer_GlobalChainAnalysis(t *testing.T) { CreationTimestamp: time3, }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource", }, Status: v1alpha1.DecisionStatus{ History: &[]corev1.ObjectReference{ @@ -1075,8 +1075,8 @@ func TestExplainer_GlobalChainAnalysis(t *testing.T) { CreationTimestamp: metav1.Time{Time: baseTime.Time}, }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource", }, Status: v1alpha1.DecisionStatus{ History: &[]corev1.ObjectReference{ @@ -1114,8 +1114,8 @@ func TestExplainer_GlobalChainAnalysis(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource", }, Status: v1alpha1.DecisionStatus{ History: nil, // No history @@ -1316,8 +1316,8 @@ func TestExplainer_RawVsNormalizedComparison(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "test-resource", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "test-resource", }, Status: v1alpha1.DecisionStatus{ Result: &v1alpha1.DecisionResult{ diff --git a/internal/scheduling/decisions/machines/pipeline_controller.go b/internal/scheduling/decisions/machines/pipeline_controller.go index cf128874..2e372bf8 100644 --- a/internal/scheduling/decisions/machines/pipeline_controller.go +++ b/internal/scheduling/decisions/machines/pipeline_controller.go @@ -83,9 +83,8 @@ func (c *DecisionPipelineController) ProcessNewMachine(ctx context.Context, mach GenerateName: "machine-", }, Spec: v1alpha1.DecisionSpec{ - Operator: c.Conf.Operator, - Type: v1alpha1.DecisionTypeIroncoreMachine, - ResourceID: machine.Name, + SchedulingDomain: v1alpha1.SchedulingDomainMachines, + ResourceID: machine.Name, PipelineRef: corev1.ObjectReference{ Name: "machines-scheduler", }, @@ -217,6 +216,7 @@ func (c *DecisionPipelineController) handleMachine() handler.EventHandler { func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl *multicluster.Client) error { c.Initializer = c + c.SchedulingDomain = v1alpha1.SchedulingDomainMachines if err := mgr.Add(manager.RunnableFunc(c.InitAllPipelines)); err != nil { return err } @@ -248,8 +248,8 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { pipeline := obj.(*v1alpha1.Pipeline) - // Only react to pipelines matching the operator. - if pipeline.Spec.Operator != c.Conf.Operator { + // Only react to pipelines matching the scheduling domain. + if pipeline.Spec.SchedulingDomain != v1alpha1.SchedulingDomainMachines { return false } return pipeline.Spec.Type == c.PipelineType() @@ -266,8 +266,8 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { step := obj.(*v1alpha1.Step) - // Only react to steps matching the operator. - if step.Spec.Operator != c.Conf.Operator { + // Only react to steps matching the scheduling domain. + if step.Spec.SchedulingDomain != v1alpha1.SchedulingDomainMachines { return false } // Only react to filter and weigher steps. @@ -283,15 +283,14 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * &v1alpha1.Decision{}, builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool { decision := obj.(*v1alpha1.Decision) - if decision.Spec.Operator != c.Conf.Operator { + if decision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainMachines { return false } // Ignore already decided schedulings. if decision.Status.Result != nil { return false } - // Only handle ironcore machine decisions. - return decision.Spec.Type == v1alpha1.DecisionTypeIroncoreMachine + return true })), ). Complete(c) diff --git a/internal/scheduling/decisions/machines/pipeline_controller_test.go b/internal/scheduling/decisions/machines/pipeline_controller_test.go index 9987971f..64596149 100644 --- a/internal/scheduling/decisions/machines/pipeline_controller_test.go +++ b/internal/scheduling/decisions/machines/pipeline_controller_test.go @@ -47,9 +47,8 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Name: "test-decision", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeIroncoreMachine, - ResourceID: "test-machine", + SchedulingDomain: v1alpha1.SchedulingDomainMachines, + ResourceID: "test-machine", PipelineRef: corev1.ObjectReference{ Name: "machines-scheduler", }, @@ -88,9 +87,8 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Name: "test-decision-no-pools", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeIroncoreMachine, - ResourceID: "test-machine", + SchedulingDomain: v1alpha1.SchedulingDomainMachines, + ResourceID: "test-machine", PipelineRef: corev1.ObjectReference{ Name: "machines-scheduler", }, @@ -129,7 +127,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { }, }, Conf: conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainMachines, }, Monitor: lib.PipelineMonitor{}, } @@ -316,10 +314,10 @@ func TestDecisionPipelineController_ProcessNewMachine(t *testing.T) { Name: "machines-scheduler", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainMachines, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, createDecisions: true, @@ -349,10 +347,10 @@ func TestDecisionPipelineController_ProcessNewMachine(t *testing.T) { Name: "machines-scheduler", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: false, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainMachines, + CreateDecisions: false, + Steps: []v1alpha1.StepInPipeline{}, }, }, createDecisions: false, @@ -395,10 +393,10 @@ func TestDecisionPipelineController_ProcessNewMachine(t *testing.T) { Name: "machines-scheduler", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainMachines, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, createDecisions: true, @@ -430,7 +428,7 @@ func TestDecisionPipelineController_ProcessNewMachine(t *testing.T) { PipelineConfigs: map[string]v1alpha1.Pipeline{}, }, Conf: conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainMachines, }, Monitor: lib.PipelineMonitor{}, } @@ -470,11 +468,8 @@ func TestDecisionPipelineController_ProcessNewMachine(t *testing.T) { found = true // Verify decision properties - if decision.Spec.Operator != "test-operator" { - t.Errorf("expected operator %q, got %q", "test-operator", decision.Spec.Operator) - } - if decision.Spec.Type != v1alpha1.DecisionTypeIroncoreMachine { - t.Errorf("expected type %q, got %q", v1alpha1.DecisionTypeIroncoreMachine, decision.Spec.Type) + if decision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainMachines { + t.Errorf("expected scheduling domain %q, got %q", v1alpha1.SchedulingDomainMachines, decision.Spec.SchedulingDomain) } if decision.Spec.ResourceID != tt.machine.Name { t.Errorf("expected resource ID %q, got %q", tt.machine.Name, decision.Spec.ResourceID) diff --git a/internal/scheduling/decisions/manila/cleanup.go b/internal/scheduling/decisions/manila/cleanup.go index 5cd01f96..6ad87aa3 100644 --- a/internal/scheduling/decisions/manila/cleanup.go +++ b/internal/scheduling/decisions/manila/cleanup.go @@ -110,10 +110,7 @@ func Cleanup(ctx context.Context, client client.Client, conf conf.Config) error } for _, decision := range decisionList.Items { // Skip non-manila decisions. - if decision.Spec.Operator != conf.Operator { - continue - } - if decision.Spec.Type != v1alpha1.DecisionTypeManilaShare { + if decision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainManila { continue } // Skip decisions for which the share still exists. diff --git a/internal/scheduling/decisions/manila/cleanup_test.go b/internal/scheduling/decisions/manila/cleanup_test.go index f348793d..6431b2d7 100644 --- a/internal/scheduling/decisions/manila/cleanup_test.go +++ b/internal/scheduling/decisions/manila/cleanup_test.go @@ -75,9 +75,8 @@ func TestCleanupManila(t *testing.T) { Name: "decision-existing-share", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeManilaShare, - ResourceID: "share-exists", + SchedulingDomain: v1alpha1.SchedulingDomainManila, + ResourceID: "share-exists", }, }, { @@ -85,9 +84,8 @@ func TestCleanupManila(t *testing.T) { Name: "decision-deleted-share", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeManilaShare, - ResourceID: "share-deleted", + SchedulingDomain: v1alpha1.SchedulingDomainManila, + ResourceID: "share-deleted", }, }, }, @@ -105,9 +103,8 @@ func TestCleanupManila(t *testing.T) { Name: "decision-share-1", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeManilaShare, - ResourceID: "share-1", + SchedulingDomain: v1alpha1.SchedulingDomainManila, + ResourceID: "share-1", }, }, { @@ -115,9 +112,8 @@ func TestCleanupManila(t *testing.T) { Name: "decision-share-2", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeManilaShare, - ResourceID: "share-2", + SchedulingDomain: v1alpha1.SchedulingDomainManila, + ResourceID: "share-2", }, }, }, @@ -136,9 +132,8 @@ func TestCleanupManila(t *testing.T) { Name: "decision-other-type", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeCinderVolume, - ResourceID: "some-resource", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, + ResourceID: "some-resource", }, }, { @@ -146,9 +141,8 @@ func TestCleanupManila(t *testing.T) { Name: "decision-other-operator", }, Spec: v1alpha1.DecisionSpec{ - Operator: "other-operator", - Type: v1alpha1.DecisionTypeManilaShare, - ResourceID: "share-1", + SchedulingDomain: "other-operator", + ResourceID: "share-1", }, }, }, @@ -339,7 +333,7 @@ func TestCleanupManila(t *testing.T) { WithObjects(objects...). Build() config := conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainManila, KeystoneSecretRef: corev1.SecretReference{ Name: "keystone-secret", Namespace: "default", @@ -422,7 +416,7 @@ func TestCleanupManilaDecisionsCancel(t *testing.T) { Build() config := conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainManila, KeystoneSecretRef: corev1.SecretReference{ Name: "keystone-secret", Namespace: "default", diff --git a/internal/scheduling/decisions/manila/pipeline_controller.go b/internal/scheduling/decisions/manila/pipeline_controller.go index 050ff1c8..d3537c68 100644 --- a/internal/scheduling/decisions/manila/pipeline_controller.go +++ b/internal/scheduling/decisions/manila/pipeline_controller.go @@ -136,6 +136,7 @@ func (c *DecisionPipelineController) InitPipeline( func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl *multicluster.Client) error { c.Initializer = c + c.SchedulingDomain = v1alpha1.SchedulingDomainManila if err := mgr.Add(manager.RunnableFunc(c.InitAllPipelines)); err != nil { return err } @@ -150,8 +151,8 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { pipeline := obj.(*v1alpha1.Pipeline) - // Only react to pipelines matching the operator. - if pipeline.Spec.Operator != c.Conf.Operator { + // Only react to pipelines matching the scheduling domain. + if pipeline.Spec.SchedulingDomain != v1alpha1.SchedulingDomainManila { return false } return pipeline.Spec.Type == c.PipelineType() @@ -168,8 +169,8 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { step := obj.(*v1alpha1.Step) - // Only react to steps matching the operator. - if step.Spec.Operator != c.Conf.Operator { + // Only react to steps matching the scheduling domain. + if step.Spec.SchedulingDomain != v1alpha1.SchedulingDomainManila { return false } // Only react to filter and weigher steps. @@ -190,8 +191,8 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { knowledge := obj.(*v1alpha1.Knowledge) - // Only react to knowledge matching the operator. - return knowledge.Spec.Operator == c.Conf.Operator + // Only react to knowledge matching the scheduling domain. + return knowledge.Spec.SchedulingDomain == v1alpha1.SchedulingDomainManila }), ). Named("cortex-manila-decisions"). @@ -199,15 +200,14 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * &v1alpha1.Decision{}, builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool { decision := obj.(*v1alpha1.Decision) - if decision.Spec.Operator != c.Conf.Operator { + if decision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainManila { return false } // Ignore already decided schedulings. if decision.Status.Result != nil { return false } - // Only handle manila decisions. - return decision.Spec.Type == v1alpha1.DecisionTypeManilaShare + return true })), ). Complete(c) diff --git a/internal/scheduling/decisions/manila/pipeline_controller_test.go b/internal/scheduling/decisions/manila/pipeline_controller_test.go index d7bf6fd2..9ab5c0b2 100644 --- a/internal/scheduling/decisions/manila/pipeline_controller_test.go +++ b/internal/scheduling/decisions/manila/pipeline_controller_test.go @@ -69,8 +69,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeManilaShare, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainManila, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -84,9 +83,9 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainManila, + Steps: []v1alpha1.StepInPipeline{}, }, }, expectError: false, @@ -101,8 +100,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeManilaShare, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainManila, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -114,9 +112,9 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainManila, + Steps: []v1alpha1.StepInPipeline{}, }, }, expectError: true, @@ -131,8 +129,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeManilaShare, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainManila, PipelineRef: corev1.ObjectReference{ Name: "nonexistent-pipeline", }, @@ -168,7 +165,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { }, Monitor: lib.PipelineMonitor{}, Conf: conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainManila, }, } @@ -270,8 +267,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeManilaShare, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainManila, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -285,10 +281,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainManila, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, createDecisions: true, @@ -305,8 +301,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeManilaShare, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainManila, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -320,10 +315,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: false, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainManila, + CreateDecisions: false, + Steps: []v1alpha1.StepInPipeline{}, }, }, createDecisions: false, @@ -340,8 +335,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeManilaShare, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainManila, PipelineRef: corev1.ObjectReference{ Name: "nonexistent-pipeline", }, @@ -364,8 +358,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeManilaShare, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainManila, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -377,10 +370,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainManila, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, createDecisions: true, @@ -412,7 +405,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { }, Monitor: lib.PipelineMonitor{}, Conf: conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainManila, }, } @@ -445,8 +438,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { found := false for _, decision := range decisions.Items { - if decision.Spec.Type == v1alpha1.DecisionTypeManilaShare && - decision.Spec.Operator == "test-operator" { + if decision.Spec.SchedulingDomain == v1alpha1.SchedulingDomainManila { found = true // Verify decision properties diff --git a/internal/scheduling/decisions/nova/cleanup.go b/internal/scheduling/decisions/nova/cleanup.go index c4bf8df9..5a652445 100644 --- a/internal/scheduling/decisions/nova/cleanup.go +++ b/internal/scheduling/decisions/nova/cleanup.go @@ -119,10 +119,7 @@ func Cleanup(ctx context.Context, client client.Client, conf conf.Config) error } for _, decision := range decisionList.Items { // Skip non-nova decisions. - if decision.Spec.Operator != conf.Operator { - continue - } - if decision.Spec.Type != v1alpha1.DecisionTypeNovaServer { + if decision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainNova { continue } // Skip decisions that are linked to existing reservations. diff --git a/internal/scheduling/decisions/nova/cleanup_test.go b/internal/scheduling/decisions/nova/cleanup_test.go index 61bdb171..6bfab7a0 100644 --- a/internal/scheduling/decisions/nova/cleanup_test.go +++ b/internal/scheduling/decisions/nova/cleanup_test.go @@ -76,9 +76,8 @@ func TestCleanupNova(t *testing.T) { Name: "decision-existing-server", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "server-exists", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "server-exists", }, }, { @@ -86,9 +85,8 @@ func TestCleanupNova(t *testing.T) { Name: "decision-deleted-server", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "server-deleted", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "server-deleted", }, }, }, @@ -106,9 +104,8 @@ func TestCleanupNova(t *testing.T) { Name: "decision-server-1", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "server-1", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "server-1", }, }, { @@ -116,9 +113,8 @@ func TestCleanupNova(t *testing.T) { Name: "decision-server-2", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "server-2", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "server-2", }, }, }, @@ -137,9 +133,8 @@ func TestCleanupNova(t *testing.T) { Name: "decision-reserved-server", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "server-reserved", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "server-reserved", }, }, { @@ -147,9 +142,8 @@ func TestCleanupNova(t *testing.T) { Name: "decision-unreserved-server", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "server-unreserved", + SchedulingDomain: v1alpha1.SchedulingDomainNova, + ResourceID: "server-unreserved", }, }, }, @@ -172,9 +166,8 @@ func TestCleanupNova(t *testing.T) { Name: "decision-cinder", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypeCinderVolume, - ResourceID: "volume-1", + SchedulingDomain: v1alpha1.SchedulingDomainCinder, + ResourceID: "volume-1", }, }, { @@ -182,9 +175,8 @@ func TestCleanupNova(t *testing.T) { Name: "decision-wrong-operator", }, Spec: v1alpha1.DecisionSpec{ - Operator: "other-operator", - Type: v1alpha1.DecisionTypeNovaServer, - ResourceID: "server-1", + SchedulingDomain: "other-operator", + ResourceID: "server-1", }, }, }, @@ -344,7 +336,7 @@ func TestCleanupNova(t *testing.T) { WithObjects(objects...). Build() config := conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, KeystoneSecretRef: corev1.SecretReference{ Name: "keystone-secret", Namespace: "default", @@ -426,7 +418,7 @@ func TestCleanupNovaDecisionsCancel(t *testing.T) { Build() config := conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, KeystoneSecretRef: corev1.SecretReference{ Name: "keystone-secret", Namespace: "default", diff --git a/internal/scheduling/decisions/nova/pipeline_controller.go b/internal/scheduling/decisions/nova/pipeline_controller.go index 4b35f2e1..ff8fca9a 100644 --- a/internal/scheduling/decisions/nova/pipeline_controller.go +++ b/internal/scheduling/decisions/nova/pipeline_controller.go @@ -137,6 +137,7 @@ func (c *DecisionPipelineController) InitPipeline( func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl *multicluster.Client) error { c.Initializer = c + c.SchedulingDomain = v1alpha1.SchedulingDomainNova if err := mgr.Add(manager.RunnableFunc(c.InitAllPipelines)); err != nil { return err } @@ -151,8 +152,8 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { pipeline := obj.(*v1alpha1.Pipeline) - // Only react to pipelines matching the operator. - if pipeline.Spec.Operator != c.Conf.Operator { + // Only react to pipelines matching the scheduling domain. + if pipeline.Spec.SchedulingDomain != v1alpha1.SchedulingDomainNova { return false } return pipeline.Spec.Type == c.PipelineType() @@ -169,8 +170,8 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { step := obj.(*v1alpha1.Step) - // Only react to steps matching the operator. - if step.Spec.Operator != c.Conf.Operator { + // Only react to steps matching the scheduling domain. + if step.Spec.SchedulingDomain != v1alpha1.SchedulingDomainNova { return false } // Only react to filter and weigher steps. @@ -191,8 +192,8 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { knowledge := obj.(*v1alpha1.Knowledge) - // Only react to knowledge matching the operator. - return knowledge.Spec.Operator == c.Conf.Operator + // Only react to knowledge matching the scheduling domain. + return knowledge.Spec.SchedulingDomain == v1alpha1.SchedulingDomainNova }), ). // Watch hypervisor changes so the cache gets updated. @@ -202,15 +203,14 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * &v1alpha1.Decision{}, builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool { decision := obj.(*v1alpha1.Decision) - if decision.Spec.Operator != c.Conf.Operator { + if decision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainNova { return false } // Ignore already decided schedulings. if decision.Status.Result != nil { return false } - // Only handle nova decisions. - return decision.Spec.Type == v1alpha1.DecisionTypeNovaServer + return true })), ). Complete(c) diff --git a/internal/scheduling/decisions/nova/pipeline_controller_test.go b/internal/scheduling/decisions/nova/pipeline_controller_test.go index aba391f5..2b6c637d 100644 --- a/internal/scheduling/decisions/nova/pipeline_controller_test.go +++ b/internal/scheduling/decisions/nova/pipeline_controller_test.go @@ -77,8 +77,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -92,9 +91,9 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + Steps: []v1alpha1.StepInPipeline{}, }, }, expectError: false, @@ -109,8 +108,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -122,9 +120,9 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + Steps: []v1alpha1.StepInPipeline{}, }, }, expectError: true, @@ -139,8 +137,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, PipelineRef: corev1.ObjectReference{ Name: "nonexistent-pipeline", }, @@ -162,8 +159,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -177,9 +173,9 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + Steps: []v1alpha1.StepInPipeline{}, }, }, expectError: true, @@ -208,7 +204,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { }, Monitor: lib.PipelineMonitor{}, Conf: conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, }, } @@ -424,8 +420,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -439,10 +434,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, pipelineConf: &v1alpha1.Pipeline{ @@ -450,10 +445,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, setupPipelineConfigs: true, @@ -472,8 +467,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline-no-create", }, @@ -487,10 +481,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline-no-create", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: false, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + CreateDecisions: false, + Steps: []v1alpha1.StepInPipeline{}, }, }, pipelineConf: &v1alpha1.Pipeline{ @@ -498,10 +492,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline-no-create", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: false, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + CreateDecisions: false, + Steps: []v1alpha1.StepInPipeline{}, }, }, setupPipelineConfigs: true, @@ -520,8 +514,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, PipelineRef: corev1.ObjectReference{ Name: "nonexistent-pipeline", }, @@ -548,8 +541,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -561,10 +553,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, pipelineConf: &v1alpha1.Pipeline{ @@ -572,10 +564,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, setupPipelineConfigs: true, @@ -595,8 +587,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, PipelineRef: corev1.ObjectReference{ Name: "test-pipeline", }, @@ -611,10 +602,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, setupPipelineConfigs: true, @@ -634,8 +625,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Namespace: "default", }, Spec: v1alpha1.DecisionSpec{ - Type: v1alpha1.DecisionTypeNovaServer, - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, PipelineRef: corev1.ObjectReference{ Name: "missing-runtime-pipeline", }, @@ -650,10 +640,10 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { Name: "missing-runtime-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainNova, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, setupPipelineConfigs: true, @@ -688,7 +678,7 @@ func TestDecisionPipelineController_ProcessNewDecisionFromAPI(t *testing.T) { }, Monitor: lib.PipelineMonitor{}, Conf: conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainNova, }, } diff --git a/internal/scheduling/decisions/pods/pipeline_controller.go b/internal/scheduling/decisions/pods/pipeline_controller.go index 10b62d7a..22cccc69 100644 --- a/internal/scheduling/decisions/pods/pipeline_controller.go +++ b/internal/scheduling/decisions/pods/pipeline_controller.go @@ -82,9 +82,8 @@ func (c *DecisionPipelineController) ProcessNewPod(ctx context.Context, pod *cor GenerateName: "pod-", }, Spec: v1alpha1.DecisionSpec{ - Operator: c.Conf.Operator, - Type: v1alpha1.DecisionTypePod, - ResourceID: pod.Name, + SchedulingDomain: v1alpha1.SchedulingDomainPods, + ResourceID: pod.Name, PipelineRef: corev1.ObjectReference{ Name: "pods-scheduler", }, @@ -230,6 +229,7 @@ func (c *DecisionPipelineController) handlePod() handler.EventHandler { func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl *multicluster.Client) error { c.Initializer = c + c.SchedulingDomain = v1alpha1.SchedulingDomainPods if err := mgr.Add(manager.RunnableFunc(c.InitAllPipelines)); err != nil { return err } @@ -244,7 +244,7 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * // Skip pods that already have a node assigned. return false } - return pod.Spec.SchedulerName == c.Conf.Operator + return pod.Spec.SchedulerName == string(v1alpha1.SchedulingDomainPods) }), ). // Watch pipeline changes so that we can reconfigure pipelines as needed. @@ -257,8 +257,8 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { pipeline := obj.(*v1alpha1.Pipeline) - // Only react to pipelines matching the operator. - if pipeline.Spec.Operator != c.Conf.Operator { + // Only react to pipelines matching the scheduling domain. + if pipeline.Spec.SchedulingDomain != v1alpha1.SchedulingDomainPods { return false } return pipeline.Spec.Type == v1alpha1.PipelineTypeFilterWeigher @@ -275,8 +275,8 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * }, predicate.NewPredicateFuncs(func(obj client.Object) bool { step := obj.(*v1alpha1.Step) - // Only react to steps matching the operator. - if step.Spec.Operator != c.Conf.Operator { + // Only react to steps matching the scheduling domain. + if step.Spec.SchedulingDomain != v1alpha1.SchedulingDomainPods { return false } // Only react to filter and weigher steps. @@ -292,15 +292,14 @@ func (c *DecisionPipelineController) SetupWithManager(mgr manager.Manager, mcl * &v1alpha1.Decision{}, builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool { decision := obj.(*v1alpha1.Decision) - if decision.Spec.Operator != c.Conf.Operator { + if decision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainPods { return false } // Ignore already decided schedulings. if decision.Status.Result != nil { return false } - // Only handle pod decisions. - return decision.Spec.Type == v1alpha1.DecisionTypePod + return true })), ). Complete(c) diff --git a/internal/scheduling/decisions/pods/pipeline_controller_test.go b/internal/scheduling/decisions/pods/pipeline_controller_test.go index e2037b2c..2521952d 100644 --- a/internal/scheduling/decisions/pods/pipeline_controller_test.go +++ b/internal/scheduling/decisions/pods/pipeline_controller_test.go @@ -45,9 +45,8 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Name: "test-decision", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypePod, - ResourceID: "test-pod", + SchedulingDomain: v1alpha1.SchedulingDomainPods, + ResourceID: "test-pod", PipelineRef: corev1.ObjectReference{ Name: "pods-scheduler", }, @@ -85,9 +84,8 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { Name: "test-decision-no-nodes", }, Spec: v1alpha1.DecisionSpec{ - Operator: "test-operator", - Type: v1alpha1.DecisionTypePod, - ResourceID: "test-pod", + SchedulingDomain: v1alpha1.SchedulingDomainPods, + ResourceID: "test-pod", PipelineRef: corev1.ObjectReference{ Name: "pods-scheduler", }, @@ -126,7 +124,7 @@ func TestDecisionPipelineController_Reconcile(t *testing.T) { }, }, Conf: conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainPods, }, Monitor: lib.PipelineMonitor{}, } @@ -291,10 +289,10 @@ func TestDecisionPipelineController_ProcessNewPod(t *testing.T) { Name: "pods-scheduler", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainPods, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, createDecisions: true, @@ -324,10 +322,10 @@ func TestDecisionPipelineController_ProcessNewPod(t *testing.T) { Name: "pods-scheduler", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: false, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainPods, + CreateDecisions: false, + Steps: []v1alpha1.StepInPipeline{}, }, }, createDecisions: false, @@ -370,10 +368,10 @@ func TestDecisionPipelineController_ProcessNewPod(t *testing.T) { Name: "pods-scheduler", }, Spec: v1alpha1.PipelineSpec{ - Type: v1alpha1.PipelineTypeFilterWeigher, - Operator: "test-operator", - CreateDecisions: true, - Steps: []v1alpha1.StepInPipeline{}, + Type: v1alpha1.PipelineTypeFilterWeigher, + SchedulingDomain: v1alpha1.SchedulingDomainPods, + CreateDecisions: true, + Steps: []v1alpha1.StepInPipeline{}, }, }, createDecisions: true, @@ -405,7 +403,7 @@ func TestDecisionPipelineController_ProcessNewPod(t *testing.T) { PipelineConfigs: map[string]v1alpha1.Pipeline{}, }, Conf: conf.Config{ - Operator: "test-operator", + SchedulingDomain: v1alpha1.SchedulingDomainPods, }, Monitor: lib.PipelineMonitor{}, } @@ -445,11 +443,8 @@ func TestDecisionPipelineController_ProcessNewPod(t *testing.T) { found = true // Verify decision properties - if decision.Spec.Operator != "test-operator" { - t.Errorf("expected operator %q, got %q", "test-operator", decision.Spec.Operator) - } - if decision.Spec.Type != v1alpha1.DecisionTypePod { - t.Errorf("expected type %q, got %q", v1alpha1.DecisionTypePod, decision.Spec.Type) + if decision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainPods { + t.Errorf("expected scheduling domain %q, got %q", v1alpha1.SchedulingDomainPods, decision.Spec.SchedulingDomain) } if decision.Spec.ResourceID != tt.pod.Name { t.Errorf("expected resource ID %q, got %q", tt.pod.Name, decision.Spec.ResourceID) diff --git a/internal/scheduling/descheduling/nova/pipeline_controller.go b/internal/scheduling/descheduling/nova/pipeline_controller.go index 1d7229b4..a39c9f34 100644 --- a/internal/scheduling/descheduling/nova/pipeline_controller.go +++ b/internal/scheduling/descheduling/nova/pipeline_controller.go @@ -86,6 +86,7 @@ func (c *DeschedulingsPipelineController) Reconcile(ctx context.Context, req ctr func (c *DeschedulingsPipelineController) SetupWithManager(mgr ctrl.Manager, mcl *multicluster.Client) error { c.Initializer = c + c.SchedulingDomain = v1alpha1.SchedulingDomainNova if err := mgr.Add(manager.RunnableFunc(func(ctx context.Context) error { // Initialize the cycle detector. return c.CycleDetector.Init(ctx, mgr.GetClient(), c.Conf) @@ -106,8 +107,8 @@ func (c *DeschedulingsPipelineController) SetupWithManager(mgr ctrl.Manager, mcl }, predicate.NewPredicateFuncs(func(obj client.Object) bool { pipeline := obj.(*v1alpha1.Pipeline) - // Only react to pipelines matching the operator. - if pipeline.Spec.Operator != c.Conf.Operator { + // Only react to pipelines matching the scheduling domain. + if pipeline.Spec.SchedulingDomain != v1alpha1.SchedulingDomainNova { return false } return pipeline.Spec.Type == c.PipelineType() @@ -124,8 +125,8 @@ func (c *DeschedulingsPipelineController) SetupWithManager(mgr ctrl.Manager, mcl }, predicate.NewPredicateFuncs(func(obj client.Object) bool { step := obj.(*v1alpha1.Step) - // Only react to steps matching the operator. - if step.Spec.Operator != c.Conf.Operator { + // Only react to steps matching the scheduling domain. + if step.Spec.SchedulingDomain != v1alpha1.SchedulingDomainNova { return false } // Only react to filter and weigher steps. @@ -145,8 +146,8 @@ func (c *DeschedulingsPipelineController) SetupWithManager(mgr ctrl.Manager, mcl }, predicate.NewPredicateFuncs(func(obj client.Object) bool { knowledge := obj.(*v1alpha1.Knowledge) - // Only react to knowledge matching the operator. - return knowledge.Spec.Operator == c.Conf.Operator + // Only react to knowledge matching the scheduling domain. + return knowledge.Spec.SchedulingDomain == v1alpha1.SchedulingDomainNova }), ). Named("cortex-nova-deschedulings"). diff --git a/internal/scheduling/external/cinder/api.go b/internal/scheduling/external/cinder/api.go index ba33a4a4..53f54378 100644 --- a/internal/scheduling/external/cinder/api.go +++ b/internal/scheduling/external/cinder/api.go @@ -146,12 +146,11 @@ func (httpAPI *httpAPI) CinderExternalScheduler(w http.ResponseWriter, r *http.R GenerateName: "cinder-", }, Spec: v1alpha1.DecisionSpec{ - Operator: httpAPI.config.Operator, + SchedulingDomain: v1alpha1.SchedulingDomainCinder, PipelineRef: corev1.ObjectReference{ Name: requestData.Pipeline, }, ResourceID: "", // TODO - Type: v1alpha1.DecisionTypeCinderVolume, CinderRaw: &raw, }, } diff --git a/internal/scheduling/external/cinder/api_test.go b/internal/scheduling/external/cinder/api_test.go index 7c698bde..139441be 100644 --- a/internal/scheduling/external/cinder/api_test.go +++ b/internal/scheduling/external/cinder/api_test.go @@ -32,7 +32,7 @@ func (m *mockHTTPAPIDelegate) ProcessNewDecisionFromAPI(ctx context.Context, dec } func TestNewAPI(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: "test-operator"} delegate := &mockHTTPAPIDelegate{} api := NewAPI(config, delegate) @@ -46,8 +46,8 @@ func TestNewAPI(t *testing.T) { t.Fatal("NewAPI did not return httpAPI type") } - if httpAPI.config.Operator != "test-operator" { - t.Errorf("Expected operator 'test-operator', got %s", httpAPI.config.Operator) + if httpAPI.config.SchedulingDomain != "test-operator" { + t.Errorf("Expected scheduling domain 'test-operator', got %s", httpAPI.config.SchedulingDomain) } if httpAPI.delegate != delegate { @@ -60,7 +60,7 @@ func TestNewAPI(t *testing.T) { } func TestHTTPAPI_Init(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: "test-operator"} delegate := &mockHTTPAPIDelegate{} api := NewAPI(config, delegate) @@ -79,7 +79,7 @@ func TestHTTPAPI_Init(t *testing.T) { } func TestHTTPAPI_canRunScheduler(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: "test-operator"} delegate := &mockHTTPAPIDelegate{} api := NewAPI(config, delegate).(*httpAPI) @@ -256,7 +256,7 @@ func TestHTTPAPI_CinderExternalScheduler(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: "test-operator"} delegate := &mockHTTPAPIDelegate{ processDecisionFunc: func(ctx context.Context, decision *v1alpha1.Decision) error { if tt.processDecisionErr != nil { @@ -309,7 +309,7 @@ func TestHTTPAPI_CinderExternalScheduler(t *testing.T) { } func TestHTTPAPI_CinderExternalScheduler_DecisionCreation(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: v1alpha1.SchedulingDomainCinder} var capturedDecision *v1alpha1.Decision delegate := &mockHTTPAPIDelegate{ @@ -353,18 +353,14 @@ func TestHTTPAPI_CinderExternalScheduler_DecisionCreation(t *testing.T) { } // Verify decision fields - if capturedDecision.Spec.Operator != "test-operator" { - t.Errorf("Expected operator 'test-operator', got %s", capturedDecision.Spec.Operator) + if capturedDecision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainCinder { + t.Errorf("Expected scheduling domain %s, got %s", v1alpha1.SchedulingDomainCinder, capturedDecision.Spec.SchedulingDomain) } if capturedDecision.Spec.PipelineRef.Name != "test-pipeline" { t.Errorf("Expected pipeline 'test-pipeline', got %s", capturedDecision.Spec.PipelineRef.Name) } - if capturedDecision.Spec.Type != v1alpha1.DecisionTypeCinderVolume { - t.Errorf("Expected type %s, got %s", v1alpha1.DecisionTypeCinderVolume, capturedDecision.Spec.Type) - } - if capturedDecision.GenerateName != "cinder-" { t.Errorf("Expected generate name 'cinder-', got %s", capturedDecision.GenerateName) } diff --git a/internal/scheduling/external/manila/api.go b/internal/scheduling/external/manila/api.go index aaaf6d31..d2665d8e 100644 --- a/internal/scheduling/external/manila/api.go +++ b/internal/scheduling/external/manila/api.go @@ -146,12 +146,11 @@ func (httpAPI *httpAPI) ManilaExternalScheduler(w http.ResponseWriter, r *http.R GenerateName: "manila-", }, Spec: v1alpha1.DecisionSpec{ - Operator: httpAPI.config.Operator, + SchedulingDomain: v1alpha1.SchedulingDomainManila, PipelineRef: corev1.ObjectReference{ Name: requestData.Pipeline, }, ResourceID: "", // TODO model out the spec. - Type: v1alpha1.DecisionTypeManilaShare, ManilaRaw: &raw, }, } diff --git a/internal/scheduling/external/manila/api_test.go b/internal/scheduling/external/manila/api_test.go index f8d4af18..5b3d7235 100644 --- a/internal/scheduling/external/manila/api_test.go +++ b/internal/scheduling/external/manila/api_test.go @@ -32,7 +32,7 @@ func (m *mockHTTPAPIDelegate) ProcessNewDecisionFromAPI(ctx context.Context, dec } func TestNewAPI(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: "test-operator"} delegate := &mockHTTPAPIDelegate{} api := NewAPI(config, delegate) @@ -46,8 +46,8 @@ func TestNewAPI(t *testing.T) { t.Fatal("NewAPI did not return httpAPI type") } - if httpAPI.config.Operator != "test-operator" { - t.Errorf("Expected operator 'test-operator', got %s", httpAPI.config.Operator) + if httpAPI.config.SchedulingDomain != "test-operator" { + t.Errorf("Expected scheduling domain 'test-operator', got %s", httpAPI.config.SchedulingDomain) } if httpAPI.delegate != delegate { @@ -60,7 +60,7 @@ func TestNewAPI(t *testing.T) { } func TestHTTPAPI_Init(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: "test-operator"} delegate := &mockHTTPAPIDelegate{} api := NewAPI(config, delegate) @@ -79,7 +79,7 @@ func TestHTTPAPI_Init(t *testing.T) { } func TestHTTPAPI_canRunScheduler(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: "test-operator"} delegate := &mockHTTPAPIDelegate{} api := NewAPI(config, delegate).(*httpAPI) @@ -256,7 +256,7 @@ func TestHTTPAPI_ManilaExternalScheduler(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: "test-operator"} delegate := &mockHTTPAPIDelegate{ processDecisionFunc: func(ctx context.Context, decision *v1alpha1.Decision) error { if tt.processDecisionErr != nil { @@ -309,7 +309,7 @@ func TestHTTPAPI_ManilaExternalScheduler(t *testing.T) { } func TestHTTPAPI_ManilaExternalScheduler_DecisionCreation(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: v1alpha1.SchedulingDomainManila} var capturedDecision *v1alpha1.Decision delegate := &mockHTTPAPIDelegate{ @@ -353,18 +353,14 @@ func TestHTTPAPI_ManilaExternalScheduler_DecisionCreation(t *testing.T) { } // Verify decision fields - if capturedDecision.Spec.Operator != "test-operator" { - t.Errorf("Expected operator 'test-operator', got %s", capturedDecision.Spec.Operator) + if capturedDecision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainManila { + t.Errorf("Expected scheduling domain %s, got %s", v1alpha1.SchedulingDomainManila, capturedDecision.Spec.SchedulingDomain) } if capturedDecision.Spec.PipelineRef.Name != "test-pipeline" { t.Errorf("Expected pipeline 'test-pipeline', got %s", capturedDecision.Spec.PipelineRef.Name) } - if capturedDecision.Spec.Type != v1alpha1.DecisionTypeManilaShare { - t.Errorf("Expected type %s, got %s", v1alpha1.DecisionTypeManilaShare, capturedDecision.Spec.Type) - } - if capturedDecision.GenerateName != "manila-" { t.Errorf("Expected generate name 'manila-', got %s", capturedDecision.GenerateName) } diff --git a/internal/scheduling/external/nova/api.go b/internal/scheduling/external/nova/api.go index 1b728005..0a81d603 100644 --- a/internal/scheduling/external/nova/api.go +++ b/internal/scheduling/external/nova/api.go @@ -167,12 +167,11 @@ func (httpAPI *httpAPI) NovaExternalScheduler(w http.ResponseWriter, r *http.Req GenerateName: "nova-", }, Spec: v1alpha1.DecisionSpec{ - Operator: httpAPI.config.Operator, + SchedulingDomain: v1alpha1.SchedulingDomainNova, PipelineRef: corev1.ObjectReference{ Name: requestData.Pipeline, }, ResourceID: requestData.Spec.Data.InstanceUUID, - Type: v1alpha1.DecisionTypeNovaServer, NovaRaw: &raw, }, } diff --git a/internal/scheduling/external/nova/api_test.go b/internal/scheduling/external/nova/api_test.go index 28319b4c..53e49c8f 100644 --- a/internal/scheduling/external/nova/api_test.go +++ b/internal/scheduling/external/nova/api_test.go @@ -32,7 +32,7 @@ func (m *mockHTTPAPIDelegate) ProcessNewDecisionFromAPI(ctx context.Context, dec } func TestNewAPI(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: "test-operator"} delegate := &mockHTTPAPIDelegate{} api := NewAPI(config, delegate) @@ -46,8 +46,8 @@ func TestNewAPI(t *testing.T) { t.Fatal("NewAPI did not return httpAPI type") } - if httpAPI.config.Operator != "test-operator" { - t.Errorf("Expected operator 'test-operator', got %s", httpAPI.config.Operator) + if httpAPI.config.SchedulingDomain != "test-operator" { + t.Errorf("Expected scheduling domain 'test-operator', got %s", httpAPI.config.SchedulingDomain) } if httpAPI.delegate != delegate { @@ -60,7 +60,7 @@ func TestNewAPI(t *testing.T) { } func TestHTTPAPI_Init(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: "test-operator"} delegate := &mockHTTPAPIDelegate{} api := NewAPI(config, delegate) @@ -79,7 +79,7 @@ func TestHTTPAPI_Init(t *testing.T) { } func TestHTTPAPI_canRunScheduler(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: "test-operator"} delegate := &mockHTTPAPIDelegate{} api := NewAPI(config, delegate).(*httpAPI) @@ -271,7 +271,7 @@ func TestHTTPAPI_NovaExternalScheduler(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: "test-operator"} delegate := &mockHTTPAPIDelegate{ processDecisionFunc: func(ctx context.Context, decision *v1alpha1.Decision) error { if tt.processDecisionErr != nil { @@ -324,7 +324,7 @@ func TestHTTPAPI_NovaExternalScheduler(t *testing.T) { } func TestHTTPAPI_NovaExternalScheduler_DecisionCreation(t *testing.T) { - config := conf.Config{Operator: "test-operator"} + config := conf.Config{SchedulingDomain: v1alpha1.SchedulingDomainNova} var capturedDecision *v1alpha1.Decision delegate := &mockHTTPAPIDelegate{ @@ -373,8 +373,8 @@ func TestHTTPAPI_NovaExternalScheduler_DecisionCreation(t *testing.T) { } // Verify decision fields - if capturedDecision.Spec.Operator != "test-operator" { - t.Errorf("Expected operator 'test-operator', got %s", capturedDecision.Spec.Operator) + if capturedDecision.Spec.SchedulingDomain != v1alpha1.SchedulingDomainNova { + t.Errorf("Expected scheduling domain %s, got %s", v1alpha1.SchedulingDomainNova, capturedDecision.Spec.SchedulingDomain) } if capturedDecision.Spec.PipelineRef.Name != "test-pipeline" { @@ -385,10 +385,6 @@ func TestHTTPAPI_NovaExternalScheduler_DecisionCreation(t *testing.T) { t.Errorf("Expected resource ID 'test-uuid-123', got %s", capturedDecision.Spec.ResourceID) } - if capturedDecision.Spec.Type != v1alpha1.DecisionTypeNovaServer { - t.Errorf("Expected type %s, got %s", v1alpha1.DecisionTypeNovaServer, capturedDecision.Spec.Type) - } - if capturedDecision.GenerateName != "nova-" { t.Errorf("Expected generate name 'nova-', got %s", capturedDecision.GenerateName) } diff --git a/internal/scheduling/lib/pipeline_controller.go b/internal/scheduling/lib/pipeline_controller.go index 47aa4e74..a6cf4d88 100644 --- a/internal/scheduling/lib/pipeline_controller.go +++ b/internal/scheduling/lib/pipeline_controller.go @@ -44,8 +44,8 @@ type BasePipelineController[PipelineType any] struct { Initializer PipelineInitializer[PipelineType] // Kubernetes client to manage/fetch resources. client.Client - // The name of the operator to scope resources to. - OperatorName string + // The scheduling domain to scope resources to. + SchedulingDomain v1alpha1.SchedulingDomain } // Handle the startup of the manager by initializing the pipeline map. @@ -60,7 +60,7 @@ func (c *BasePipelineController[PipelineType]) InitAllPipelines(ctx context.Cont return fmt.Errorf("failed to list existing pipelines: %w", err) } for _, pipelineConf := range pipelines.Items { - if pipelineConf.Spec.Operator != c.OperatorName { + if pipelineConf.Spec.SchedulingDomain != c.SchedulingDomain { continue } if pipelineConf.Spec.Type != c.Initializer.PipelineType() { @@ -80,7 +80,7 @@ func (c *BasePipelineController[PipelineType]) handlePipelineChange( _ workqueue.TypedRateLimitingInterface[reconcile.Request], ) { - if obj.Spec.Operator != c.OperatorName { + if obj.Spec.SchedulingDomain != c.SchedulingDomain { delete(c.Pipelines, obj.Name) // Just to be sure. delete(c.PipelineConfigs, obj.Name) return @@ -203,7 +203,7 @@ func (c *BasePipelineController[PipelineType]) handleStepChange( queue workqueue.TypedRateLimitingInterface[reconcile.Request], ) { - if obj.Spec.Operator != c.OperatorName { + if obj.Spec.SchedulingDomain != c.SchedulingDomain { return } log := ctrl.LoggerFrom(ctx) @@ -307,7 +307,7 @@ func (c *BasePipelineController[PipelineType]) HandleStepDeleted( ) { stepConf := evt.Object.(*v1alpha1.Step) - if stepConf.Spec.Operator != c.OperatorName { + if stepConf.Spec.SchedulingDomain != c.SchedulingDomain { return } // When a step is deleted, we need to re-evaluate all pipelines depending on it. @@ -338,7 +338,7 @@ func (c *BasePipelineController[PipelineType]) handleKnowledgeChange( queue workqueue.TypedRateLimitingInterface[reconcile.Request], ) { - if obj.Spec.Operator != c.OperatorName { + if obj.Spec.SchedulingDomain != c.SchedulingDomain { return } log := ctrl.LoggerFrom(ctx) diff --git a/internal/scheduling/lib/pipeline_controller_test.go b/internal/scheduling/lib/pipeline_controller_test.go index 5158cda4..326f4861 100644 --- a/internal/scheduling/lib/pipeline_controller_test.go +++ b/internal/scheduling/lib/pipeline_controller_test.go @@ -68,9 +68,9 @@ func createTestPipeline(steps []v1alpha1.StepInPipeline) *v1alpha1.Pipeline { Name: "test-pipeline", }, Spec: v1alpha1.PipelineSpec{ - Operator: "test", - Type: "", - Steps: steps, + SchedulingDomain: "test", + Type: "", + Steps: steps, }, } } @@ -82,10 +82,10 @@ func createTestStep(ready bool, knowledges []corev1.ObjectReference) *v1alpha1.S Namespace: "default", }, Spec: v1alpha1.StepSpec{ - Operator: "test", - Type: v1alpha1.StepTypeFilter, - Impl: "test-impl", - Knowledges: knowledges, + SchedulingDomain: "test", + Type: v1alpha1.StepTypeFilter, + Impl: "test-impl", + Knowledges: knowledges, }, Status: v1alpha1.StepStatus{ Ready: ready, @@ -103,7 +103,7 @@ func createTestKnowledge(name string, hasError bool, rawLength int) *v1alpha1.Kn Namespace: "default", }, Spec: v1alpha1.KnowledgeSpec{ - Operator: "test", + SchedulingDomain: "test", }, Status: v1alpha1.KnowledgeStatus{ RawLength: rawLength, @@ -195,9 +195,9 @@ func TestBasePipelineController_InitAllPipelines(t *testing.T) { initializer := &mockInitializer{shouldFail: tt.initializerFails} controller := &BasePipelineController[mockPipeline]{ - Initializer: initializer, - Client: client, - OperatorName: "test", + Initializer: initializer, + Client: client, + SchedulingDomain: "test", } ctx := ctrl.LoggerInto(context.Background(), ctrl.Log) @@ -315,10 +315,10 @@ func TestBasePipelineController_HandlePipelineCreated(t *testing.T) { initializer := &mockInitializer{shouldFail: tt.initializerFails} controller := &BasePipelineController[mockPipeline]{ - Pipelines: make(map[string]mockPipeline), - Initializer: initializer, - Client: client, - OperatorName: "test", + Pipelines: make(map[string]mockPipeline), + Initializer: initializer, + Client: client, + SchedulingDomain: "test", } controller.Pipelines = make(map[string]mockPipeline) controller.PipelineConfigs = make(map[string]v1alpha1.Pipeline) @@ -371,9 +371,9 @@ func TestBasePipelineController_HandlePipelineDeleted(t *testing.T) { Pipelines: map[string]mockPipeline{ "test-pipeline": {name: "test-pipeline"}, }, - Initializer: initializer, - Client: client, - OperatorName: "test", + Initializer: initializer, + Client: client, + SchedulingDomain: "test", } ctx := ctrl.LoggerInto(context.Background(), ctrl.Log) @@ -463,11 +463,11 @@ func TestBasePipelineController_HandleStepCreated(t *testing.T) { initializer := &mockInitializer{} controller := &BasePipelineController[mockPipeline]{ - Pipelines: make(map[string]mockPipeline), - PipelineConfigs: make(map[string]v1alpha1.Pipeline), - Initializer: initializer, - Client: client, - OperatorName: "test", + Pipelines: make(map[string]mockPipeline), + PipelineConfigs: make(map[string]v1alpha1.Pipeline), + Initializer: initializer, + Client: client, + SchedulingDomain: "test", } ctx := ctrl.LoggerInto(context.Background(), ctrl.Log) @@ -549,10 +549,10 @@ func TestBasePipelineController_HandleKnowledgeUpdated(t *testing.T) { initializer := &mockInitializer{} controller := &BasePipelineController[mockPipeline]{ - Pipelines: make(map[string]mockPipeline), - Initializer: initializer, - Client: client, - OperatorName: "test", + Pipelines: make(map[string]mockPipeline), + Initializer: initializer, + Client: client, + SchedulingDomain: "test", } controller.Pipelines = make(map[string]mockPipeline) controller.PipelineConfigs = make(map[string]v1alpha1.Pipeline) @@ -670,9 +670,9 @@ func TestBasePipelineController_HandleKnowledgeDeleted(t *testing.T) { Pipelines: map[string]mockPipeline{ "test-pipeline": {name: "test-pipeline"}, }, - Initializer: initializer, - Client: client, - OperatorName: "test", + Initializer: initializer, + Client: client, + SchedulingDomain: "test", } ctx := ctrl.LoggerInto(context.Background(), ctrl.Log) diff --git a/pkg/conf/conf.go b/pkg/conf/conf.go index 085d2220..e61b2775 100644 --- a/pkg/conf/conf.go +++ b/pkg/conf/conf.go @@ -8,6 +8,7 @@ import ( "io" "os" + "github.com/cobaltcore-dev/cortex/api/v1alpha1" corev1 "k8s.io/api/core/v1" ) @@ -76,8 +77,8 @@ type EndpointsConfig struct { } type Config struct { - // The operator will only touch CRs with this operator name. - Operator string `json:"operator"` + // The controller will only touch resources with this scheduling domain. + SchedulingDomain v1alpha1.SchedulingDomain `json:"schedulingDomain"` // ID used to identify leader election participants. LeaderElectionID string `json:"leaderElectionID,omitempty"` diff --git a/samples/nova-decisions.yaml b/samples/nova-decisions.yaml index 1bac1c75..bc6a4aa0 100644 --- a/samples/nova-decisions.yaml +++ b/samples/nova-decisions.yaml @@ -145,11 +145,10 @@ spec: nova-compute-bb83: 100.61753491786814 nova-compute-bb84: 0.562147416492215 nova-compute-bb97: -147 - operator: cortex-nova + schedulingDomain: nova pipelineRef: name: nova-external-scheduler resourceID: abc12345-6789-0123-4567-89abcdef0123 - type: nova-server status: history: [] precedence: 0