From 67446b671d81b49a9f383654238329db19ff277f Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Mon, 10 Jun 2024 15:24:42 -0400 Subject: [PATCH] Check for Ceilometer and Autoscaling dependencies --- .../v1beta1/openstackcontrolplane_webhook.go | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/apis/core/v1beta1/openstackcontrolplane_webhook.go b/apis/core/v1beta1/openstackcontrolplane_webhook.go index 84a7de45f..7ba0c5053 100644 --- a/apis/core/v1beta1/openstackcontrolplane_webhook.go +++ b/apis/core/v1beta1/openstackcontrolplane_webhook.go @@ -167,6 +167,14 @@ func (r *OpenStackControlPlane) checkDepsEnabled(name string) string { r.Spec.Ovn.Enabled) { reqs = "Galera, Memcached, RabbitMQ, Keystone, Glance, Neutron, Nova, OVN" } + case "Telemetry.Autoscaling": + if !(r.Spec.Galera.Enabled && r.Spec.Heat.Enabled && r.Spec.Rabbitmq.Enabled && r.Spec.Keystone.Enabled) { + reqs = "Galera, Heat, RabbitMQ, Keystone" + } + case "Telemetry.Ceilometer": + if !(r.Spec.Rabbitmq.Enabled && r.Spec.Keystone.Enabled) { + reqs = "RabbitMQ, Keystone" + } } // If "reqs" is not the empty string, we have missing requirements @@ -304,6 +312,20 @@ func (r *OpenStackControlPlane) ValidateServiceDependencies(basePath *field.Path allErrs = append(allErrs, err) } } + if r.Spec.Telemetry.Enabled && r.Spec.Telemetry.Template.Ceilometer.Enabled { + if depErrorMsg := r.checkDepsEnabled("Telemetry.Ceilometer"); depErrorMsg != "" { + err := field.Invalid(basePath.Child("telemetry").Child("template").Child("ceilometer").Child("enabled"), + r.Spec.Telemetry.Template.Ceilometer.Enabled, depErrorMsg) + allErrs = append(allErrs, err) + } + } + if r.Spec.Telemetry.Enabled && r.Spec.Telemetry.Template.Autoscaling.Enabled { + if depErrorMsg := r.checkDepsEnabled("Telemetry.Autoscaling"); depErrorMsg != "" { + err := field.Invalid(basePath.Child("telemetry").Child("template").Child("autoscaling").Child("enabled"), + r.Spec.Telemetry.Template.Autoscaling.Enabled, depErrorMsg) + allErrs = append(allErrs, err) + } + } return allErrs }