From 24072c2987952af896201cda8e8295610775ae4b Mon Sep 17 00:00:00 2001 From: Luca Miccini Date: Tue, 23 Dec 2025 10:29:09 +0100 Subject: [PATCH 1/5] Rabbitmq vhost and user support Add support for a dedicated rabbitmq cluster for notifications. Add new messagingBus and notificationsBus interfaces to hold cluster, user and vhost names for optional usage. The controller adds these values to the TransportURL create request when present. Additionally, we migrate RabbitMQ cluster name to RabbitMq config struct using DefaultRabbitMqConfig from infra-operator to automatically populate the new Cluster field from legacy RabbitMqClusterName. Example usage: spec: messagingBus: cluster: rpc-rabbitmq user: rpc-user vhost: rpc-vhost notificationsBus: cluster: notifications-rabbitmq user: notifications-user vhost: notifications-vhost Jira: https://issues.redhat.com/browse/OSPRH-23909 --- Makefile | 2 +- .../telemetry.openstack.org_autoscalings.yaml | 39 ++++++ .../telemetry.openstack.org_ceilometers.yaml | 38 ++++++ .../telemetry.openstack.org_cloudkitties.yaml | 38 ++++++ .../telemetry.openstack.org_telemetries.yaml | 105 +++++++++++++++ api/go.mod | 9 +- api/go.sum | 15 ++- api/v1beta1/autoscaling_types.go | 13 ++ api/v1beta1/autoscaling_webhook.go | 117 ++++++++++++++++- api/v1beta1/ceilometer_types.go | 13 ++ api/v1beta1/ceilometer_webhook.go | 122 +++++++++++++++++- api/v1beta1/cloudkitty_types.go | 13 ++ api/v1beta1/cloudkitty_webhook.go | 72 ++++++++++- api/v1beta1/telemetry_webhook.go | 50 +++++-- api/v1beta1/telemetry_webhook_test.go | 26 ++++ api/v1beta1/zz_generated.deepcopy.go | 34 +++++ .../telemetry.openstack.org_autoscalings.yaml | 39 ++++++ .../telemetry.openstack.org_ceilometers.yaml | 38 ++++++ .../telemetry.openstack.org_cloudkitties.yaml | 38 ++++++ .../telemetry.openstack.org_telemetries.yaml | 105 +++++++++++++++ go.mod | 16 +-- go.sum | 28 +++- internal/ceilometer/const.go | 16 +++ internal/cloudkitty/const.go | 13 ++ internal/controller/autoscaling_controller.go | 103 ++++++++++++++- internal/controller/ceilometer_controller.go | 113 ++++++++++++++-- internal/controller/cloudkitty_controller.go | 93 ++++++++++++- templates/autoscaling/config/aodh.conf | 8 +- .../ceilometercentral/config/ceilometer.conf | 4 + templates/cloudkitty/config/cloudkitty.conf | 8 ++ 30 files changed, 1257 insertions(+), 71 deletions(-) create mode 100644 api/v1beta1/telemetry_webhook_test.go diff --git a/Makefile b/Makefile index 72153f294..e9f2619f1 100644 --- a/Makefile +++ b/Makefile @@ -116,7 +116,7 @@ tidy: ## Run go mod tidy on every mod file in the repo .PHONY: test test: manifests generate fmt vet envtest ## Run tests. - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... ./api/... -coverprofile cover.out ##@ Build diff --git a/api/bases/telemetry.openstack.org_autoscalings.yaml b/api/bases/telemetry.openstack.org_autoscalings.yaml index 0a4627cfc..ed38e43b2 100644 --- a/api/bases/telemetry.openstack.org_autoscalings.yaml +++ b/api/bases/telemetry.openstack.org_autoscalings.yaml @@ -118,6 +118,23 @@ spec: default: memcached description: Memcached instance name. type: string + messagingBus: + description: MessagingBus configuration (username, vhost, and + cluster) + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object networkAttachmentDefinitions: description: NetworkAttachmentDefinitions list of network attachment definitions the service pod gets attached to @@ -130,6 +147,23 @@ spec: description: NodeSelector to target subset of worker nodes running this service type: object + notificationsBus: + description: NotificationsBus configuration (username, vhost, + and cluster) for notifications + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object notifierImage: type: string override: @@ -323,6 +357,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Aodh + Deprecated: Use MessagingBus.Cluster instead type: string secret: default: osp-secret @@ -510,6 +545,10 @@ spec: items: type: string type: array + notificationsURLSecret: + description: NotificationsURLSecret - Secret containing RabbitMQ notification + transportURL + type: string observedGeneration: description: |- ObservedGeneration - the most recent generation observed for this diff --git a/api/bases/telemetry.openstack.org_ceilometers.yaml b/api/bases/telemetry.openstack.org_ceilometers.yaml index a1bd6e565..0e1626063 100644 --- a/api/bases/telemetry.openstack.org_ceilometers.yaml +++ b/api/bases/telemetry.openstack.org_ceilometers.yaml @@ -167,6 +167,22 @@ spec: description: SecretName - holding the cert, key for the service type: string type: object + messagingBus: + description: MessagingBus configuration (username, vhost, and cluster) + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object mysqldExporterDatabaseAccountPrefix: default: mysqld-exporter description: |- @@ -207,6 +223,23 @@ spec: type: object notificationImage: type: string + notificationsBus: + description: NotificationsBus configuration (username, vhost, and + cluster) for notifications + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object passwordSelector: default: ceilometerService: CeilometerPassword @@ -236,6 +269,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Telemetry + Deprecated: Use MessagingBus.Cluster instead type: string secret: default: osp-secret @@ -381,6 +415,10 @@ spec: items: type: string type: array + notificationsURLSecret: + description: NotificationsURLSecret - Secret containing RabbitMQ notification + transportURL + type: string observedGeneration: description: |- ObservedGeneration - the most recent generation observed for this diff --git a/api/bases/telemetry.openstack.org_cloudkitties.yaml b/api/bases/telemetry.openstack.org_cloudkitties.yaml index 32506979f..e80f309a0 100644 --- a/api/bases/telemetry.openstack.org_cloudkitties.yaml +++ b/api/bases/telemetry.openstack.org_cloudkitties.yaml @@ -558,6 +558,22 @@ spec: default: memcached description: Memcached instance name. type: string + messagingBus: + description: MessagingBus configuration (username, vhost, and cluster) + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object nodeSelector: additionalProperties: type: string @@ -566,6 +582,23 @@ spec: NodeSelector here acts as a default value and can be overridden by service specific NodeSelector Settings. type: object + notificationsBus: + description: NotificationsBus configuration (username, vhost, and + cluster) for notifications + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object passwordSelector: default: cloudKittyService: CloudKittyPassword @@ -637,6 +670,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in CloudKitty + Deprecated: Use MessagingBus.Cluster instead type: string s3StorageConfig: default: @@ -806,6 +840,10 @@ spec: type: string description: Map of hashes to track e.g. job status type: object + notificationsURLSecret: + description: NotificationsURLSecret - Secret containing RabbitMQ notification + transportURL + type: string observedGeneration: description: |- ObservedGeneration - the most recent generation observed for this service. diff --git a/api/bases/telemetry.openstack.org_telemetries.yaml b/api/bases/telemetry.openstack.org_telemetries.yaml index 4817f61d0..d18f99a1a 100644 --- a/api/bases/telemetry.openstack.org_telemetries.yaml +++ b/api/bases/telemetry.openstack.org_telemetries.yaml @@ -121,6 +121,23 @@ spec: default: memcached description: Memcached instance name. type: string + messagingBus: + description: MessagingBus configuration (username, vhost, + and cluster) + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object networkAttachmentDefinitions: description: NetworkAttachmentDefinitions list of network attachment definitions the service pod gets attached to @@ -133,6 +150,23 @@ spec: description: NodeSelector to target subset of worker nodes running this service type: object + notificationsBus: + description: NotificationsBus configuration (username, vhost, + and cluster) for notifications + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object notifierImage: type: string override: @@ -326,6 +360,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Aodh + Deprecated: Use MessagingBus.Cluster instead type: string secret: default: osp-secret @@ -503,6 +538,23 @@ spec: description: SecretName - holding the cert, key for the service type: string type: object + messagingBus: + description: MessagingBus configuration (username, vhost, and + cluster) + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object mysqldExporterDatabaseAccountPrefix: default: mysqld-exporter description: |- @@ -543,6 +595,23 @@ spec: type: object notificationImage: type: string + notificationsBus: + description: NotificationsBus configuration (username, vhost, + and cluster) for notifications + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object passwordSelector: default: ceilometerService: CeilometerPassword @@ -572,6 +641,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Telemetry + Deprecated: Use MessagingBus.Cluster instead type: string secret: default: osp-secret @@ -1142,6 +1212,23 @@ spec: default: memcached description: Memcached instance name. type: string + messagingBus: + description: MessagingBus configuration (username, vhost, and + cluster) + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object nodeSelector: additionalProperties: type: string @@ -1150,6 +1237,23 @@ spec: NodeSelector here acts as a default value and can be overridden by service specific NodeSelector Settings. type: object + notificationsBus: + description: NotificationsBus configuration (username, vhost, + and cluster) for notifications + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object passwordSelector: default: cloudKittyService: CloudKittyPassword @@ -1222,6 +1326,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in CloudKitty + Deprecated: Use MessagingBus.Cluster instead type: string s3StorageConfig: default: diff --git a/api/go.mod b/api/go.mod index 850e3f313..9f3f4d241 100644 --- a/api/go.mod +++ b/api/go.mod @@ -3,8 +3,9 @@ module github.com/openstack-k8s-operators/telemetry-operator/api go 1.24.4 require ( - github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260108154501-11e5091cddf1 - github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251230215914-6ba873b49a35 + github.com/onsi/gomega v1.39.0 + github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260126091827-7758173fbb09 + github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260126081203-efc2df9207eb github.com/rhobs/observability-operator v0.3.1 k8s.io/api v0.31.14 k8s.io/apimachinery v0.31.14 @@ -16,7 +17,6 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/emicklei/go-restful/v3 v3.12.2 // indirect - github.com/evanphx/json-patch v5.9.11+incompatible // indirect github.com/evanphx/json-patch/v5 v5.9.11 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/fxamacker/cbor/v2 v2.9.0 // indirect @@ -38,12 +38,13 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/onsi/gomega v1.39.0 // indirect + github.com/onsi/ginkgo/v2 v2.27.4 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.22.0 // indirect github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/common v0.65.0 // indirect github.com/prometheus/procfs v0.16.1 // indirect + github.com/rabbitmq/cluster-operator/v2 v2.16.0 // indirect github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.71.0-rhobs1 // indirect github.com/spf13/pflag v1.0.7 // indirect github.com/x448/float16 v0.8.4 // indirect diff --git a/api/go.sum b/api/go.sum index 00a3d93b8..82f4d02b7 100644 --- a/api/go.sum +++ b/api/go.sum @@ -1,3 +1,4 @@ +github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -74,14 +75,16 @@ github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFd github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/onsi/ginkgo/v2 v2.27.3 h1:ICsZJ8JoYafeXFFlFAG75a7CxMsJHwgKwtO+82SE9L8= -github.com/onsi/ginkgo/v2 v2.27.3/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo= +github.com/onsi/ginkgo/v2 v2.27.4 h1:fcEcQW/A++6aZAZQNUmNjvA9PSOzefMJBerHJ4t8v8Y= +github.com/onsi/ginkgo/v2 v2.27.4/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo= github.com/onsi/gomega v1.39.0 h1:y2ROC3hKFmQZJNFeGAMeHZKkjBL65mIZcvrLQBF9k6Q= github.com/onsi/gomega v1.39.0/go.mod h1:ZCU1pkQcXDO5Sl9/VVEGlDyp+zm0m1cmeG5TOzLgdh4= -github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260108154501-11e5091cddf1 h1:zAbZVtpldi1TU/CO9aU2ZByzcsi+N3aIv6snpSjBVLY= -github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260108154501-11e5091cddf1/go.mod h1:ZXwFlspJCdZEUjMbmaf61t5AMB4u2vMyAMMoe/vJroE= -github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251230215914-6ba873b49a35 h1:pF3mJ3nwq6r4qwom+rEWZNquZpcQW/iftHlJ1KPIDsk= -github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251230215914-6ba873b49a35/go.mod h1:kycZyoe7OZdW1HUghr2nI3N7wSJtNahXf6b/ypD14f4= +github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260126091827-7758173fbb09 h1:vhAGLKZitJIffj7ONiPpKmOX7Tmt/LGJpaY0Z2LeyfQ= +github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260126091827-7758173fbb09/go.mod h1:ZXwFlspJCdZEUjMbmaf61t5AMB4u2vMyAMMoe/vJroE= +github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260126081203-efc2df9207eb h1:S7tnYO/E1f1KQfcp7N5bam8+ax/ExDTOhZ1WqG4Bfu0= +github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260126081203-efc2df9207eb/go.mod h1:ndqfy1KbVorHH6+zlUFPIrCRhMSxO3ImYJUGaooE0x0= +github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20250929174222-a0d328fa4dec h1:saovr368HPAKHN0aRPh8h8n9s9dn3d8Frmfua0UYRlc= +github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20250929174222-a0d328fa4dec/go.mod h1:Nh2NEePLjovUQof2krTAg4JaAoLacqtPTZQXK6izNfg= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/api/v1beta1/autoscaling_types.go b/api/v1beta1/autoscaling_types.go index 3c21c089b..dda8a84d5 100644 --- a/api/v1beta1/autoscaling_types.go +++ b/api/v1beta1/autoscaling_types.go @@ -17,6 +17,7 @@ limitations under the License. package v1beta1 import ( + rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1" condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" "github.com/openstack-k8s-operators/lib-common/modules/common/tls" @@ -63,8 +64,17 @@ type AodhCore struct { // APITimeout for Route and Apache APITimeout int `json:"apiTimeout"` + // +kubebuilder:validation:Optional + // MessagingBus configuration (username, vhost, and cluster) + MessagingBus rabbitmqv1.RabbitMqConfig `json:"messagingBus,omitempty"` + + // +kubebuilder:validation:Optional + // NotificationsBus configuration (username, vhost, and cluster) for notifications + NotificationsBus *rabbitmqv1.RabbitMqConfig `json:"notificationsBus,omitempty"` + // RabbitMQ instance name // Needed to request a transportURL that is created and used in Aodh + // Deprecated: Use MessagingBus.Cluster instead // +kubebuilder:default=rabbitmq RabbitMqClusterName string `json:"rabbitMqClusterName,omitempty"` @@ -206,6 +216,9 @@ type AutoscalingStatus struct { // TransportURLSecret - Secret containing RabbitMQ transportURL TransportURLSecret string `json:"transportURLSecret,omitempty"` + // NotificationsURLSecret - Secret containing RabbitMQ notification transportURL + NotificationsURLSecret *string `json:"notificationsURLSecret,omitempty"` + // DatabaseHostname - Hostname for the database DatabaseHostname string `json:"databaseHostname,omitempty"` diff --git a/api/v1beta1/autoscaling_webhook.go b/api/v1beta1/autoscaling_webhook.go index 78948dbf7..f00484773 100644 --- a/api/v1beta1/autoscaling_webhook.go +++ b/api/v1beta1/autoscaling_webhook.go @@ -19,10 +19,15 @@ package v1beta1 import ( "fmt" + rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" + apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/validation/field" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + common_webhook "github.com/openstack-k8s-operators/lib-common/modules/common/webhook" ) // AutoscalingDefaults - @@ -73,6 +78,11 @@ func (spec *AutoscalingSpec) Default() { // Default - note only *Core* versions like this will have validations that are called from the // Controlplane webhook func (spec *AodhCore) Default() { + if spec.RabbitMqClusterName == "" { + spec.RabbitMqClusterName = "rabbitmq" + } + rabbitmqv1.DefaultRabbitMqConfig(&spec.MessagingBus, spec.RabbitMqClusterName) + if spec.MemcachedInstance == "" { spec.MemcachedInstance = "memcached" } @@ -80,6 +90,51 @@ func (spec *AodhCore) Default() { // AppCred is opt-in: only used when explicitly configured by the user. } +// getDeprecatedFields returns the centralized list of deprecated fields for AodhCore +func (spec *AodhCore) getDeprecatedFields(old *AodhCore) []common_webhook.DeprecatedFieldUpdate { + deprecatedFields := []common_webhook.DeprecatedFieldUpdate{ + { + DeprecatedFieldName: "rabbitMqClusterName", + NewFieldPath: []string{"messagingBus", "cluster"}, + NewDeprecatedValue: &spec.RabbitMqClusterName, + NewValue: &spec.MessagingBus.Cluster, + }, + } + + // If old spec is provided (UPDATE operation), add old values + if old != nil { + deprecatedFields[0].OldDeprecatedValue = &old.RabbitMqClusterName + } + + return deprecatedFields +} + +// validateDeprecatedFieldsCreate validates deprecated fields during CREATE operations +func (spec *AodhCore) validateDeprecatedFieldsCreate(basePath *field.Path) ([]string, field.ErrorList) { + // Get deprecated fields list (without old values for CREATE) + deprecatedFieldsUpdate := spec.getDeprecatedFields(nil) + + // Convert to DeprecatedField list for CREATE validation + deprecatedFields := make([]common_webhook.DeprecatedField, len(deprecatedFieldsUpdate)) + for i, df := range deprecatedFieldsUpdate { + deprecatedFields[i] = common_webhook.DeprecatedField{ + DeprecatedFieldName: df.DeprecatedFieldName, + NewFieldPath: df.NewFieldPath, + DeprecatedValue: df.NewDeprecatedValue, + NewValue: df.NewValue, + } + } + + return common_webhook.ValidateDeprecatedFieldsCreate(deprecatedFields, basePath), nil +} + +// validateDeprecatedFieldsUpdate validates deprecated fields during UPDATE operations +func (spec *AodhCore) validateDeprecatedFieldsUpdate(old AodhCore, basePath *field.Path) ([]string, field.ErrorList) { + // Get deprecated fields list with old values + deprecatedFields := spec.getDeprecatedFields(&old) + return common_webhook.ValidateDeprecatedFieldsUpdate(deprecatedFields, basePath) +} + // SetDefaultRouteAnnotations sets HAProxy timeout values of the route // NOTE: it is used by ctlplane webhook on openstack-operator func (spec *AutoscalingSpecCore) SetDefaultRouteAnnotations(annotations map[string]string) { @@ -113,7 +168,19 @@ var _ webhook.Validator = &Autoscaling{} func (r *Autoscaling) ValidateCreate() (admission.Warnings, error) { autoscalinglog.Info("validate create", "name", r.Name) - // TODO(user): fill in your validation logic upon object creation. + var allErrs field.ErrorList + basePath := field.NewPath("spec") + + if err := r.Spec.Aodh.ValidateCreate(basePath.Child("aodh"), r.Namespace); err != nil { + allErrs = append(allErrs, err...) + } + + if len(allErrs) != 0 { + return nil, apierrors.NewInvalid( + schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Autoscaling"}, + r.Name, allErrs) + } + return nil, nil } @@ -121,7 +188,24 @@ func (r *Autoscaling) ValidateCreate() (admission.Warnings, error) { func (r *Autoscaling) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { autoscalinglog.Info("validate update", "name", r.Name) - // TODO(user): fill in your validation logic upon object update. + oldAutoscaling, ok := old.(*Autoscaling) + if !ok || oldAutoscaling == nil { + return nil, apierrors.NewInternalError(nil) + } + + var allErrs field.ErrorList + basePath := field.NewPath("spec") + + if err := r.Spec.Aodh.ValidateUpdate(oldAutoscaling.Spec.Aodh.AodhCore, basePath.Child("aodh"), r.Namespace); err != nil { + allErrs = append(allErrs, err...) + } + + if len(allErrs) != 0 { + return nil, apierrors.NewInvalid( + schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Autoscaling"}, + r.Name, allErrs) + } + return nil, nil } @@ -129,6 +213,33 @@ func (r *Autoscaling) ValidateUpdate(old runtime.Object) (admission.Warnings, er func (r *Autoscaling) ValidateDelete() (admission.Warnings, error) { autoscalinglog.Info("validate delete", "name", r.Name) - // TODO(user): fill in your validation logic upon object deletion. return nil, nil } + +// ValidateCreate - Exported function wrapping non-exported validate functions, +// this function can be called externally to validate an aodh spec. +func (spec *AodhCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList { + var allErrs field.ErrorList + + // Validate deprecated fields using shared helper + _, errs := spec.validateDeprecatedFieldsCreate(basePath) + allErrs = append(allErrs, errs...) + + allErrs = append(allErrs, spec.ValidateTopology(basePath, namespace)...) + + return allErrs +} + +// ValidateUpdate - Exported function wrapping non-exported validate functions, +// this function can be called externally to validate an aodh spec. +func (spec *AodhCore) ValidateUpdate(old AodhCore, basePath *field.Path, namespace string) field.ErrorList { + var allErrs field.ErrorList + + // Validate deprecated fields using shared helper + _, errs := spec.validateDeprecatedFieldsUpdate(old, basePath) + allErrs = append(allErrs, errs...) + + allErrs = append(allErrs, spec.ValidateTopology(basePath, namespace)...) + + return allErrs +} diff --git a/api/v1beta1/ceilometer_types.go b/api/v1beta1/ceilometer_types.go index 35530a96e..f4b9e3eb5 100644 --- a/api/v1beta1/ceilometer_types.go +++ b/api/v1beta1/ceilometer_types.go @@ -17,6 +17,7 @@ limitations under the License. package v1beta1 import ( + rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1" condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" "github.com/openstack-k8s-operators/lib-common/modules/common/tls" @@ -81,8 +82,17 @@ type CeilometerSpecCore struct { // APITimeout for Apache APITimeout int `json:"apiTimeout"` + // +kubebuilder:validation:Optional + // MessagingBus configuration (username, vhost, and cluster) + MessagingBus rabbitmqv1.RabbitMqConfig `json:"messagingBus,omitempty"` + + // +kubebuilder:validation:Optional + // NotificationsBus configuration (username, vhost, and cluster) for notifications + NotificationsBus *rabbitmqv1.RabbitMqConfig `json:"notificationsBus,omitempty"` + // RabbitMQ instance name // Needed to request a transportURL that is created and used in Telemetry + // Deprecated: Use MessagingBus.Cluster instead // +kubebuilder:default=rabbitmq RabbitMqClusterName string `json:"rabbitMqClusterName,omitempty"` @@ -182,6 +192,9 @@ type CeilometerStatus struct { // TransportURLSecret - Secret containing RabbitMQ transportURL TransportURLSecret string `json:"transportURLSecret,omitempty"` + // NotificationsURLSecret - Secret containing RabbitMQ notification transportURL + NotificationsURLSecret *string `json:"notificationsURLSecret,omitempty"` + // Networks in addtion to the cluster network, the service is attached to Networks []string `json:"networks,omitempty"` diff --git a/api/v1beta1/ceilometer_webhook.go b/api/v1beta1/ceilometer_webhook.go index 71ec2daf0..5ec142be5 100644 --- a/api/v1beta1/ceilometer_webhook.go +++ b/api/v1beta1/ceilometer_webhook.go @@ -17,10 +17,15 @@ limitations under the License. package v1beta1 import ( + rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" + apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/validation/field" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + common_webhook "github.com/openstack-k8s-operators/lib-common/modules/common/webhook" ) // CeilometerDefaults - @@ -81,6 +86,61 @@ func (spec *CeilometerSpec) Default() { if spec.MysqldExporterImage == "" { spec.MysqldExporterImage = ceilometerDefaults.MysqldExporterContainerImageURL } + + spec.CeilometerSpecCore.Default() +} + +// Default - set defaults for this CeilometerSpecCore. NOTE: this version is used by the OpenStackControlplane webhook +func (spec *CeilometerSpecCore) Default() { + if spec.RabbitMqClusterName == "" { + spec.RabbitMqClusterName = "rabbitmq" + } + rabbitmqv1.DefaultRabbitMqConfig(&spec.MessagingBus, spec.RabbitMqClusterName) +} + +// getDeprecatedFields returns the centralized list of deprecated fields for CeilometerSpecCore +func (spec *CeilometerSpecCore) getDeprecatedFields(old *CeilometerSpecCore) []common_webhook.DeprecatedFieldUpdate { + deprecatedFields := []common_webhook.DeprecatedFieldUpdate{ + { + DeprecatedFieldName: "rabbitMqClusterName", + NewFieldPath: []string{"messagingBus", "cluster"}, + NewDeprecatedValue: &spec.RabbitMqClusterName, + NewValue: &spec.MessagingBus.Cluster, + }, + } + + // If old spec is provided (UPDATE operation), add old values + if old != nil { + deprecatedFields[0].OldDeprecatedValue = &old.RabbitMqClusterName + } + + return deprecatedFields +} + +// validateDeprecatedFieldsCreate validates deprecated fields during CREATE operations +func (spec *CeilometerSpecCore) validateDeprecatedFieldsCreate(basePath *field.Path) ([]string, field.ErrorList) { + // Get deprecated fields list (without old values for CREATE) + deprecatedFieldsUpdate := spec.getDeprecatedFields(nil) + + // Convert to DeprecatedField list for CREATE validation + deprecatedFields := make([]common_webhook.DeprecatedField, len(deprecatedFieldsUpdate)) + for i, df := range deprecatedFieldsUpdate { + deprecatedFields[i] = common_webhook.DeprecatedField{ + DeprecatedFieldName: df.DeprecatedFieldName, + NewFieldPath: df.NewFieldPath, + DeprecatedValue: df.NewDeprecatedValue, + NewValue: df.NewValue, + } + } + + return common_webhook.ValidateDeprecatedFieldsCreate(deprecatedFields, basePath), nil +} + +// validateDeprecatedFieldsUpdate validates deprecated fields during UPDATE operations +func (spec *CeilometerSpecCore) validateDeprecatedFieldsUpdate(old CeilometerSpecCore, basePath *field.Path) ([]string, field.ErrorList) { + // Get deprecated fields list with old values + deprecatedFields := spec.getDeprecatedFields(&old) + return common_webhook.ValidateDeprecatedFieldsUpdate(deprecatedFields, basePath) } func (spec *CeilometerSpecCore) Default() { @@ -94,7 +154,19 @@ var _ webhook.Validator = &Ceilometer{} func (r *Ceilometer) ValidateCreate() (admission.Warnings, error) { ceilometerlog.Info("validate create", "name", r.Name) - // TODO(user): fill in your validation logic upon object creation. + var allErrs field.ErrorList + basePath := field.NewPath("spec") + + if err := r.Spec.CeilometerSpecCore.ValidateCreate(basePath, r.Namespace); err != nil { + allErrs = append(allErrs, err...) + } + + if len(allErrs) != 0 { + return nil, apierrors.NewInvalid( + schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Ceilometer"}, + r.Name, allErrs) + } + return nil, nil } @@ -102,7 +174,24 @@ func (r *Ceilometer) ValidateCreate() (admission.Warnings, error) { func (r *Ceilometer) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { ceilometerlog.Info("validate update", "name", r.Name) - // TODO(user): fill in your validation logic upon object update. + oldCeilometer, ok := old.(*Ceilometer) + if !ok || oldCeilometer == nil { + return nil, apierrors.NewInternalError(nil) + } + + var allErrs field.ErrorList + basePath := field.NewPath("spec") + + if err := r.Spec.CeilometerSpecCore.ValidateUpdate(oldCeilometer.Spec.CeilometerSpecCore, basePath, r.Namespace); err != nil { + allErrs = append(allErrs, err...) + } + + if len(allErrs) != 0 { + return nil, apierrors.NewInvalid( + schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Ceilometer"}, + r.Name, allErrs) + } + return nil, nil } @@ -110,6 +199,33 @@ func (r *Ceilometer) ValidateUpdate(old runtime.Object) (admission.Warnings, err func (r *Ceilometer) ValidateDelete() (admission.Warnings, error) { ceilometerlog.Info("validate delete", "name", r.Name) - // TODO(user): fill in your validation logic upon object deletion. return nil, nil } + +// ValidateCreate - Exported function wrapping non-exported validate functions, +// this function can be called externally to validate a ceilometer spec. +func (spec *CeilometerSpecCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList { + var allErrs field.ErrorList + + // Validate deprecated fields using shared helper + _, errs := spec.validateDeprecatedFieldsCreate(basePath) + allErrs = append(allErrs, errs...) + + allErrs = append(allErrs, spec.ValidateTopology(basePath, namespace)...) + + return allErrs +} + +// ValidateUpdate - Exported function wrapping non-exported validate functions, +// this function can be called externally to validate a ceilometer spec. +func (spec *CeilometerSpecCore) ValidateUpdate(old CeilometerSpecCore, basePath *field.Path, namespace string) field.ErrorList { + var allErrs field.ErrorList + + // Validate deprecated fields using shared helper + _, errs := spec.validateDeprecatedFieldsUpdate(old, basePath) + allErrs = append(allErrs, errs...) + + allErrs = append(allErrs, spec.ValidateTopology(basePath, namespace)...) + + return allErrs +} diff --git a/api/v1beta1/cloudkitty_types.go b/api/v1beta1/cloudkitty_types.go index 431a9266a..3f2e9cd53 100644 --- a/api/v1beta1/cloudkitty_types.go +++ b/api/v1beta1/cloudkitty_types.go @@ -17,6 +17,7 @@ limitations under the License. package v1beta1 import ( + rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1" "github.com/openstack-k8s-operators/lib-common/modules/common/condition" "github.com/openstack-k8s-operators/lib-common/modules/common/util" @@ -133,10 +134,19 @@ type CloudKittySpecBase struct { // Might not be required in future DatabaseInstance string `json:"databaseInstance"` + // +kubebuilder:validation:Optional + // MessagingBus configuration (username, vhost, and cluster) + MessagingBus rabbitmqv1.RabbitMqConfig `json:"messagingBus,omitempty"` + + // +kubebuilder:validation:Optional + // NotificationsBus configuration (username, vhost, and cluster) for notifications + NotificationsBus *rabbitmqv1.RabbitMqConfig `json:"notificationsBus,omitempty"` + // +kubebuilder:validation:Optional // +kubebuilder:default=rabbitmq // RabbitMQ instance name // Needed to request a transportURL that is created and used in CloudKitty + // Deprecated: Use MessagingBus.Cluster instead RabbitMqClusterName string `json:"rabbitMqClusterName"` // +kubebuilder:validation:Optional @@ -319,6 +329,9 @@ type CloudKittyStatus struct { // TransportURLSecret - Secret containing RabbitMQ transportURL TransportURLSecret string `json:"transportURLSecret,omitempty"` + // NotificationsURLSecret - Secret containing RabbitMQ notification transportURL + NotificationsURLSecret *string `json:"notificationsURLSecret,omitempty"` + // API endpoints APIEndpoints map[string]map[string]string `json:"apiEndpoints,omitempty"` diff --git a/api/v1beta1/cloudkitty_webhook.go b/api/v1beta1/cloudkitty_webhook.go index f12914f08..5272f119b 100644 --- a/api/v1beta1/cloudkitty_webhook.go +++ b/api/v1beta1/cloudkitty_webhook.go @@ -20,6 +20,7 @@ import ( "fmt" "slices" + rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -27,6 +28,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + common_webhook "github.com/openstack-k8s-operators/lib-common/modules/common/webhook" ) // CloudKittyDefaults - @@ -63,6 +65,8 @@ func (spec *CloudKittySpec) Default() { if spec.CloudKittyProc.ContainerImage == "" { spec.CloudKittyProc.ContainerImage = cloudKittyDefaults.ProcContainerImageURL } + + spec.CloudKittySpecBase.Default() } // Default - note only *Template* versions like this will have validations that are called from the @@ -72,6 +76,64 @@ func (spec *CloudKittyTemplate) Default() { // AppCred is opt-in: only used when explicitly configured by the user. } +// Default - set defaults for this CloudKittySpecCore. NOTE: this version is used by the OpenStackControlplane webhook +func (spec *CloudKittySpecCore) Default() { + spec.CloudKittySpecBase.Default() +} + +// Default - set defaults for this CloudKittySpecBase +func (spec *CloudKittySpecBase) Default() { + if spec.RabbitMqClusterName == "" { + spec.RabbitMqClusterName = "rabbitmq" + } + rabbitmqv1.DefaultRabbitMqConfig(&spec.MessagingBus, spec.RabbitMqClusterName) +} + +// getDeprecatedFields returns the centralized list of deprecated fields for CloudKittySpecBase +func (spec *CloudKittySpecBase) getDeprecatedFields(old *CloudKittySpecBase) []common_webhook.DeprecatedFieldUpdate { + deprecatedFields := []common_webhook.DeprecatedFieldUpdate{ + { + DeprecatedFieldName: "rabbitMqClusterName", + NewFieldPath: []string{"messagingBus", "cluster"}, + NewDeprecatedValue: &spec.RabbitMqClusterName, + NewValue: &spec.MessagingBus.Cluster, + }, + } + + // If old spec is provided (UPDATE operation), add old values + if old != nil { + deprecatedFields[0].OldDeprecatedValue = &old.RabbitMqClusterName + } + + return deprecatedFields +} + +// validateDeprecatedFieldsCreate validates deprecated fields during CREATE operations +func (spec *CloudKittySpecBase) validateDeprecatedFieldsCreate(basePath *field.Path) ([]string, field.ErrorList) { + // Get deprecated fields list (without old values for CREATE) + deprecatedFieldsUpdate := spec.getDeprecatedFields(nil) + + // Convert to DeprecatedField list for CREATE validation + deprecatedFields := make([]common_webhook.DeprecatedField, len(deprecatedFieldsUpdate)) + for i, df := range deprecatedFieldsUpdate { + deprecatedFields[i] = common_webhook.DeprecatedField{ + DeprecatedFieldName: df.DeprecatedFieldName, + NewFieldPath: df.NewFieldPath, + DeprecatedValue: df.NewDeprecatedValue, + NewValue: df.NewValue, + } + } + + return common_webhook.ValidateDeprecatedFieldsCreate(deprecatedFields, basePath), nil +} + +// validateDeprecatedFieldsUpdate validates deprecated fields during UPDATE operations +func (spec *CloudKittySpecBase) validateDeprecatedFieldsUpdate(old CloudKittySpecBase, basePath *field.Path) ([]string, field.ErrorList) { + // Get deprecated fields list with old values + deprecatedFields := spec.getDeprecatedFields(&old) + return common_webhook.ValidateDeprecatedFieldsUpdate(deprecatedFields, basePath) +} + var _ webhook.Validator = &CloudKitty{} func (r *ObjectStorageSpec) Validate(basePath *field.Path) field.ErrorList { @@ -159,6 +221,10 @@ func (r *CloudKittySpecCore) ValidateCreate(basePath *field.Path, namespace stri func (r *CloudKittySpecBase) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList { var allErrs field.ErrorList + // Validate deprecated fields using shared helper + _, errs := r.validateDeprecatedFieldsCreate(basePath) + allErrs = append(allErrs, errs...) + allErrs = append(allErrs, r.S3StorageConfig.Validate(basePath.Child("s3StorageConfig"))...) // TODO: Add other CK spec field validations as needed @@ -198,10 +264,14 @@ func (r *CloudKittySpecCore) ValidateUpdate(old CloudKittySpecCore, basePath *fi return r.CloudKittySpecBase.ValidateUpdate(old.CloudKittySpecBase, basePath, namespace) } -// ValidateCreate validates the CloudKittySpecBase during the webhook invocation. +// ValidateUpdate validates the CloudKittySpecBase during the webhook invocation. func (r *CloudKittySpecBase) ValidateUpdate(old CloudKittySpecBase, basePath *field.Path, namespace string) field.ErrorList { var allErrs field.ErrorList + // Validate deprecated fields using shared helper + _, errs := r.validateDeprecatedFieldsUpdate(old, basePath) + allErrs = append(allErrs, errs...) + allErrs = append(allErrs, r.S3StorageConfig.Validate(basePath.Child("s3StorageConfig"))...) // TODO: Add other CK spec field validations as needed diff --git a/api/v1beta1/telemetry_webhook.go b/api/v1beta1/telemetry_webhook.go index 2bd919f2d..463730bee 100644 --- a/api/v1beta1/telemetry_webhook.go +++ b/api/v1beta1/telemetry_webhook.go @@ -114,12 +114,20 @@ func (spec *TelemetrySpec) Default() { if spec.CloudKitty.CloudKittyProc.ContainerImage == "" { spec.CloudKitty.CloudKittyProc.ContainerImage = telemetryDefaults.CloudKittyProcContainerImageURL } + + // Call nested Default() methods to set rabbitmq cluster defaults + spec.Autoscaling.AutoscalingSpec.Default() + spec.Autoscaling.Aodh.Default() + spec.Ceilometer.CeilometerSpec.Default() + spec.CloudKitty.CloudKittySpec.Default() } // Default - set defaults for this Telemetry spec core // NOTE: only this version gets called by the Controlplane Webhook func (spec *TelemetrySpecCore) Default() { spec.Autoscaling.Aodh.Default() + spec.Ceilometer.Default() + spec.CloudKitty.Default() } var _ webhook.Validator = &Telemetry{} @@ -127,41 +135,49 @@ var _ webhook.Validator = &Telemetry{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type func (r *Telemetry) ValidateCreate() (admission.Warnings, error) { telemetrylog.Info("validate create", "name", r.Name) + var allWarns []string var allErrs field.ErrorList basePath := field.NewPath("spec") - allErrs = r.Spec.ValidateCreate(basePath, r.Namespace) + warns, errs := r.Spec.ValidateCreate(basePath, r.Namespace) + allWarns = append(allWarns, warns...) + allErrs = append(allErrs, errs...) + if len(allErrs) != 0 { - return nil, apierrors.NewInvalid( + return allWarns, apierrors.NewInvalid( schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Telemetry"}, r.Name, allErrs) } - return nil, nil + return allWarns, nil } -func (r TelemetrySpec) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList { +func (r TelemetrySpec) ValidateCreate(basePath *field.Path, namespace string) ([]string, field.ErrorList) { var allErrs field.ErrorList + var allWarns []string allErrs = append(allErrs, r.ValidateTelemetryTopology(basePath, namespace)...) if r.CloudKitty.Enabled != nil && *r.CloudKitty.Enabled { allErrs = append(allErrs, r.CloudKitty.CloudKittySpec.ValidateCreate(basePath.Child("cloudkitty"), namespace)...) } - return allErrs + return allWarns, allErrs } -func (r TelemetrySpecCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList { +func (r TelemetrySpecCore) ValidateCreate(basePath *field.Path, namespace string) ([]string, field.ErrorList) { var allErrs field.ErrorList + var allWarns []string + allErrs = append(allErrs, r.ValidateTelemetryTopology(basePath, namespace)...) if r.CloudKitty.Enabled != nil && *r.CloudKitty.Enabled { allErrs = append(allErrs, r.CloudKitty.CloudKittySpecCore.ValidateCreate(basePath.Child("cloudkitty"), namespace)...) } - return allErrs + return allWarns, allErrs } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *Telemetry) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { telemetrylog.Info("validate update", "name", r.Name) + var allWarns []string var allErrs field.ErrorList basePath := field.NewPath("spec") @@ -170,33 +186,39 @@ func (r *Telemetry) ValidateUpdate(old runtime.Object) (admission.Warnings, erro return nil, apierrors.NewInternalError(fmt.Errorf("unable to convert existing object")) } - allErrs = r.Spec.ValidateUpdate(oldTelemetry.Spec, basePath, r.Namespace) + warns, errs := r.Spec.ValidateUpdate(oldTelemetry.Spec, basePath, r.Namespace) + allWarns = append(allWarns, warns...) + allErrs = append(allErrs, errs...) + if len(allErrs) != 0 { - return nil, apierrors.NewInvalid( + return allWarns, apierrors.NewInvalid( schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Telemetry"}, r.Name, allErrs) } - return nil, nil + return allWarns, nil } -func (r TelemetrySpec) ValidateUpdate(old TelemetrySpec, basePath *field.Path, namespace string) field.ErrorList { +func (r TelemetrySpec) ValidateUpdate(old TelemetrySpec, basePath *field.Path, namespace string) ([]string, field.ErrorList) { var allErrs field.ErrorList + var allWarns []string allErrs = append(allErrs, r.ValidateTelemetryTopology(basePath, namespace)...) if r.CloudKitty.Enabled != nil && *r.CloudKitty.Enabled { allErrs = append(allErrs, r.CloudKitty.CloudKittySpec.ValidateUpdate(old.CloudKitty.CloudKittySpec, basePath.Child("cloudkitty"), namespace)...) } - return allErrs + return allWarns, allErrs } -func (r TelemetrySpecCore) ValidateUpdate(old TelemetrySpecCore, basePath *field.Path, namespace string) field.ErrorList { +func (r TelemetrySpecCore) ValidateUpdate(old TelemetrySpecCore, basePath *field.Path, namespace string) ([]string, field.ErrorList) { var allErrs field.ErrorList + var allWarns []string + allErrs = append(allErrs, r.ValidateTelemetryTopology(basePath, namespace)...) if r.CloudKitty.Enabled != nil && *r.CloudKitty.Enabled { allErrs = append(allErrs, r.CloudKitty.CloudKittySpecCore.ValidateUpdate(old.CloudKitty.CloudKittySpecCore, basePath.Child("cloudkitty"), namespace)...) } - return allErrs + return allWarns, allErrs } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type diff --git a/api/v1beta1/telemetry_webhook_test.go b/api/v1beta1/telemetry_webhook_test.go new file mode 100644 index 000000000..6f74f6322 --- /dev/null +++ b/api/v1beta1/telemetry_webhook_test.go @@ -0,0 +1,26 @@ +package v1beta1 + +import ( + "testing" + + . "github.com/onsi/gomega" +) + +func TestTelemetrySpecCoreDefault(t *testing.T) { + g := NewWithT(t) + + spec := &TelemetrySpecCore{} + spec.Ceilometer.RabbitMqClusterName = "test-rabbitmq" + spec.CloudKitty.RabbitMqClusterName = "test-cloudkitty-rabbitmq" + + // Call Default() which should migrate rabbitMqClusterName to messagingBus.cluster + spec.Default() + + // Verify Ceilometer got defaulted + g.Expect(spec.Ceilometer.MessagingBus.Cluster).To(Equal("test-rabbitmq"), + "Ceilometer messagingBus.cluster should be defaulted from rabbitMqClusterName") + + // Verify CloudKitty got defaulted + g.Expect(spec.CloudKitty.MessagingBus.Cluster).To(Equal("test-cloudkitty-rabbitmq"), + "CloudKitty messagingBus.cluster should be defaulted from rabbitMqClusterName") +} diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 59312fcd7..1cde1ee44 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -22,6 +22,7 @@ package v1beta1 import ( networkv1beta1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1" + rabbitmqv1beta1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" topologyv1beta1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1" "github.com/openstack-k8s-operators/lib-common/modules/common/condition" "github.com/openstack-k8s-operators/lib-common/modules/common/service" @@ -71,6 +72,12 @@ func (in *Aodh) DeepCopy() *Aodh { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AodhCore) DeepCopyInto(out *AodhCore) { *out = *in + out.MessagingBus = in.MessagingBus + if in.NotificationsBus != nil { + in, out := &in.NotificationsBus, &out.NotificationsBus + *out = new(rabbitmqv1beta1.RabbitMqConfig) + **out = **in + } out.PasswordSelectors = in.PasswordSelectors if in.DefaultConfigOverwrite != nil { in, out := &in.DefaultConfigOverwrite, &out.DefaultConfigOverwrite @@ -322,6 +329,11 @@ func (in *AutoscalingStatus) DeepCopyInto(out *AutoscalingStatus) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.NotificationsURLSecret != nil { + in, out := &in.NotificationsURLSecret, &out.NotificationsURLSecret + *out = new(string) + **out = **in + } if in.APIEndpoints != nil { in, out := &in.APIEndpoints, &out.APIEndpoints *out = make(map[string]string, len(*in)) @@ -497,6 +509,12 @@ func (in *CeilometerSpec) DeepCopy() *CeilometerSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CeilometerSpecCore) DeepCopyInto(out *CeilometerSpecCore) { *out = *in + out.MessagingBus = in.MessagingBus + if in.NotificationsBus != nil { + in, out := &in.NotificationsBus, &out.NotificationsBus + *out = new(rabbitmqv1beta1.RabbitMqConfig) + **out = **in + } out.PasswordSelectors = in.PasswordSelectors if in.DefaultConfigOverwrite != nil { in, out := &in.DefaultConfigOverwrite, &out.DefaultConfigOverwrite @@ -569,6 +587,11 @@ func (in *CeilometerStatus) DeepCopyInto(out *CeilometerStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.NotificationsURLSecret != nil { + in, out := &in.NotificationsURLSecret, &out.NotificationsURLSecret + *out = new(string) + **out = **in + } if in.Networks != nil { in, out := &in.Networks, &out.Networks *out = make([]string, len(*in)) @@ -1144,6 +1167,12 @@ func (in *CloudKittySpec) DeepCopy() *CloudKittySpec { func (in *CloudKittySpecBase) DeepCopyInto(out *CloudKittySpecBase) { *out = *in out.CloudKittyTemplate = in.CloudKittyTemplate + out.MessagingBus = in.MessagingBus + if in.NotificationsBus != nil { + in, out := &in.NotificationsBus, &out.NotificationsBus + *out = new(rabbitmqv1beta1.RabbitMqConfig) + **out = **in + } if in.NodeSelector != nil { in, out := &in.NodeSelector, &out.NodeSelector *out = new(map[string]string) @@ -1213,6 +1242,11 @@ func (in *CloudKittyStatus) DeepCopyInto(out *CloudKittyStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.NotificationsURLSecret != nil { + in, out := &in.NotificationsURLSecret, &out.NotificationsURLSecret + *out = new(string) + **out = **in + } if in.APIEndpoints != nil { in, out := &in.APIEndpoints, &out.APIEndpoints *out = make(map[string]map[string]string, len(*in)) diff --git a/config/crd/bases/telemetry.openstack.org_autoscalings.yaml b/config/crd/bases/telemetry.openstack.org_autoscalings.yaml index 0a4627cfc..ed38e43b2 100644 --- a/config/crd/bases/telemetry.openstack.org_autoscalings.yaml +++ b/config/crd/bases/telemetry.openstack.org_autoscalings.yaml @@ -118,6 +118,23 @@ spec: default: memcached description: Memcached instance name. type: string + messagingBus: + description: MessagingBus configuration (username, vhost, and + cluster) + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object networkAttachmentDefinitions: description: NetworkAttachmentDefinitions list of network attachment definitions the service pod gets attached to @@ -130,6 +147,23 @@ spec: description: NodeSelector to target subset of worker nodes running this service type: object + notificationsBus: + description: NotificationsBus configuration (username, vhost, + and cluster) for notifications + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object notifierImage: type: string override: @@ -323,6 +357,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Aodh + Deprecated: Use MessagingBus.Cluster instead type: string secret: default: osp-secret @@ -510,6 +545,10 @@ spec: items: type: string type: array + notificationsURLSecret: + description: NotificationsURLSecret - Secret containing RabbitMQ notification + transportURL + type: string observedGeneration: description: |- ObservedGeneration - the most recent generation observed for this diff --git a/config/crd/bases/telemetry.openstack.org_ceilometers.yaml b/config/crd/bases/telemetry.openstack.org_ceilometers.yaml index a1bd6e565..0e1626063 100644 --- a/config/crd/bases/telemetry.openstack.org_ceilometers.yaml +++ b/config/crd/bases/telemetry.openstack.org_ceilometers.yaml @@ -167,6 +167,22 @@ spec: description: SecretName - holding the cert, key for the service type: string type: object + messagingBus: + description: MessagingBus configuration (username, vhost, and cluster) + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object mysqldExporterDatabaseAccountPrefix: default: mysqld-exporter description: |- @@ -207,6 +223,23 @@ spec: type: object notificationImage: type: string + notificationsBus: + description: NotificationsBus configuration (username, vhost, and + cluster) for notifications + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object passwordSelector: default: ceilometerService: CeilometerPassword @@ -236,6 +269,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Telemetry + Deprecated: Use MessagingBus.Cluster instead type: string secret: default: osp-secret @@ -381,6 +415,10 @@ spec: items: type: string type: array + notificationsURLSecret: + description: NotificationsURLSecret - Secret containing RabbitMQ notification + transportURL + type: string observedGeneration: description: |- ObservedGeneration - the most recent generation observed for this diff --git a/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml b/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml index 32506979f..e80f309a0 100644 --- a/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml +++ b/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml @@ -558,6 +558,22 @@ spec: default: memcached description: Memcached instance name. type: string + messagingBus: + description: MessagingBus configuration (username, vhost, and cluster) + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object nodeSelector: additionalProperties: type: string @@ -566,6 +582,23 @@ spec: NodeSelector here acts as a default value and can be overridden by service specific NodeSelector Settings. type: object + notificationsBus: + description: NotificationsBus configuration (username, vhost, and + cluster) for notifications + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object passwordSelector: default: cloudKittyService: CloudKittyPassword @@ -637,6 +670,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in CloudKitty + Deprecated: Use MessagingBus.Cluster instead type: string s3StorageConfig: default: @@ -806,6 +840,10 @@ spec: type: string description: Map of hashes to track e.g. job status type: object + notificationsURLSecret: + description: NotificationsURLSecret - Secret containing RabbitMQ notification + transportURL + type: string observedGeneration: description: |- ObservedGeneration - the most recent generation observed for this service. diff --git a/config/crd/bases/telemetry.openstack.org_telemetries.yaml b/config/crd/bases/telemetry.openstack.org_telemetries.yaml index 4817f61d0..d18f99a1a 100644 --- a/config/crd/bases/telemetry.openstack.org_telemetries.yaml +++ b/config/crd/bases/telemetry.openstack.org_telemetries.yaml @@ -121,6 +121,23 @@ spec: default: memcached description: Memcached instance name. type: string + messagingBus: + description: MessagingBus configuration (username, vhost, + and cluster) + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object networkAttachmentDefinitions: description: NetworkAttachmentDefinitions list of network attachment definitions the service pod gets attached to @@ -133,6 +150,23 @@ spec: description: NodeSelector to target subset of worker nodes running this service type: object + notificationsBus: + description: NotificationsBus configuration (username, vhost, + and cluster) for notifications + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object notifierImage: type: string override: @@ -326,6 +360,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Aodh + Deprecated: Use MessagingBus.Cluster instead type: string secret: default: osp-secret @@ -503,6 +538,23 @@ spec: description: SecretName - holding the cert, key for the service type: string type: object + messagingBus: + description: MessagingBus configuration (username, vhost, and + cluster) + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object mysqldExporterDatabaseAccountPrefix: default: mysqld-exporter description: |- @@ -543,6 +595,23 @@ spec: type: object notificationImage: type: string + notificationsBus: + description: NotificationsBus configuration (username, vhost, + and cluster) for notifications + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object passwordSelector: default: ceilometerService: CeilometerPassword @@ -572,6 +641,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Telemetry + Deprecated: Use MessagingBus.Cluster instead type: string secret: default: osp-secret @@ -1142,6 +1212,23 @@ spec: default: memcached description: Memcached instance name. type: string + messagingBus: + description: MessagingBus configuration (username, vhost, and + cluster) + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object nodeSelector: additionalProperties: type: string @@ -1150,6 +1237,23 @@ spec: NodeSelector here acts as a default value and can be overridden by service specific NodeSelector Settings. type: object + notificationsBus: + description: NotificationsBus configuration (username, vhost, + and cluster) for notifications + properties: + cluster: + description: Name of the cluster + minLength: 1 + type: string + user: + description: User - RabbitMQ username + type: string + vhost: + description: Vhost - RabbitMQ vhost name + type: string + required: + - cluster + type: object passwordSelector: default: cloudKittyService: CloudKittyPassword @@ -1222,6 +1326,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in CloudKitty + Deprecated: Use MessagingBus.Cluster instead type: string s3StorageConfig: default: diff --git a/go.mod b/go.mod index a1f1ae984..b81eae477 100644 --- a/go.mod +++ b/go.mod @@ -9,14 +9,14 @@ require ( github.com/go-logr/logr v1.4.3 github.com/grafana/loki/operator/api/loki v0.0.0-20250910094332-a082b8a061ba github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.7.7 - github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20260105161809-cf030b344d79 - github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260108154501-11e5091cddf1 - github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20260120112029-cd452f0497ba - github.com/openstack-k8s-operators/lib-common/modules/ansible v0.6.1-0.20251230215914-6ba873b49a35 - github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.6.1-0.20251230215914-6ba873b49a35 - github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251230215914-6ba873b49a35 - github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20260105160121-f7a8ef85ce8d - github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20260105171105-7cdc83d0bcd1 + github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20260126095359-39e97ca5471e + github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260126091827-7758173fbb09 + github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20260126094240-81b572e8f653 + github.com/openstack-k8s-operators/lib-common/modules/ansible v0.6.1-0.20260126081203-efc2df9207eb + github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.6.1-0.20260126081203-efc2df9207eb + github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260126081203-efc2df9207eb + github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20260124124804-c82210f7a636 + github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20260126095359-1dcdd4734763 github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240529090522-c780bd90b147 github.com/rabbitmq/cluster-operator v1.14.0 github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.71.0-rhobs1 diff --git a/go.sum b/go.sum index cfb31b45c..6d36bc127 100644 --- a/go.sum +++ b/go.sum @@ -105,12 +105,18 @@ github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWu github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +<<<<<<< HEAD github.com/onsi/ginkgo/v2 v2.27.3 h1:ICsZJ8JoYafeXFFlFAG75a7CxMsJHwgKwtO+82SE9L8= github.com/onsi/ginkgo/v2 v2.27.3/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo= +======= +github.com/onsi/ginkgo/v2 v2.27.4 h1:fcEcQW/A++6aZAZQNUmNjvA9PSOzefMJBerHJ4t8v8Y= +github.com/onsi/ginkgo/v2 v2.27.4/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo= +>>>>>>> f2528a7 (Rabbitmq vhost and user support) github.com/onsi/gomega v1.39.0 h1:y2ROC3hKFmQZJNFeGAMeHZKkjBL65mIZcvrLQBF9k6Q= github.com/onsi/gomega v1.39.0/go.mod h1:ZCU1pkQcXDO5Sl9/VVEGlDyp+zm0m1cmeG5TOzLgdh4= github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e h1:E1OdwSpqWuDPCedyUt0GEdoAE+r5TXy7YS21yNEo+2U= github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo= +<<<<<<< HEAD github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20260105161809-cf030b344d79 h1:KxkelBuKUkKWfa37nQsTNcmGvJ7Jfl51LIYHlDeKh3Y= github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20260105161809-cf030b344d79/go.mod h1:LM4ZO7tDrBZQWTQlyUAOSaDEaIRWVtWwcGMFWHYDlFQ= github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260108154501-11e5091cddf1 h1:zAbZVtpldi1TU/CO9aU2ZByzcsi+N3aIv6snpSjBVLY= @@ -123,14 +129,28 @@ github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.6.1-0.20251 github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.6.1-0.20251230215914-6ba873b49a35/go.mod h1:DXZa8jn1R4GNDNBvKJhOFEFjg/6v8TRu9J1AHKj5TJc= github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251230215914-6ba873b49a35 h1:pF3mJ3nwq6r4qwom+rEWZNquZpcQW/iftHlJ1KPIDsk= github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251230215914-6ba873b49a35/go.mod h1:kycZyoe7OZdW1HUghr2nI3N7wSJtNahXf6b/ypD14f4= +======= +github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20260126095359-39e97ca5471e h1:0bCc5n4IBF2vkb7bh+xU+eXHFLYlyrzGBDQYjzwhm0g= +github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20260126095359-39e97ca5471e/go.mod h1:NQxR8xE2FtkWS5rY4cZ0rLGWqme6p7UCg8MCrSiv1C0= +github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260126091827-7758173fbb09 h1:vhAGLKZitJIffj7ONiPpKmOX7Tmt/LGJpaY0Z2LeyfQ= +github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260126091827-7758173fbb09/go.mod h1:ZXwFlspJCdZEUjMbmaf61t5AMB4u2vMyAMMoe/vJroE= +github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20260126094240-81b572e8f653 h1:WZgTxkUrXMquCJbT9ckkHwg0qwEQXR8vZb3NBz6r314= +github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20260126094240-81b572e8f653/go.mod h1:PDOQwlNVjHCygfqUw3k8OY1VcV/Fo6r1Fsjrdm8IhGk= +github.com/openstack-k8s-operators/lib-common/modules/ansible v0.6.1-0.20260126081203-efc2df9207eb h1:35v30c6nI9WtnNnkfh4nRnC/lU9O6rM2Y8onhEAl45g= +github.com/openstack-k8s-operators/lib-common/modules/ansible v0.6.1-0.20260126081203-efc2df9207eb/go.mod h1:tXxVkkk8HlATwTmDA5RTP3b+c8apfuMM15mZ2wW5iNs= +github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.6.1-0.20260126081203-efc2df9207eb h1:pCyizgwvB2tgFGhGtAV5rXV0kSu9l5RoR2XA+Gd5BuY= +github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.6.1-0.20260126081203-efc2df9207eb/go.mod h1:chsg6x4P7376/8MlmsC3OiasuDatbOLwC5D5KRD9fbo= +github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260126081203-efc2df9207eb h1:S7tnYO/E1f1KQfcp7N5bam8+ax/ExDTOhZ1WqG4Bfu0= +github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260126081203-efc2df9207eb/go.mod h1:ndqfy1KbVorHH6+zlUFPIrCRhMSxO3ImYJUGaooE0x0= +>>>>>>> f2528a7 (Rabbitmq vhost and user support) github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20251230215914-6ba873b49a35 h1:IdcI8DFvW8rXtchONSzbDmhhRp1YyO2YaBJDBXr44Gk= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20251230215914-6ba873b49a35/go.mod h1:zOX7Y05keiSppIvLabuyh42QHBMhCcoskAtxFRbwXKo= github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20251230215914-6ba873b49a35 h1:8WZYfCt1VJHa5sJRX0UhpmoXud/fn8LHQhXsakdYXuQ= github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20251230215914-6ba873b49a35/go.mod h1:H0aQANk8iJPRhS2Bg9n6cYb/IHF0Cks9g7+uZG04Rhk= -github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20260105160121-f7a8ef85ce8d h1:cbQpEHW404M+QBrevqh+MyrtPRUFlHTLmSAHflEth6U= -github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20260105160121-f7a8ef85ce8d/go.mod h1:X6W8pIULiWUc6smaTqiNocjxoXaRLgXediwpI/dxD9s= -github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20260105171105-7cdc83d0bcd1 h1:Fya3LwE9d1d4m4J05fJraiq442+7db/KZjY1wvA248c= -github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20260105171105-7cdc83d0bcd1/go.mod h1:LTrCp/cf4HFozb0ZhblhQKO0jUmmBnvD8zFocOsasAM= +github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20260124124804-c82210f7a636 h1:Mtjy0cc2pBdyP44/5K6TB/VxIDvtjU2EHer17JKUaLg= +github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20260124124804-c82210f7a636/go.mod h1:X6W8pIULiWUc6smaTqiNocjxoXaRLgXediwpI/dxD9s= +github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20260126095359-1dcdd4734763 h1:soWH8HSuyp+ltiaeqRwD7ttPJGny/nwDRC6eu6Qt+lE= +github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20260126095359-1dcdd4734763/go.mod h1:ZXb5ElK2MpUScWpwHW/xx5TXkaUA3Ol8oQitslyYso8= github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20250929174222-a0d328fa4dec h1:saovr368HPAKHN0aRPh8h8n9s9dn3d8Frmfua0UYRlc= github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20250929174222-a0d328fa4dec/go.mod h1:Nh2NEePLjovUQof2krTAg4JaAoLacqtPTZQXK6izNfg= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/internal/ceilometer/const.go b/internal/ceilometer/const.go index 68c3d8cf5..598b64ce5 100644 --- a/internal/ceilometer/const.go +++ b/internal/ceilometer/const.go @@ -16,6 +16,10 @@ limitations under the License. // Package ceilometer provides functionality for managing OpenStack Ceilometer telemetry components package ceilometer +import ( + condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" +) + const ( // ServiceName - ServiceName = "ceilometer" @@ -37,4 +41,16 @@ const ( // CeilometerUserID - CeilometerUserID = 42405 + + // CeilometerNotificationBusReadyCondition Status=True condition indicates if the RabbitMQ NotificationsBus TransportURL is configured + CeilometerNotificationBusReadyCondition condition.Type = "CeilometerNotificationBusReady" + + // CeilometerNotificationBusReadyMessage + CeilometerNotificationBusReadyMessage = "NotificationsBus TransportURL successfully created" + + // CeilometerNotificationBusReadyRunningMessage + CeilometerNotificationBusReadyRunningMessage = "NotificationsBus TransportURL creation in progress" + + // CeilometerNotificationBusReadyErrorMessage + CeilometerNotificationBusReadyErrorMessage = "NotificationsBus TransportURL error occured %s" ) diff --git a/internal/cloudkitty/const.go b/internal/cloudkitty/const.go index 7a862dd11..ac19434bc 100644 --- a/internal/cloudkitty/const.go +++ b/internal/cloudkitty/const.go @@ -18,6 +18,7 @@ package cloudkitty import ( "time" + condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" ctrl "sigs.k8s.io/controller-runtime" ) @@ -65,6 +66,18 @@ const ( // CloudKittyUserID - CloudKittyUserID = 42406 + + // CloudKittyNotificationBusReadyCondition Status=True condition indicates if the RabbitMQ NotificationsBus TransportURL is configured + CloudKittyNotificationBusReadyCondition condition.Type = "CloudKittyNotificationBusReady" + + // CloudKittyNotificationBusReadyMessage + CloudKittyNotificationBusReadyMessage = "NotificationsBus TransportURL successfully created" + + // CloudKittyNotificationBusReadyRunningMessage + CloudKittyNotificationBusReadyRunningMessage = "NotificationsBus TransportURL creation in progress" + + // CloudKittyNotificationBusReadyErrorMessage + CloudKittyNotificationBusReadyErrorMessage = "NotificationsBus TransportURL error occured %s" ) // ResultRequeue is a ctrl.Result that requeues after NormalDuration diff --git a/internal/controller/autoscaling_controller.go b/internal/controller/autoscaling_controller.go index 285ac1736..0c1be5ff4 100644 --- a/internal/controller/autoscaling_controller.go +++ b/internal/controller/autoscaling_controller.go @@ -35,6 +35,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" + "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" @@ -327,7 +328,7 @@ func (r *AutoscalingReconciler) reconcileNormal( // // create RabbitMQ transportURL CR and get the actual URL from the associated secret that is created // - transportURL, op, err := r.transportURLCreateOrUpdate(instance) + transportURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, nil) if err != nil { Log.Info("Error getting transportURL. Setting error condition on status and returning") instance.Status.Conditions.Set(condition.FalseCondition( @@ -358,6 +359,50 @@ func (r *AutoscalingReconciler) reconcileNormal( instance.Status.Conditions.MarkTrue(condition.RabbitMqTransportURLReadyCondition, condition.RabbitMqTransportURLReadyMessage) // end transportURL + // + // create NotificationsBus TransportURL if configured + // + if instance.Spec.Aodh.NotificationsBus != nil { + // init .Status.NotificationsURLSecret + instance.Status.NotificationsURLSecret = ptr.To("") + + // Always pass the NotificationsBus config to ensure a separate TransportURL is created, + // even when using the same cluster as messaging (to allow different vhost/user) + notificationBusInstanceURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, instance.Spec.Aodh.NotificationsBus) + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.NotificationBusInstanceReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + condition.NotificationBusInstanceReadyErrorMessage, + err.Error())) + return ctrl.Result{}, err + } + + if op != controllerutil.OperationResultNone { + Log.Info(fmt.Sprintf("NotificationBusInstanceURL %s successfully reconciled - operation: %s", notificationBusInstanceURL.Name, string(op))) + } + + *instance.Status.NotificationsURLSecret = notificationBusInstanceURL.Status.SecretName + + if *instance.Status.NotificationsURLSecret == "" { + Log.Info(fmt.Sprintf("Waiting for NotificationBusInstanceURL %s secret to be created", notificationBusInstanceURL.Name)) + instance.Status.Conditions.Set(condition.FalseCondition( + condition.NotificationBusInstanceReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.NotificationBusInstanceReadyRunningMessage)) + return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil + } + + instance.Status.Conditions.MarkTrue(condition.NotificationBusInstanceReadyCondition, condition.NotificationBusInstanceReadyMessage) + } else { + // make sure we do not have an entry in the status if + // .Spec.Aodh.NotificationsBus is not provided + instance.Status.NotificationsURLSecret = nil + } + // end notificationsBus + configMapVars := make(map[string]env.Setter) // @@ -799,6 +844,16 @@ func (r *AutoscalingReconciler) generateServiceConfig( // Quorum Queues templateParameters["QuorumQueues"] = string(transportURLSecret.Data["quorumqueues"]) == "true" + // Add NotificationsURL if configured + // Always get the separate notification secret since we always create separate TransportURLs + if instance.Status.NotificationsURLSecret != nil { + notificationInstanceURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) + if err != nil { + return err + } + templateParameters["NotificationsURL"] = string(notificationInstanceURLSecret.Data["transport_url"]) + } + cms := []util.Template{ // ScriptsSecret { @@ -865,18 +920,52 @@ func (r *AutoscalingReconciler) getSecret(ctx context.Context, h *helper.Helper, return ctrl.Result{}, nil } -func (r *AutoscalingReconciler) transportURLCreateOrUpdate(instance *telemetryv1.Autoscaling) (*rabbitmqv1.TransportURL, controllerutil.OperationResult, error) { +func (r *AutoscalingReconciler) transportURLCreateOrUpdate( + ctx context.Context, + instance *telemetryv1.Autoscaling, + serviceLabels map[string]string, + rabbitmqConfig *rabbitmqv1.RabbitMqConfig, +) (*rabbitmqv1.TransportURL, controllerutil.OperationResult, error) { + // Default values for regular messagingBus transportURL + rmqName := fmt.Sprintf("%s-transport", autoscaling.ServiceName) + config := &instance.Spec.Aodh.MessagingBus + + // When rabbitmqConfig is passed (notificationsBus use case) + // update the default rmqName and use the provided config + if rabbitmqConfig != nil { + rmqName = fmt.Sprintf("%s-notifications-transport", autoscaling.ServiceName) + config = rabbitmqConfig + } + + // Prepare the spec values before CreateOrUpdate so webhooks see them during CREATE + clusterName := config.Cluster + username := config.User + vhost := config.Vhost + transportURL := &rabbitmqv1.TransportURL{ ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-transport", autoscaling.ServiceName), + Name: rmqName, Namespace: instance.Namespace, + Labels: serviceLabels, + }, + Spec: rabbitmqv1.TransportURLSpec{ + RabbitmqClusterName: clusterName, + Username: username, + Vhost: vhost, }, } - op, err := controllerutil.CreateOrUpdate(context.TODO(), r.Client, transportURL, func() error { - transportURL.Spec.RabbitmqClusterName = instance.Spec.Aodh.RabbitMqClusterName - err := controllerutil.SetControllerReference(instance, transportURL, r.Scheme) - return err + + op, err := controllerutil.CreateOrUpdate(ctx, r.Client, transportURL, func() error { + transportURL.Spec.RabbitmqClusterName = clusterName + // Always set Username and Vhost to allow clearing/resetting them + // The infra-operator TransportURL controller handles empty values: + // - Empty Username: uses default cluster admin credentials + // - Empty Vhost: defaults to "/" vhost + transportURL.Spec.Username = username + transportURL.Spec.Vhost = vhost + return controllerutil.SetControllerReference(instance, transportURL, r.Scheme) }) + return transportURL, op, err } diff --git a/internal/controller/ceilometer_controller.go b/internal/controller/ceilometer_controller.go index 62593cf33..71e6642ca 100644 --- a/internal/controller/ceilometer_controller.go +++ b/internal/controller/ceilometer_controller.go @@ -34,6 +34,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" + "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" @@ -530,10 +531,15 @@ func (r *CeilometerReconciler) reconcileCeilometer( Log := r.GetLogger(ctx) Log.Info(fmt.Sprintf(msgReconcileStart, ceilometer.ServiceName)) + serviceLabels := map[string]string{ + common.AppSelector: ceilometer.ServiceName, + common.OwnerSelector: instance.Name, + } + // // create RabbitMQ transportURL CR and get the actual URL from the associated secret that is created // - transportURL, op, err := r.transportURLCreateOrUpdate(instance) + transportURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, nil) if err != nil { Log.Info("Error getting transportURL. Setting error condition on status and returning") instance.Status.Conditions.Set(condition.FalseCondition( @@ -564,6 +570,50 @@ func (r *CeilometerReconciler) reconcileCeilometer( instance.Status.Conditions.MarkTrue(condition.RabbitMqTransportURLReadyCondition, condition.RabbitMqTransportURLReadyMessage) // end transportURL + // + // create NotificationsBus TransportURL if configured + // + if instance.Spec.NotificationsBus != nil { + // init .Status.NotificationsURLSecret + instance.Status.NotificationsURLSecret = ptr.To("") + + // Always pass the NotificationsBus config to ensure a separate TransportURL is created, + // even when using the same cluster as messaging (to allow different vhost/user) + notificationBusInstanceURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, instance.Spec.NotificationsBus) + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + ceilometer.CeilometerNotificationBusReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + ceilometer.CeilometerNotificationBusReadyErrorMessage, + err.Error())) + return ctrl.Result{}, err + } + + if op != controllerutil.OperationResultNone { + Log.Info(fmt.Sprintf("NotificationBusInstanceURL %s successfully reconciled - operation: %s", notificationBusInstanceURL.Name, string(op))) + } + + *instance.Status.NotificationsURLSecret = notificationBusInstanceURL.Status.SecretName + + if *instance.Status.NotificationsURLSecret == "" { + Log.Info(fmt.Sprintf("Waiting for NotificationBusInstanceURL %s secret to be created", notificationBusInstanceURL.Name)) + instance.Status.Conditions.Set(condition.FalseCondition( + ceilometer.CeilometerNotificationBusReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + ceilometer.CeilometerNotificationBusReadyRunningMessage)) + return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil + } + + instance.Status.Conditions.MarkTrue(ceilometer.CeilometerNotificationBusReadyCondition, ceilometer.CeilometerNotificationBusReadyMessage) + } else { + // make sure we do not have an entry in the status if + // .Spec.NotificationsBus is not provided + instance.Status.NotificationsURLSecret = nil + } + // end notificationsBus + // // check for required OpenStack secret holding passwords for service/admin user and add hash to the vars map // @@ -741,11 +791,6 @@ func (r *CeilometerReconciler) reconcileCeilometer( instance.Status.Conditions.MarkTrue(condition.ServiceConfigReadyCondition, condition.ServiceConfigReadyMessage) - serviceLabels := map[string]string{ - common.AppSelector: ceilometer.ServiceName, - common.OwnerSelector: instance.Name, - } - topology, err := ensureTopology( ctx, helper, @@ -1321,6 +1366,16 @@ func (r *CeilometerReconciler) generateServiceConfig( templateParameters["SwiftRole"] = true } + // Add NotificationsURL if configured + // Always get the separate notification secret since we always create separate TransportURLs + if instance.Status.NotificationsURLSecret != nil { + notificationInstanceURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) + if err != nil { + return err + } + templateParameters["NotificationsURL"] = string(notificationInstanceURLSecret.Data["transport_url"]) + } + cms := []util.Template{ // ScriptsSecrets { @@ -1682,18 +1737,52 @@ func (r *CeilometerReconciler) createHashOfInputHashes( return hash, changed, nil } -func (r *CeilometerReconciler) transportURLCreateOrUpdate(instance *telemetryv1.Ceilometer) (*rabbitmqv1.TransportURL, controllerutil.OperationResult, error) { +func (r *CeilometerReconciler) transportURLCreateOrUpdate( + ctx context.Context, + instance *telemetryv1.Ceilometer, + serviceLabels map[string]string, + rabbitmqConfig *rabbitmqv1.RabbitMqConfig, +) (*rabbitmqv1.TransportURL, controllerutil.OperationResult, error) { + // Default values for regular messagingBus transportURL + rmqName := fmt.Sprintf("%s-transport", ceilometer.ServiceName) + config := &instance.Spec.MessagingBus + + // When rabbitmqConfig is passed (notificationsBus use case) + // update the default rmqName and use the provided config + if rabbitmqConfig != nil { + rmqName = fmt.Sprintf("%s-notifications-transport", ceilometer.ServiceName) + config = rabbitmqConfig + } + + // Prepare the spec values before CreateOrUpdate so webhooks see them during CREATE + clusterName := config.Cluster + username := config.User + vhost := config.Vhost + transportURL := &rabbitmqv1.TransportURL{ ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-transport", ceilometer.ServiceName), + Name: rmqName, Namespace: instance.Namespace, + Labels: serviceLabels, + }, + Spec: rabbitmqv1.TransportURLSpec{ + RabbitmqClusterName: clusterName, + Username: username, + Vhost: vhost, }, } - op, err := controllerutil.CreateOrUpdate(context.TODO(), r.Client, transportURL, func() error { - transportURL.Spec.RabbitmqClusterName = instance.Spec.RabbitMqClusterName - err := controllerutil.SetControllerReference(instance, transportURL, r.Scheme) - return err + + op, err := controllerutil.CreateOrUpdate(ctx, r.Client, transportURL, func() error { + transportURL.Spec.RabbitmqClusterName = clusterName + // Always set Username and Vhost to allow clearing/resetting them + // The infra-operator TransportURL controller handles empty values: + // - Empty Username: uses default cluster admin credentials + // - Empty Vhost: defaults to "/" vhost + transportURL.Spec.Username = username + transportURL.Spec.Vhost = vhost + return controllerutil.SetControllerReference(instance, transportURL, r.Scheme) }) + return transportURL, op, err } diff --git a/internal/controller/cloudkitty_controller.go b/internal/controller/cloudkitty_controller.go index 8514ed250..23dd3e3ca 100644 --- a/internal/controller/cloudkitty_controller.go +++ b/internal/controller/cloudkitty_controller.go @@ -34,6 +34,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" + "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" @@ -856,7 +857,7 @@ func (r *CloudKittyReconciler) reconcileNormal(ctx context.Context, instance *te // create RabbitMQ transportURL CR and get the actual URL from the associated secret that is created // - transportURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels) + transportURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, nil) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( condition.RabbitMqTransportURLReadyCondition, @@ -887,6 +888,50 @@ func (r *CloudKittyReconciler) reconcileNormal(ctx context.Context, instance *te // end transportURL + // + // create NotificationsBus TransportURL if configured + // + if instance.Spec.NotificationsBus != nil { + // init .Status.NotificationsURLSecret + instance.Status.NotificationsURLSecret = ptr.To("") + + // Always pass the NotificationsBus config to ensure a separate TransportURL is created, + // even when using the same cluster as messaging (to allow different vhost/user) + notificationBusInstanceURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, instance.Spec.NotificationsBus) + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + cloudkitty.CloudKittyNotificationBusReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + cloudkitty.CloudKittyNotificationBusReadyErrorMessage, + err.Error())) + return ctrl.Result{}, err + } + + if op != controllerutil.OperationResultNone { + Log.Info(fmt.Sprintf("NotificationBusInstanceURL %s successfully reconciled - operation: %s", notificationBusInstanceURL.Name, string(op))) + } + + *instance.Status.NotificationsURLSecret = notificationBusInstanceURL.Status.SecretName + + if *instance.Status.NotificationsURLSecret == "" { + Log.Info(fmt.Sprintf("Waiting for NotificationBusInstanceURL %s secret to be created", notificationBusInstanceURL.Name)) + instance.Status.Conditions.Set(condition.FalseCondition( + cloudkitty.CloudKittyNotificationBusReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + cloudkitty.CloudKittyNotificationBusReadyRunningMessage)) + return cloudkitty.ResultRequeue, nil + } + + instance.Status.Conditions.MarkTrue(cloudkitty.CloudKittyNotificationBusReadyCondition, cloudkitty.CloudKittyNotificationBusReadyMessage) + } else { + // make sure we do not have an entry in the status if + // .Spec.NotificationsBus is not provided + instance.Status.NotificationsURLSecret = nil + } + // end notificationsBus + // // Check for required memcached used for caching // @@ -1308,6 +1353,16 @@ func (r *CloudKittyReconciler) generateServiceConfigs( templateParameters["PrometheusCAFile"] = tls.DownstreamTLSCABundlePath } + // Add NotificationsURL if configured + // Always get the separate notification secret since we always create separate TransportURLs + if instance.Status.NotificationsURLSecret != nil { + notificationInstanceURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) + if err != nil { + return err + } + templateParameters["NotificationsURL"] = string(notificationInstanceURLSecret.Data["transport_url"]) + } + // create httpd vhost template parameters httpdVhostConfig := map[string]interface{}{} for _, endpt := range []service.Endpoint{service.EndpointInternal, service.EndpointPublic} { @@ -1374,20 +1429,46 @@ func (r *CloudKittyReconciler) transportURLCreateOrUpdate( ctx context.Context, instance *telemetryv1.CloudKitty, serviceLabels map[string]string, + rabbitmqConfig *rabbitmqv1.RabbitMqConfig, ) (*rabbitmqv1.TransportURL, controllerutil.OperationResult, error) { + // Default values for regular messagingBus transportURL + rmqName := fmt.Sprintf("%s-transport", instance.Name) + config := &instance.Spec.MessagingBus + + // When rabbitmqConfig is passed (notificationsBus use case) + // update the default rmqName and use the provided config + if rabbitmqConfig != nil { + rmqName = fmt.Sprintf("%s-notifications-transport", instance.Name) + config = rabbitmqConfig + } + + // Prepare the spec values before CreateOrUpdate so webhooks see them during CREATE + clusterName := config.Cluster + username := config.User + vhost := config.Vhost + transportURL := &rabbitmqv1.TransportURL{ ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-transport", instance.Name), + Name: rmqName, Namespace: instance.Namespace, Labels: serviceLabels, }, + Spec: rabbitmqv1.TransportURLSpec{ + RabbitmqClusterName: clusterName, + Username: username, + Vhost: vhost, + }, } op, err := controllerutil.CreateOrUpdate(ctx, r.Client, transportURL, func() error { - transportURL.Spec.RabbitmqClusterName = instance.Spec.RabbitMqClusterName - - err := controllerutil.SetControllerReference(instance, transportURL, r.Scheme) - return err + transportURL.Spec.RabbitmqClusterName = clusterName + // Always set Username and Vhost to allow clearing/resetting them + // The infra-operator TransportURL controller handles empty values: + // - Empty Username: uses default cluster admin credentials + // - Empty Vhost: defaults to "/" vhost + transportURL.Spec.Username = username + transportURL.Spec.Vhost = vhost + return controllerutil.SetControllerReference(instance, transportURL, r.Scheme) }) return transportURL, op, err diff --git a/templates/autoscaling/config/aodh.conf b/templates/autoscaling/config/aodh.conf index 52631f068..72518b18a 100644 --- a/templates/autoscaling/config/aodh.conf +++ b/templates/autoscaling/config/aodh.conf @@ -25,8 +25,12 @@ enable_proxy_headers_parsing=True policy_file=/etc/aodh/policy.yaml [oslo_messaging_notifications] -driver=noop -transport_url = {{ .TransportURL }} +driver=messagingv2 +{{ if (index . "NotificationsURL") -}} +transport_url={{ .NotificationsURL }} +{{- else -}} +transport_url={{ .TransportURL }} +{{- end }} {{ if (index . "QuorumQueues") }} [oslo_messaging_rabbit] rabbit_quorum_queue=true diff --git a/templates/ceilometercentral/config/ceilometer.conf b/templates/ceilometercentral/config/ceilometer.conf index 035664acd..e883f5fc8 100644 --- a/templates/ceilometercentral/config/ceilometer.conf +++ b/templates/ceilometercentral/config/ceilometer.conf @@ -48,7 +48,11 @@ notify_address_prefix= [oslo_messaging_notifications] driver=messagingv2 topics=notifications +{{ if (index . "NotificationsURL") -}} +transport_url={{ .NotificationsURL }} +{{- else -}} transport_url={{ .TransportURL }} +{{- end }} {{ if (index . "QuorumQueues") }} [oslo_messaging_rabbit] rabbit_quorum_queue=true diff --git a/templates/cloudkitty/config/cloudkitty.conf b/templates/cloudkitty/config/cloudkitty.conf index 76700234d..65644da0b 100644 --- a/templates/cloudkitty/config/cloudkitty.conf +++ b/templates/cloudkitty/config/cloudkitty.conf @@ -7,6 +7,14 @@ debug = True notification_topics = notifications transport_url = {{ .TransportURL }} +[oslo_messaging_notifications] +driver = messagingv2 +{{ if (index . "NotificationsURL") -}} +transport_url = {{ .NotificationsURL }} +{{- else -}} +transport_url = {{ .TransportURL }} +{{- end }} + [authinfos] debug = True {{ if (index . "ACID") }} From 9faac21eede30741060b29ffbfbd62fda9dc3958 Mon Sep 17 00:00:00 2001 From: Luca Miccini Date: Wed, 28 Jan 2026 13:53:51 +0100 Subject: [PATCH 2/5] Model transporturl and config files according to services usage --- .../telemetry.openstack.org_autoscalings.yaml | 19 +--- .../telemetry.openstack.org_ceilometers.yaml | 18 +--- .../telemetry.openstack.org_telemetries.yaml | 38 +------- api/v1beta1/autoscaling_types.go | 6 +- api/v1beta1/autoscaling_webhook.go | 11 ++- api/v1beta1/ceilometer_types.go | 6 +- api/v1beta1/ceilometer_webhook.go | 11 ++- api/v1beta1/cloudkitty_webhook.go | 5 +- api/v1beta1/telemetry_webhook_test.go | 87 ++++++++++++++++- api/v1beta1/zz_generated.deepcopy.go | 2 - .../telemetry.openstack.org_autoscalings.yaml | 19 +--- .../telemetry.openstack.org_ceilometers.yaml | 18 +--- .../telemetry.openstack.org_telemetries.yaml | 38 +------- internal/ceilometer/const.go | 6 +- internal/cloudkitty/const.go | 13 --- internal/controller/autoscaling_controller.go | 90 ++++------------- internal/controller/ceilometer_controller.go | 96 ++++--------------- internal/controller/cloudkitty_controller.go | 58 +---------- templates/autoscaling/config/aodh.conf | 7 +- .../ceilometercentral/config/ceilometer.conf | 7 +- templates/cloudkitty/config/cloudkitty.conf | 11 +-- 21 files changed, 164 insertions(+), 402 deletions(-) diff --git a/api/bases/telemetry.openstack.org_autoscalings.yaml b/api/bases/telemetry.openstack.org_autoscalings.yaml index ed38e43b2..756b3540d 100644 --- a/api/bases/telemetry.openstack.org_autoscalings.yaml +++ b/api/bases/telemetry.openstack.org_autoscalings.yaml @@ -118,23 +118,6 @@ spec: default: memcached description: Memcached instance name. type: string - messagingBus: - description: MessagingBus configuration (username, vhost, and - cluster) - properties: - cluster: - description: Name of the cluster - minLength: 1 - type: string - user: - description: User - RabbitMQ username - type: string - vhost: - description: Vhost - RabbitMQ vhost name - type: string - required: - - cluster - type: object networkAttachmentDefinitions: description: NetworkAttachmentDefinitions list of network attachment definitions the service pod gets attached to @@ -357,7 +340,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Aodh - Deprecated: Use MessagingBus.Cluster instead + Deprecated: Use NotificationsBus.Cluster instead type: string secret: default: osp-secret diff --git a/api/bases/telemetry.openstack.org_ceilometers.yaml b/api/bases/telemetry.openstack.org_ceilometers.yaml index 0e1626063..bd5810823 100644 --- a/api/bases/telemetry.openstack.org_ceilometers.yaml +++ b/api/bases/telemetry.openstack.org_ceilometers.yaml @@ -167,22 +167,6 @@ spec: description: SecretName - holding the cert, key for the service type: string type: object - messagingBus: - description: MessagingBus configuration (username, vhost, and cluster) - properties: - cluster: - description: Name of the cluster - minLength: 1 - type: string - user: - description: User - RabbitMQ username - type: string - vhost: - description: Vhost - RabbitMQ vhost name - type: string - required: - - cluster - type: object mysqldExporterDatabaseAccountPrefix: default: mysqld-exporter description: |- @@ -269,7 +253,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Telemetry - Deprecated: Use MessagingBus.Cluster instead + Deprecated: Use NotificationsBus.Cluster instead type: string secret: default: osp-secret diff --git a/api/bases/telemetry.openstack.org_telemetries.yaml b/api/bases/telemetry.openstack.org_telemetries.yaml index d18f99a1a..94f80a86f 100644 --- a/api/bases/telemetry.openstack.org_telemetries.yaml +++ b/api/bases/telemetry.openstack.org_telemetries.yaml @@ -121,23 +121,6 @@ spec: default: memcached description: Memcached instance name. type: string - messagingBus: - description: MessagingBus configuration (username, vhost, - and cluster) - properties: - cluster: - description: Name of the cluster - minLength: 1 - type: string - user: - description: User - RabbitMQ username - type: string - vhost: - description: Vhost - RabbitMQ vhost name - type: string - required: - - cluster - type: object networkAttachmentDefinitions: description: NetworkAttachmentDefinitions list of network attachment definitions the service pod gets attached to @@ -360,7 +343,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Aodh - Deprecated: Use MessagingBus.Cluster instead + Deprecated: Use NotificationsBus.Cluster instead type: string secret: default: osp-secret @@ -538,23 +521,6 @@ spec: description: SecretName - holding the cert, key for the service type: string type: object - messagingBus: - description: MessagingBus configuration (username, vhost, and - cluster) - properties: - cluster: - description: Name of the cluster - minLength: 1 - type: string - user: - description: User - RabbitMQ username - type: string - vhost: - description: Vhost - RabbitMQ vhost name - type: string - required: - - cluster - type: object mysqldExporterDatabaseAccountPrefix: default: mysqld-exporter description: |- @@ -641,7 +607,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Telemetry - Deprecated: Use MessagingBus.Cluster instead + Deprecated: Use NotificationsBus.Cluster instead type: string secret: default: osp-secret diff --git a/api/v1beta1/autoscaling_types.go b/api/v1beta1/autoscaling_types.go index dda8a84d5..5ee118c17 100644 --- a/api/v1beta1/autoscaling_types.go +++ b/api/v1beta1/autoscaling_types.go @@ -64,17 +64,13 @@ type AodhCore struct { // APITimeout for Route and Apache APITimeout int `json:"apiTimeout"` - // +kubebuilder:validation:Optional - // MessagingBus configuration (username, vhost, and cluster) - MessagingBus rabbitmqv1.RabbitMqConfig `json:"messagingBus,omitempty"` - // +kubebuilder:validation:Optional // NotificationsBus configuration (username, vhost, and cluster) for notifications NotificationsBus *rabbitmqv1.RabbitMqConfig `json:"notificationsBus,omitempty"` // RabbitMQ instance name // Needed to request a transportURL that is created and used in Aodh - // Deprecated: Use MessagingBus.Cluster instead + // Deprecated: Use NotificationsBus.Cluster instead // +kubebuilder:default=rabbitmq RabbitMqClusterName string `json:"rabbitMqClusterName,omitempty"` diff --git a/api/v1beta1/autoscaling_webhook.go b/api/v1beta1/autoscaling_webhook.go index f00484773..49be6e3ca 100644 --- a/api/v1beta1/autoscaling_webhook.go +++ b/api/v1beta1/autoscaling_webhook.go @@ -81,7 +81,12 @@ func (spec *AodhCore) Default() { if spec.RabbitMqClusterName == "" { spec.RabbitMqClusterName = "rabbitmq" } - rabbitmqv1.DefaultRabbitMqConfig(&spec.MessagingBus, spec.RabbitMqClusterName) + + // Aodh only uses Notifications (never RPC), so only default NotificationsBus + if spec.NotificationsBus == nil { + spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{} + } + rabbitmqv1.DefaultRabbitMqConfig(spec.NotificationsBus, spec.RabbitMqClusterName) if spec.MemcachedInstance == "" { spec.MemcachedInstance = "memcached" @@ -95,9 +100,9 @@ func (spec *AodhCore) getDeprecatedFields(old *AodhCore) []common_webhook.Deprec deprecatedFields := []common_webhook.DeprecatedFieldUpdate{ { DeprecatedFieldName: "rabbitMqClusterName", - NewFieldPath: []string{"messagingBus", "cluster"}, + NewFieldPath: []string{"notificationsBus", "cluster"}, NewDeprecatedValue: &spec.RabbitMqClusterName, - NewValue: &spec.MessagingBus.Cluster, + NewValue: &spec.NotificationsBus.Cluster, }, } diff --git a/api/v1beta1/ceilometer_types.go b/api/v1beta1/ceilometer_types.go index f4b9e3eb5..c75c4a85f 100644 --- a/api/v1beta1/ceilometer_types.go +++ b/api/v1beta1/ceilometer_types.go @@ -82,17 +82,13 @@ type CeilometerSpecCore struct { // APITimeout for Apache APITimeout int `json:"apiTimeout"` - // +kubebuilder:validation:Optional - // MessagingBus configuration (username, vhost, and cluster) - MessagingBus rabbitmqv1.RabbitMqConfig `json:"messagingBus,omitempty"` - // +kubebuilder:validation:Optional // NotificationsBus configuration (username, vhost, and cluster) for notifications NotificationsBus *rabbitmqv1.RabbitMqConfig `json:"notificationsBus,omitempty"` // RabbitMQ instance name // Needed to request a transportURL that is created and used in Telemetry - // Deprecated: Use MessagingBus.Cluster instead + // Deprecated: Use NotificationsBus.Cluster instead // +kubebuilder:default=rabbitmq RabbitMqClusterName string `json:"rabbitMqClusterName,omitempty"` diff --git a/api/v1beta1/ceilometer_webhook.go b/api/v1beta1/ceilometer_webhook.go index 5ec142be5..307ec3e97 100644 --- a/api/v1beta1/ceilometer_webhook.go +++ b/api/v1beta1/ceilometer_webhook.go @@ -95,7 +95,12 @@ func (spec *CeilometerSpecCore) Default() { if spec.RabbitMqClusterName == "" { spec.RabbitMqClusterName = "rabbitmq" } - rabbitmqv1.DefaultRabbitMqConfig(&spec.MessagingBus, spec.RabbitMqClusterName) + + // Ceilometer only uses Notifications (never RPC), so only default NotificationsBus + if spec.NotificationsBus == nil { + spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{} + } + rabbitmqv1.DefaultRabbitMqConfig(spec.NotificationsBus, spec.RabbitMqClusterName) } // getDeprecatedFields returns the centralized list of deprecated fields for CeilometerSpecCore @@ -103,9 +108,9 @@ func (spec *CeilometerSpecCore) getDeprecatedFields(old *CeilometerSpecCore) []c deprecatedFields := []common_webhook.DeprecatedFieldUpdate{ { DeprecatedFieldName: "rabbitMqClusterName", - NewFieldPath: []string{"messagingBus", "cluster"}, + NewFieldPath: []string{"notificationsBus", "cluster"}, NewDeprecatedValue: &spec.RabbitMqClusterName, - NewValue: &spec.MessagingBus.Cluster, + NewValue: &spec.NotificationsBus.Cluster, }, } diff --git a/api/v1beta1/cloudkitty_webhook.go b/api/v1beta1/cloudkitty_webhook.go index 5272f119b..e77722747 100644 --- a/api/v1beta1/cloudkitty_webhook.go +++ b/api/v1beta1/cloudkitty_webhook.go @@ -86,7 +86,10 @@ func (spec *CloudKittySpecBase) Default() { if spec.RabbitMqClusterName == "" { spec.RabbitMqClusterName = "rabbitmq" } - rabbitmqv1.DefaultRabbitMqConfig(&spec.MessagingBus, spec.RabbitMqClusterName) + // Only migrate from deprecated field if the new field is not already set + if spec.MessagingBus.Cluster == "" { + rabbitmqv1.DefaultRabbitMqConfig(&spec.MessagingBus, spec.RabbitMqClusterName) + } } // getDeprecatedFields returns the centralized list of deprecated fields for CloudKittySpecBase diff --git a/api/v1beta1/telemetry_webhook_test.go b/api/v1beta1/telemetry_webhook_test.go index 6f74f6322..aa77e32fb 100644 --- a/api/v1beta1/telemetry_webhook_test.go +++ b/api/v1beta1/telemetry_webhook_test.go @@ -4,6 +4,7 @@ import ( "testing" . "github.com/onsi/gomega" + rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" ) func TestTelemetrySpecCoreDefault(t *testing.T) { @@ -13,14 +14,90 @@ func TestTelemetrySpecCoreDefault(t *testing.T) { spec.Ceilometer.RabbitMqClusterName = "test-rabbitmq" spec.CloudKitty.RabbitMqClusterName = "test-cloudkitty-rabbitmq" - // Call Default() which should migrate rabbitMqClusterName to messagingBus.cluster + // Call Default() which should migrate rabbitMqClusterName to the appropriate bus config spec.Default() - // Verify Ceilometer got defaulted - g.Expect(spec.Ceilometer.MessagingBus.Cluster).To(Equal("test-rabbitmq"), - "Ceilometer messagingBus.cluster should be defaulted from rabbitMqClusterName") + // Verify Ceilometer got notificationsBus defaulted (Ceilometer only uses Notifications, not RPC) + g.Expect(spec.Ceilometer.NotificationsBus).ToNot(BeNil(), + "Ceilometer notificationsBus should be initialized") + g.Expect(spec.Ceilometer.NotificationsBus.Cluster).To(Equal("test-rabbitmq"), + "Ceilometer notificationsBus.cluster should be defaulted from rabbitMqClusterName") - // Verify CloudKitty got defaulted + // Verify CloudKitty got messagingBus defaulted (CloudKitty uses RPC, not Notifications) g.Expect(spec.CloudKitty.MessagingBus.Cluster).To(Equal("test-cloudkitty-rabbitmq"), "CloudKitty messagingBus.cluster should be defaulted from rabbitMqClusterName") } + +func TestCeilometerSpecCoreDefault(t *testing.T) { + g := NewWithT(t) + + spec := &CeilometerSpecCore{} + spec.RabbitMqClusterName = "test-rabbitmq" + + // Call Default() + spec.Default() + + // Verify NotificationsBus is defaulted (Ceilometer only uses Notifications) + g.Expect(spec.NotificationsBus).ToNot(BeNil(), + "Ceilometer notificationsBus should be initialized") + g.Expect(spec.NotificationsBus.Cluster).To(Equal("test-rabbitmq"), + "Ceilometer notificationsBus.cluster should be defaulted from rabbitMqClusterName") +} + +func TestCeilometerSpecCoreDefaultWithExistingNotificationsBus(t *testing.T) { + g := NewWithT(t) + + spec := &CeilometerSpecCore{} + spec.RabbitMqClusterName = "test-rabbitmq" + // User explicitly sets notificationsBus + spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{ + Cluster: "custom-notifications-rabbitmq", + User: "custom-user", + Vhost: "custom-vhost", + } + + // Call Default() + spec.Default() + + // Verify NotificationsBus preserves explicit values + g.Expect(spec.NotificationsBus.Cluster).To(Equal("custom-notifications-rabbitmq"), + "Ceilometer notificationsBus.cluster should preserve user-specified value") + g.Expect(spec.NotificationsBus.User).To(Equal("custom-user"), + "Ceilometer notificationsBus.user should preserve user-specified value") + g.Expect(spec.NotificationsBus.Vhost).To(Equal("custom-vhost"), + "Ceilometer notificationsBus.vhost should preserve user-specified value") +} + +func TestAodhCoreDefault(t *testing.T) { + g := NewWithT(t) + + spec := &AodhCore{} + spec.RabbitMqClusterName = "test-rabbitmq" + + // Call Default() + spec.Default() + + // Verify NotificationsBus is defaulted (Aodh only uses Notifications) + g.Expect(spec.NotificationsBus).ToNot(BeNil(), + "Aodh notificationsBus should be initialized") + g.Expect(spec.NotificationsBus.Cluster).To(Equal("test-rabbitmq"), + "Aodh notificationsBus.cluster should be defaulted from rabbitMqClusterName") +} + +func TestCloudKittySpecBaseDefault(t *testing.T) { + g := NewWithT(t) + + spec := &CloudKittySpecBase{} + spec.RabbitMqClusterName = "test-rabbitmq" + + // Call Default() + spec.Default() + + // Verify MessagingBus is defaulted (CloudKitty uses RPC messaging) + g.Expect(spec.MessagingBus.Cluster).To(Equal("test-rabbitmq"), + "CloudKitty messagingBus.cluster should be defaulted from rabbitMqClusterName") + + // Verify NotificationsBus is NOT defaulted (CloudKitty doesn't use notifications) + g.Expect(spec.NotificationsBus).To(BeNil(), + "CloudKitty notificationsBus should not be initialized (not used)") +} diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 1cde1ee44..a73e36208 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -72,7 +72,6 @@ func (in *Aodh) DeepCopy() *Aodh { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AodhCore) DeepCopyInto(out *AodhCore) { *out = *in - out.MessagingBus = in.MessagingBus if in.NotificationsBus != nil { in, out := &in.NotificationsBus, &out.NotificationsBus *out = new(rabbitmqv1beta1.RabbitMqConfig) @@ -509,7 +508,6 @@ func (in *CeilometerSpec) DeepCopy() *CeilometerSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CeilometerSpecCore) DeepCopyInto(out *CeilometerSpecCore) { *out = *in - out.MessagingBus = in.MessagingBus if in.NotificationsBus != nil { in, out := &in.NotificationsBus, &out.NotificationsBus *out = new(rabbitmqv1beta1.RabbitMqConfig) diff --git a/config/crd/bases/telemetry.openstack.org_autoscalings.yaml b/config/crd/bases/telemetry.openstack.org_autoscalings.yaml index ed38e43b2..756b3540d 100644 --- a/config/crd/bases/telemetry.openstack.org_autoscalings.yaml +++ b/config/crd/bases/telemetry.openstack.org_autoscalings.yaml @@ -118,23 +118,6 @@ spec: default: memcached description: Memcached instance name. type: string - messagingBus: - description: MessagingBus configuration (username, vhost, and - cluster) - properties: - cluster: - description: Name of the cluster - minLength: 1 - type: string - user: - description: User - RabbitMQ username - type: string - vhost: - description: Vhost - RabbitMQ vhost name - type: string - required: - - cluster - type: object networkAttachmentDefinitions: description: NetworkAttachmentDefinitions list of network attachment definitions the service pod gets attached to @@ -357,7 +340,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Aodh - Deprecated: Use MessagingBus.Cluster instead + Deprecated: Use NotificationsBus.Cluster instead type: string secret: default: osp-secret diff --git a/config/crd/bases/telemetry.openstack.org_ceilometers.yaml b/config/crd/bases/telemetry.openstack.org_ceilometers.yaml index 0e1626063..bd5810823 100644 --- a/config/crd/bases/telemetry.openstack.org_ceilometers.yaml +++ b/config/crd/bases/telemetry.openstack.org_ceilometers.yaml @@ -167,22 +167,6 @@ spec: description: SecretName - holding the cert, key for the service type: string type: object - messagingBus: - description: MessagingBus configuration (username, vhost, and cluster) - properties: - cluster: - description: Name of the cluster - minLength: 1 - type: string - user: - description: User - RabbitMQ username - type: string - vhost: - description: Vhost - RabbitMQ vhost name - type: string - required: - - cluster - type: object mysqldExporterDatabaseAccountPrefix: default: mysqld-exporter description: |- @@ -269,7 +253,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Telemetry - Deprecated: Use MessagingBus.Cluster instead + Deprecated: Use NotificationsBus.Cluster instead type: string secret: default: osp-secret diff --git a/config/crd/bases/telemetry.openstack.org_telemetries.yaml b/config/crd/bases/telemetry.openstack.org_telemetries.yaml index d18f99a1a..94f80a86f 100644 --- a/config/crd/bases/telemetry.openstack.org_telemetries.yaml +++ b/config/crd/bases/telemetry.openstack.org_telemetries.yaml @@ -121,23 +121,6 @@ spec: default: memcached description: Memcached instance name. type: string - messagingBus: - description: MessagingBus configuration (username, vhost, - and cluster) - properties: - cluster: - description: Name of the cluster - minLength: 1 - type: string - user: - description: User - RabbitMQ username - type: string - vhost: - description: Vhost - RabbitMQ vhost name - type: string - required: - - cluster - type: object networkAttachmentDefinitions: description: NetworkAttachmentDefinitions list of network attachment definitions the service pod gets attached to @@ -360,7 +343,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Aodh - Deprecated: Use MessagingBus.Cluster instead + Deprecated: Use NotificationsBus.Cluster instead type: string secret: default: osp-secret @@ -538,23 +521,6 @@ spec: description: SecretName - holding the cert, key for the service type: string type: object - messagingBus: - description: MessagingBus configuration (username, vhost, and - cluster) - properties: - cluster: - description: Name of the cluster - minLength: 1 - type: string - user: - description: User - RabbitMQ username - type: string - vhost: - description: Vhost - RabbitMQ vhost name - type: string - required: - - cluster - type: object mysqldExporterDatabaseAccountPrefix: default: mysqld-exporter description: |- @@ -641,7 +607,7 @@ spec: description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Telemetry - Deprecated: Use MessagingBus.Cluster instead + Deprecated: Use NotificationsBus.Cluster instead type: string secret: default: osp-secret diff --git a/internal/ceilometer/const.go b/internal/ceilometer/const.go index 598b64ce5..6a86af3bd 100644 --- a/internal/ceilometer/const.go +++ b/internal/ceilometer/const.go @@ -45,12 +45,12 @@ const ( // CeilometerNotificationBusReadyCondition Status=True condition indicates if the RabbitMQ NotificationsBus TransportURL is configured CeilometerNotificationBusReadyCondition condition.Type = "CeilometerNotificationBusReady" - // CeilometerNotificationBusReadyMessage + // CeilometerNotificationBusReadyMessage is the message for CeilometerNotificationBusReady condition CeilometerNotificationBusReadyMessage = "NotificationsBus TransportURL successfully created" - // CeilometerNotificationBusReadyRunningMessage + // CeilometerNotificationBusReadyRunningMessage is the message for CeilometerNotificationBusReady running state CeilometerNotificationBusReadyRunningMessage = "NotificationsBus TransportURL creation in progress" - // CeilometerNotificationBusReadyErrorMessage + // CeilometerNotificationBusReadyErrorMessage is the message for CeilometerNotificationBusReady error state CeilometerNotificationBusReadyErrorMessage = "NotificationsBus TransportURL error occured %s" ) diff --git a/internal/cloudkitty/const.go b/internal/cloudkitty/const.go index ac19434bc..7a862dd11 100644 --- a/internal/cloudkitty/const.go +++ b/internal/cloudkitty/const.go @@ -18,7 +18,6 @@ package cloudkitty import ( "time" - condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" ctrl "sigs.k8s.io/controller-runtime" ) @@ -66,18 +65,6 @@ const ( // CloudKittyUserID - CloudKittyUserID = 42406 - - // CloudKittyNotificationBusReadyCondition Status=True condition indicates if the RabbitMQ NotificationsBus TransportURL is configured - CloudKittyNotificationBusReadyCondition condition.Type = "CloudKittyNotificationBusReady" - - // CloudKittyNotificationBusReadyMessage - CloudKittyNotificationBusReadyMessage = "NotificationsBus TransportURL successfully created" - - // CloudKittyNotificationBusReadyRunningMessage - CloudKittyNotificationBusReadyRunningMessage = "NotificationsBus TransportURL creation in progress" - - // CloudKittyNotificationBusReadyErrorMessage - CloudKittyNotificationBusReadyErrorMessage = "NotificationsBus TransportURL error occured %s" ) // ResultRequeue is a ctrl.Result that requeues after NormalDuration diff --git a/internal/controller/autoscaling_controller.go b/internal/controller/autoscaling_controller.go index 0c1be5ff4..22b7d9b2c 100644 --- a/internal/controller/autoscaling_controller.go +++ b/internal/controller/autoscaling_controller.go @@ -326,81 +326,39 @@ func (r *AutoscalingReconciler) reconcileNormal( } // - // create RabbitMQ transportURL CR and get the actual URL from the associated secret that is created + // create NotificationsBus TransportURL - Aodh only uses Notifications // - transportURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, nil) + // init .Status.NotificationsURLSecret + instance.Status.NotificationsURLSecret = ptr.To("") + + notificationBusInstanceURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, instance.Spec.Aodh.NotificationsBus) if err != nil { - Log.Info("Error getting transportURL. Setting error condition on status and returning") instance.Status.Conditions.Set(condition.FalseCondition( - condition.RabbitMqTransportURLReadyCondition, + condition.NotificationBusInstanceReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.RabbitMqTransportURLReadyErrorMessage, + condition.NotificationBusInstanceReadyErrorMessage, err.Error())) return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - Log.Info(fmt.Sprintf("TransportURL %s successfully reconciled - operation: %s", transportURL.Name, string(op))) + Log.Info(fmt.Sprintf("NotificationBusInstanceURL %s successfully reconciled - operation: %s", notificationBusInstanceURL.Name, string(op))) } - instance.Status.TransportURLSecret = transportURL.Status.SecretName + *instance.Status.NotificationsURLSecret = notificationBusInstanceURL.Status.SecretName - if instance.Status.TransportURLSecret == "" { - Log.Info(fmt.Sprintf("Waiting for TransportURL %s secret to be created", transportURL.Name)) + if *instance.Status.NotificationsURLSecret == "" { + Log.Info(fmt.Sprintf("Waiting for NotificationBusInstanceURL %s secret to be created", notificationBusInstanceURL.Name)) instance.Status.Conditions.Set(condition.FalseCondition( - condition.RabbitMqTransportURLReadyCondition, + condition.NotificationBusInstanceReadyCondition, condition.RequestedReason, condition.SeverityInfo, - condition.RabbitMqTransportURLReadyRunningMessage)) + condition.NotificationBusInstanceReadyRunningMessage)) return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil } - instance.Status.Conditions.MarkTrue(condition.RabbitMqTransportURLReadyCondition, condition.RabbitMqTransportURLReadyMessage) - // end transportURL - - // - // create NotificationsBus TransportURL if configured - // - if instance.Spec.Aodh.NotificationsBus != nil { - // init .Status.NotificationsURLSecret - instance.Status.NotificationsURLSecret = ptr.To("") - - // Always pass the NotificationsBus config to ensure a separate TransportURL is created, - // even when using the same cluster as messaging (to allow different vhost/user) - notificationBusInstanceURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, instance.Spec.Aodh.NotificationsBus) - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.NotificationBusInstanceReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - condition.NotificationBusInstanceReadyErrorMessage, - err.Error())) - return ctrl.Result{}, err - } - - if op != controllerutil.OperationResultNone { - Log.Info(fmt.Sprintf("NotificationBusInstanceURL %s successfully reconciled - operation: %s", notificationBusInstanceURL.Name, string(op))) - } - - *instance.Status.NotificationsURLSecret = notificationBusInstanceURL.Status.SecretName - - if *instance.Status.NotificationsURLSecret == "" { - Log.Info(fmt.Sprintf("Waiting for NotificationBusInstanceURL %s secret to be created", notificationBusInstanceURL.Name)) - instance.Status.Conditions.Set(condition.FalseCondition( - condition.NotificationBusInstanceReadyCondition, - condition.RequestedReason, - condition.SeverityInfo, - condition.NotificationBusInstanceReadyRunningMessage)) - return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil - } - - instance.Status.Conditions.MarkTrue(condition.NotificationBusInstanceReadyCondition, condition.NotificationBusInstanceReadyMessage) - } else { - // make sure we do not have an entry in the status if - // .Spec.Aodh.NotificationsBus is not provided - instance.Status.NotificationsURLSecret = nil - } + instance.Status.Conditions.MarkTrue(condition.NotificationBusInstanceReadyCondition, condition.NotificationBusInstanceReadyMessage) // end notificationsBus configMapVars := make(map[string]env.Setter) @@ -499,9 +457,10 @@ func (r *AutoscalingReconciler) reconcileNormal( // run check heat - end // - // check for required TransportURL secret holding transport URL string + // check for required NotificationsBus TransportURL secret holding transport URL string + // Aodh only uses NotificationsBus, not MessagingBus // - ctrlResult, err = r.getSecret(ctx, helper, instance, instance.Status.TransportURLSecret, "transport_url", &configMapVars) + ctrlResult, err = r.getSecret(ctx, helper, instance, *instance.Status.NotificationsURLSecret, "transport_url", &configMapVars) if err != nil { return ctrlResult, err } @@ -762,7 +721,7 @@ func (r *AutoscalingReconciler) generateServiceConfig( return err } - transportURLSecret, _, err := secret.GetSecret(ctx, h, instance.Status.TransportURLSecret, instance.Namespace) + transportURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) if err != nil { return err } @@ -926,16 +885,9 @@ func (r *AutoscalingReconciler) transportURLCreateOrUpdate( serviceLabels map[string]string, rabbitmqConfig *rabbitmqv1.RabbitMqConfig, ) (*rabbitmqv1.TransportURL, controllerutil.OperationResult, error) { - // Default values for regular messagingBus transportURL - rmqName := fmt.Sprintf("%s-transport", autoscaling.ServiceName) - config := &instance.Spec.Aodh.MessagingBus - - // When rabbitmqConfig is passed (notificationsBus use case) - // update the default rmqName and use the provided config - if rabbitmqConfig != nil { - rmqName = fmt.Sprintf("%s-notifications-transport", autoscaling.ServiceName) - config = rabbitmqConfig - } + // Aodh only uses NotificationsBus TransportURL + rmqName := fmt.Sprintf("%s-notifications-transport", autoscaling.ServiceName) + config := rabbitmqConfig // Prepare the spec values before CreateOrUpdate so webhooks see them during CREATE clusterName := config.Cluster diff --git a/internal/controller/ceilometer_controller.go b/internal/controller/ceilometer_controller.go index 71e6642ca..43cba40d3 100644 --- a/internal/controller/ceilometer_controller.go +++ b/internal/controller/ceilometer_controller.go @@ -537,81 +537,39 @@ func (r *CeilometerReconciler) reconcileCeilometer( } // - // create RabbitMQ transportURL CR and get the actual URL from the associated secret that is created + // create NotificationsBus TransportURL - Ceilometer only uses Notifications // - transportURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, nil) + // init .Status.NotificationsURLSecret + instance.Status.NotificationsURLSecret = ptr.To("") + + notificationBusInstanceURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, instance.Spec.NotificationsBus) if err != nil { - Log.Info("Error getting transportURL. Setting error condition on status and returning") instance.Status.Conditions.Set(condition.FalseCondition( - condition.RabbitMqTransportURLReadyCondition, + ceilometer.CeilometerNotificationBusReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.RabbitMqTransportURLReadyErrorMessage, + ceilometer.CeilometerNotificationBusReadyErrorMessage, err.Error())) return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - Log.Info(fmt.Sprintf("TransportURL %s successfully reconciled - operation: %s", transportURL.Name, string(op))) + Log.Info(fmt.Sprintf("NotificationBusInstanceURL %s successfully reconciled - operation: %s", notificationBusInstanceURL.Name, string(op))) } - instance.Status.TransportURLSecret = transportURL.Status.SecretName + *instance.Status.NotificationsURLSecret = notificationBusInstanceURL.Status.SecretName - if instance.Status.TransportURLSecret == "" { - Log.Info(fmt.Sprintf("Waiting for TransportURL %s secret to be created", transportURL.Name)) + if *instance.Status.NotificationsURLSecret == "" { + Log.Info(fmt.Sprintf("Waiting for NotificationBusInstanceURL %s secret to be created", notificationBusInstanceURL.Name)) instance.Status.Conditions.Set(condition.FalseCondition( - condition.RabbitMqTransportURLReadyCondition, + ceilometer.CeilometerNotificationBusReadyCondition, condition.RequestedReason, condition.SeverityInfo, - condition.RabbitMqTransportURLReadyRunningMessage)) + ceilometer.CeilometerNotificationBusReadyRunningMessage)) return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil } - instance.Status.Conditions.MarkTrue(condition.RabbitMqTransportURLReadyCondition, condition.RabbitMqTransportURLReadyMessage) - // end transportURL - - // - // create NotificationsBus TransportURL if configured - // - if instance.Spec.NotificationsBus != nil { - // init .Status.NotificationsURLSecret - instance.Status.NotificationsURLSecret = ptr.To("") - - // Always pass the NotificationsBus config to ensure a separate TransportURL is created, - // even when using the same cluster as messaging (to allow different vhost/user) - notificationBusInstanceURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, instance.Spec.NotificationsBus) - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - ceilometer.CeilometerNotificationBusReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - ceilometer.CeilometerNotificationBusReadyErrorMessage, - err.Error())) - return ctrl.Result{}, err - } - - if op != controllerutil.OperationResultNone { - Log.Info(fmt.Sprintf("NotificationBusInstanceURL %s successfully reconciled - operation: %s", notificationBusInstanceURL.Name, string(op))) - } - - *instance.Status.NotificationsURLSecret = notificationBusInstanceURL.Status.SecretName - - if *instance.Status.NotificationsURLSecret == "" { - Log.Info(fmt.Sprintf("Waiting for NotificationBusInstanceURL %s secret to be created", notificationBusInstanceURL.Name)) - instance.Status.Conditions.Set(condition.FalseCondition( - ceilometer.CeilometerNotificationBusReadyCondition, - condition.RequestedReason, - condition.SeverityInfo, - ceilometer.CeilometerNotificationBusReadyRunningMessage)) - return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil - } - - instance.Status.Conditions.MarkTrue(ceilometer.CeilometerNotificationBusReadyCondition, ceilometer.CeilometerNotificationBusReadyMessage) - } else { - // make sure we do not have an entry in the status if - // .Spec.NotificationsBus is not provided - instance.Status.NotificationsURLSecret = nil - } + instance.Status.Conditions.MarkTrue(ceilometer.CeilometerNotificationBusReadyCondition, ceilometer.CeilometerNotificationBusReadyMessage) // end notificationsBus // @@ -623,15 +581,6 @@ func (r *CeilometerReconciler) reconcileCeilometer( } // run check OpenStack secret - end - // - // check for required TransportURL secret holding transport URL string - // - ctrlResult, err = r.getSecret(ctx, helper, instance, instance.Status.TransportURLSecret, "transport_url", &configMapVars) - if err != nil { - return ctrlResult, err - } - // run check TransportURL secret - end - // // check for custom configs secret secret holding custom configuration files // @@ -1305,7 +1254,7 @@ func (r *CeilometerReconciler) generateServiceConfig( return err } - transportURLSecret, _, err := secret.GetSecret(ctx, h, instance.Status.TransportURLSecret, instance.Namespace) + transportURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) if err != nil { return err } @@ -1425,7 +1374,7 @@ func (r *CeilometerReconciler) generateComputeServiceConfig( return err } - transportURLSecret, _, err := secret.GetSecret(ctx, h, instance.Status.TransportURLSecret, instance.Namespace) + transportURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) if err != nil { return err } @@ -1743,16 +1692,9 @@ func (r *CeilometerReconciler) transportURLCreateOrUpdate( serviceLabels map[string]string, rabbitmqConfig *rabbitmqv1.RabbitMqConfig, ) (*rabbitmqv1.TransportURL, controllerutil.OperationResult, error) { - // Default values for regular messagingBus transportURL - rmqName := fmt.Sprintf("%s-transport", ceilometer.ServiceName) - config := &instance.Spec.MessagingBus - - // When rabbitmqConfig is passed (notificationsBus use case) - // update the default rmqName and use the provided config - if rabbitmqConfig != nil { - rmqName = fmt.Sprintf("%s-notifications-transport", ceilometer.ServiceName) - config = rabbitmqConfig - } + // Ceilometer only uses NotificationsBus TransportURL + rmqName := fmt.Sprintf("%s-notifications-transport", ceilometer.ServiceName) + config := rabbitmqConfig // Prepare the spec values before CreateOrUpdate so webhooks see them during CREATE clusterName := config.Cluster diff --git a/internal/controller/cloudkitty_controller.go b/internal/controller/cloudkitty_controller.go index 23dd3e3ca..465d4edcb 100644 --- a/internal/controller/cloudkitty_controller.go +++ b/internal/controller/cloudkitty_controller.go @@ -34,7 +34,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" - "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" @@ -885,52 +884,7 @@ func (r *CloudKittyReconciler) reconcileNormal(ctx context.Context, instance *te } instance.Status.Conditions.MarkTrue(condition.RabbitMqTransportURLReadyCondition, condition.RabbitMqTransportURLReadyMessage) - - // end transportURL - - // - // create NotificationsBus TransportURL if configured - // - if instance.Spec.NotificationsBus != nil { - // init .Status.NotificationsURLSecret - instance.Status.NotificationsURLSecret = ptr.To("") - - // Always pass the NotificationsBus config to ensure a separate TransportURL is created, - // even when using the same cluster as messaging (to allow different vhost/user) - notificationBusInstanceURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, instance.Spec.NotificationsBus) - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - cloudkitty.CloudKittyNotificationBusReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - cloudkitty.CloudKittyNotificationBusReadyErrorMessage, - err.Error())) - return ctrl.Result{}, err - } - - if op != controllerutil.OperationResultNone { - Log.Info(fmt.Sprintf("NotificationBusInstanceURL %s successfully reconciled - operation: %s", notificationBusInstanceURL.Name, string(op))) - } - - *instance.Status.NotificationsURLSecret = notificationBusInstanceURL.Status.SecretName - - if *instance.Status.NotificationsURLSecret == "" { - Log.Info(fmt.Sprintf("Waiting for NotificationBusInstanceURL %s secret to be created", notificationBusInstanceURL.Name)) - instance.Status.Conditions.Set(condition.FalseCondition( - cloudkitty.CloudKittyNotificationBusReadyCondition, - condition.RequestedReason, - condition.SeverityInfo, - cloudkitty.CloudKittyNotificationBusReadyRunningMessage)) - return cloudkitty.ResultRequeue, nil - } - - instance.Status.Conditions.MarkTrue(cloudkitty.CloudKittyNotificationBusReadyCondition, cloudkitty.CloudKittyNotificationBusReadyMessage) - } else { - // make sure we do not have an entry in the status if - // .Spec.NotificationsBus is not provided - instance.Status.NotificationsURLSecret = nil - } - // end notificationsBus + // end transportURL - CloudKitty only uses TCP Messaging Bus, not notifications // // Check for required memcached used for caching @@ -1353,16 +1307,6 @@ func (r *CloudKittyReconciler) generateServiceConfigs( templateParameters["PrometheusCAFile"] = tls.DownstreamTLSCABundlePath } - // Add NotificationsURL if configured - // Always get the separate notification secret since we always create separate TransportURLs - if instance.Status.NotificationsURLSecret != nil { - notificationInstanceURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) - if err != nil { - return err - } - templateParameters["NotificationsURL"] = string(notificationInstanceURLSecret.Data["transport_url"]) - } - // create httpd vhost template parameters httpdVhostConfig := map[string]interface{}{} for _, endpt := range []service.Endpoint{service.EndpointInternal, service.EndpointPublic} { diff --git a/templates/autoscaling/config/aodh.conf b/templates/autoscaling/config/aodh.conf index 72518b18a..8c7c0ee07 100644 --- a/templates/autoscaling/config/aodh.conf +++ b/templates/autoscaling/config/aodh.conf @@ -1,6 +1,7 @@ [DEFAULT] debug=True -transport_url = {{ .TransportURL }} +# Aodh only uses Notifications, not RPC messaging +# transport_url = {{ .TransportURL }} [database] alarm_history_time_to_live=86400 @@ -26,11 +27,7 @@ policy_file=/etc/aodh/policy.yaml [oslo_messaging_notifications] driver=messagingv2 -{{ if (index . "NotificationsURL") -}} transport_url={{ .NotificationsURL }} -{{- else -}} -transport_url={{ .TransportURL }} -{{- end }} {{ if (index . "QuorumQueues") }} [oslo_messaging_rabbit] rabbit_quorum_queue=true diff --git a/templates/ceilometercentral/config/ceilometer.conf b/templates/ceilometercentral/config/ceilometer.conf index e883f5fc8..accd4a536 100644 --- a/templates/ceilometercentral/config/ceilometer.conf +++ b/templates/ceilometercentral/config/ceilometer.conf @@ -5,7 +5,8 @@ debug=True log_dir=/var/log/ceilometer rpc_response_timeout=60 polling_namespaces=central -transport_url={{ .TransportURL }} +# Ceilometer only uses Notifications, not RPC messaging +# transport_url={{ .TransportURL }} [service_credentials] {{ if (index . "ACID") }} @@ -48,11 +49,7 @@ notify_address_prefix= [oslo_messaging_notifications] driver=messagingv2 topics=notifications -{{ if (index . "NotificationsURL") -}} transport_url={{ .NotificationsURL }} -{{- else -}} -transport_url={{ .TransportURL }} -{{- end }} {{ if (index . "QuorumQueues") }} [oslo_messaging_rabbit] rabbit_quorum_queue=true diff --git a/templates/cloudkitty/config/cloudkitty.conf b/templates/cloudkitty/config/cloudkitty.conf index 65644da0b..20e755e74 100644 --- a/templates/cloudkitty/config/cloudkitty.conf +++ b/templates/cloudkitty/config/cloudkitty.conf @@ -4,16 +4,13 @@ policy_file = policy.yaml [DEFAULT] auth_strategy = keystone debug = True -notification_topics = notifications +# CloudKitty uses TCP Messaging Bus, not notifications +# notification_topics = notifications transport_url = {{ .TransportURL }} [oslo_messaging_notifications] -driver = messagingv2 -{{ if (index . "NotificationsURL") -}} -transport_url = {{ .NotificationsURL }} -{{- else -}} -transport_url = {{ .TransportURL }} -{{- end }} +# CloudKitty uses the TCP Messaging Bus and never sends Notifications +driver = noop [authinfos] debug = True From 9ad9942b89341150c93f5f26672f3874478a8318 Mon Sep 17 00:00:00 2001 From: Luca Miccini Date: Thu, 29 Jan 2026 03:33:44 +0100 Subject: [PATCH 3/5] Address feedback and fix ptr --- .../telemetry.openstack.org_cloudkitties.yaml | 17 ----------- .../telemetry.openstack.org_telemetries.yaml | 17 ----------- api/v1beta1/cloudkitty_types.go | 4 --- api/v1beta1/telemetry_webhook_test.go | 4 --- api/v1beta1/zz_generated.deepcopy.go | 5 ---- .../telemetry.openstack.org_cloudkitties.yaml | 17 ----------- .../telemetry.openstack.org_telemetries.yaml | 17 ----------- internal/controller/autoscaling_controller.go | 28 +++++++++++++------ internal/controller/ceilometer_controller.go | 20 ++++++++----- internal/controller/cloudkitty_controller.go | 14 ++-------- templates/cloudkitty/config/cloudkitty.conf | 4 +-- 11 files changed, 38 insertions(+), 109 deletions(-) diff --git a/api/bases/telemetry.openstack.org_cloudkitties.yaml b/api/bases/telemetry.openstack.org_cloudkitties.yaml index e80f309a0..40fe06c36 100644 --- a/api/bases/telemetry.openstack.org_cloudkitties.yaml +++ b/api/bases/telemetry.openstack.org_cloudkitties.yaml @@ -582,23 +582,6 @@ spec: NodeSelector here acts as a default value and can be overridden by service specific NodeSelector Settings. type: object - notificationsBus: - description: NotificationsBus configuration (username, vhost, and - cluster) for notifications - properties: - cluster: - description: Name of the cluster - minLength: 1 - type: string - user: - description: User - RabbitMQ username - type: string - vhost: - description: Vhost - RabbitMQ vhost name - type: string - required: - - cluster - type: object passwordSelector: default: cloudKittyService: CloudKittyPassword diff --git a/api/bases/telemetry.openstack.org_telemetries.yaml b/api/bases/telemetry.openstack.org_telemetries.yaml index 94f80a86f..90d5969a0 100644 --- a/api/bases/telemetry.openstack.org_telemetries.yaml +++ b/api/bases/telemetry.openstack.org_telemetries.yaml @@ -1203,23 +1203,6 @@ spec: NodeSelector here acts as a default value and can be overridden by service specific NodeSelector Settings. type: object - notificationsBus: - description: NotificationsBus configuration (username, vhost, - and cluster) for notifications - properties: - cluster: - description: Name of the cluster - minLength: 1 - type: string - user: - description: User - RabbitMQ username - type: string - vhost: - description: Vhost - RabbitMQ vhost name - type: string - required: - - cluster - type: object passwordSelector: default: cloudKittyService: CloudKittyPassword diff --git a/api/v1beta1/cloudkitty_types.go b/api/v1beta1/cloudkitty_types.go index 3f2e9cd53..7c6c18ddc 100644 --- a/api/v1beta1/cloudkitty_types.go +++ b/api/v1beta1/cloudkitty_types.go @@ -138,10 +138,6 @@ type CloudKittySpecBase struct { // MessagingBus configuration (username, vhost, and cluster) MessagingBus rabbitmqv1.RabbitMqConfig `json:"messagingBus,omitempty"` - // +kubebuilder:validation:Optional - // NotificationsBus configuration (username, vhost, and cluster) for notifications - NotificationsBus *rabbitmqv1.RabbitMqConfig `json:"notificationsBus,omitempty"` - // +kubebuilder:validation:Optional // +kubebuilder:default=rabbitmq // RabbitMQ instance name diff --git a/api/v1beta1/telemetry_webhook_test.go b/api/v1beta1/telemetry_webhook_test.go index aa77e32fb..d3d54744e 100644 --- a/api/v1beta1/telemetry_webhook_test.go +++ b/api/v1beta1/telemetry_webhook_test.go @@ -96,8 +96,4 @@ func TestCloudKittySpecBaseDefault(t *testing.T) { // Verify MessagingBus is defaulted (CloudKitty uses RPC messaging) g.Expect(spec.MessagingBus.Cluster).To(Equal("test-rabbitmq"), "CloudKitty messagingBus.cluster should be defaulted from rabbitMqClusterName") - - // Verify NotificationsBus is NOT defaulted (CloudKitty doesn't use notifications) - g.Expect(spec.NotificationsBus).To(BeNil(), - "CloudKitty notificationsBus should not be initialized (not used)") } diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index a73e36208..f6c76af4a 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -1166,11 +1166,6 @@ func (in *CloudKittySpecBase) DeepCopyInto(out *CloudKittySpecBase) { *out = *in out.CloudKittyTemplate = in.CloudKittyTemplate out.MessagingBus = in.MessagingBus - if in.NotificationsBus != nil { - in, out := &in.NotificationsBus, &out.NotificationsBus - *out = new(rabbitmqv1beta1.RabbitMqConfig) - **out = **in - } if in.NodeSelector != nil { in, out := &in.NodeSelector, &out.NodeSelector *out = new(map[string]string) diff --git a/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml b/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml index e80f309a0..40fe06c36 100644 --- a/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml +++ b/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml @@ -582,23 +582,6 @@ spec: NodeSelector here acts as a default value and can be overridden by service specific NodeSelector Settings. type: object - notificationsBus: - description: NotificationsBus configuration (username, vhost, and - cluster) for notifications - properties: - cluster: - description: Name of the cluster - minLength: 1 - type: string - user: - description: User - RabbitMQ username - type: string - vhost: - description: Vhost - RabbitMQ vhost name - type: string - required: - - cluster - type: object passwordSelector: default: cloudKittyService: CloudKittyPassword diff --git a/config/crd/bases/telemetry.openstack.org_telemetries.yaml b/config/crd/bases/telemetry.openstack.org_telemetries.yaml index 94f80a86f..90d5969a0 100644 --- a/config/crd/bases/telemetry.openstack.org_telemetries.yaml +++ b/config/crd/bases/telemetry.openstack.org_telemetries.yaml @@ -1203,23 +1203,6 @@ spec: NodeSelector here acts as a default value and can be overridden by service specific NodeSelector Settings. type: object - notificationsBus: - description: NotificationsBus configuration (username, vhost, - and cluster) for notifications - properties: - cluster: - description: Name of the cluster - minLength: 1 - type: string - user: - description: User - RabbitMQ username - type: string - vhost: - description: Vhost - RabbitMQ vhost name - type: string - required: - - cluster - type: object passwordSelector: default: cloudKittyService: CloudKittyPassword diff --git a/internal/controller/autoscaling_controller.go b/internal/controller/autoscaling_controller.go index 22b7d9b2c..bb1dd8c22 100644 --- a/internal/controller/autoscaling_controller.go +++ b/internal/controller/autoscaling_controller.go @@ -35,7 +35,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" - "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" @@ -186,7 +185,8 @@ func (r *AutoscalingReconciler) Reconcile(ctx context.Context, req ctrl.Request) condition.UnknownCondition(condition.ServiceConfigReadyCondition, condition.InitReason, condition.ServiceConfigReadyInitMessage), condition.UnknownCondition(condition.DBReadyCondition, condition.InitReason, condition.DBReadyInitMessage), condition.UnknownCondition(condition.DBSyncReadyCondition, condition.InitReason, condition.DBSyncReadyInitMessage), - condition.UnknownCondition(condition.RabbitMqTransportURLReadyCondition, condition.InitReason, condition.RabbitMqTransportURLReadyInitMessage), + // Note: Aodh only uses NotificationsBus (no MessagingBus/RPC), so RabbitMqTransportURLReady is not needed + // NotificationBusInstanceReadyCondition handles the NotificationsBus TransportURL condition.UnknownCondition(condition.DeploymentReadyCondition, condition.InitReason, condition.DeploymentReadyInitMessage), // right now we have no dedicated KeystoneServiceReadyInitMessage condition.UnknownCondition(condition.KeystoneServiceReadyCondition, condition.InitReason, ""), @@ -328,9 +328,6 @@ func (r *AutoscalingReconciler) reconcileNormal( // // create NotificationsBus TransportURL - Aodh only uses Notifications // - // init .Status.NotificationsURLSecret - instance.Status.NotificationsURLSecret = ptr.To("") - notificationBusInstanceURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, instance.Spec.Aodh.NotificationsBus) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( @@ -346,9 +343,9 @@ func (r *AutoscalingReconciler) reconcileNormal( Log.Info(fmt.Sprintf("NotificationBusInstanceURL %s successfully reconciled - operation: %s", notificationBusInstanceURL.Name, string(op))) } - *instance.Status.NotificationsURLSecret = notificationBusInstanceURL.Status.SecretName + instance.Status.NotificationsURLSecret = ¬ificationBusInstanceURL.Status.SecretName - if *instance.Status.NotificationsURLSecret == "" { + if instance.Status.NotificationsURLSecret == nil || *instance.Status.NotificationsURLSecret == "" { Log.Info(fmt.Sprintf("Waiting for NotificationBusInstanceURL %s secret to be created", notificationBusInstanceURL.Name)) instance.Status.Conditions.Set(condition.FalseCondition( condition.NotificationBusInstanceReadyCondition, @@ -460,6 +457,16 @@ func (r *AutoscalingReconciler) reconcileNormal( // check for required NotificationsBus TransportURL secret holding transport URL string // Aodh only uses NotificationsBus, not MessagingBus // + if instance.Status.NotificationsURLSecret == nil || *instance.Status.NotificationsURLSecret == "" { + Log.Info("NotificationsURLSecret not yet available") + instance.Status.Conditions.Set(condition.FalseCondition( + condition.NotificationBusInstanceReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.NotificationBusInstanceReadyRunningMessage)) + return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil + } + ctrlResult, err = r.getSecret(ctx, helper, instance, *instance.Status.NotificationsURLSecret, "transport_url", &configMapVars) if err != nil { return ctrlResult, err @@ -721,6 +728,11 @@ func (r *AutoscalingReconciler) generateServiceConfig( return err } + // Ensure NotificationsURLSecret is not nil before dereferencing + if instance.Status.NotificationsURLSecret == nil { + return fmt.Errorf("NotificationsURLSecret is not set") + } + transportURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) if err != nil { return err @@ -805,7 +817,7 @@ func (r *AutoscalingReconciler) generateServiceConfig( // Add NotificationsURL if configured // Always get the separate notification secret since we always create separate TransportURLs - if instance.Status.NotificationsURLSecret != nil { + if instance.Status.NotificationsURLSecret != nil && *instance.Status.NotificationsURLSecret != "" { notificationInstanceURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) if err != nil { return err diff --git a/internal/controller/ceilometer_controller.go b/internal/controller/ceilometer_controller.go index 43cba40d3..e5842e19c 100644 --- a/internal/controller/ceilometer_controller.go +++ b/internal/controller/ceilometer_controller.go @@ -34,7 +34,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" - "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" @@ -539,9 +538,6 @@ func (r *CeilometerReconciler) reconcileCeilometer( // // create NotificationsBus TransportURL - Ceilometer only uses Notifications // - // init .Status.NotificationsURLSecret - instance.Status.NotificationsURLSecret = ptr.To("") - notificationBusInstanceURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, instance.Spec.NotificationsBus) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( @@ -557,9 +553,9 @@ func (r *CeilometerReconciler) reconcileCeilometer( Log.Info(fmt.Sprintf("NotificationBusInstanceURL %s successfully reconciled - operation: %s", notificationBusInstanceURL.Name, string(op))) } - *instance.Status.NotificationsURLSecret = notificationBusInstanceURL.Status.SecretName + instance.Status.NotificationsURLSecret = ¬ificationBusInstanceURL.Status.SecretName - if *instance.Status.NotificationsURLSecret == "" { + if instance.Status.NotificationsURLSecret == nil || *instance.Status.NotificationsURLSecret == "" { Log.Info(fmt.Sprintf("Waiting for NotificationBusInstanceURL %s secret to be created", notificationBusInstanceURL.Name)) instance.Status.Conditions.Set(condition.FalseCondition( ceilometer.CeilometerNotificationBusReadyCondition, @@ -1254,6 +1250,11 @@ func (r *CeilometerReconciler) generateServiceConfig( return err } + // Ensure NotificationsURLSecret is not nil before dereferencing + if instance.Status.NotificationsURLSecret == nil { + return fmt.Errorf("NotificationsURLSecret is not set") + } + transportURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) if err != nil { return err @@ -1317,7 +1318,7 @@ func (r *CeilometerReconciler) generateServiceConfig( // Add NotificationsURL if configured // Always get the separate notification secret since we always create separate TransportURLs - if instance.Status.NotificationsURLSecret != nil { + if instance.Status.NotificationsURLSecret != nil && *instance.Status.NotificationsURLSecret != "" { notificationInstanceURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) if err != nil { return err @@ -1374,6 +1375,11 @@ func (r *CeilometerReconciler) generateComputeServiceConfig( return err } + // Ensure NotificationsURLSecret is not nil before dereferencing + if instance.Status.NotificationsURLSecret == nil { + return fmt.Errorf("NotificationsURLSecret is not set") + } + transportURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) if err != nil { return err diff --git a/internal/controller/cloudkitty_controller.go b/internal/controller/cloudkitty_controller.go index 465d4edcb..8f183da22 100644 --- a/internal/controller/cloudkitty_controller.go +++ b/internal/controller/cloudkitty_controller.go @@ -856,7 +856,7 @@ func (r *CloudKittyReconciler) reconcileNormal(ctx context.Context, instance *te // create RabbitMQ transportURL CR and get the actual URL from the associated secret that is created // - transportURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, nil) + transportURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( condition.RabbitMqTransportURLReadyCondition, @@ -884,7 +884,7 @@ func (r *CloudKittyReconciler) reconcileNormal(ctx context.Context, instance *te } instance.Status.Conditions.MarkTrue(condition.RabbitMqTransportURLReadyCondition, condition.RabbitMqTransportURLReadyMessage) - // end transportURL - CloudKitty only uses TCP Messaging Bus, not notifications + // end transportURL - CloudKitty only uses RPC Messaging Bus, not notifications // // Check for required memcached used for caching @@ -1373,19 +1373,11 @@ func (r *CloudKittyReconciler) transportURLCreateOrUpdate( ctx context.Context, instance *telemetryv1.CloudKitty, serviceLabels map[string]string, - rabbitmqConfig *rabbitmqv1.RabbitMqConfig, ) (*rabbitmqv1.TransportURL, controllerutil.OperationResult, error) { - // Default values for regular messagingBus transportURL + // CloudKitty only uses messagingBus for RPC communication, not notifications rmqName := fmt.Sprintf("%s-transport", instance.Name) config := &instance.Spec.MessagingBus - // When rabbitmqConfig is passed (notificationsBus use case) - // update the default rmqName and use the provided config - if rabbitmqConfig != nil { - rmqName = fmt.Sprintf("%s-notifications-transport", instance.Name) - config = rabbitmqConfig - } - // Prepare the spec values before CreateOrUpdate so webhooks see them during CREATE clusterName := config.Cluster username := config.User diff --git a/templates/cloudkitty/config/cloudkitty.conf b/templates/cloudkitty/config/cloudkitty.conf index 20e755e74..8a68bd1d6 100644 --- a/templates/cloudkitty/config/cloudkitty.conf +++ b/templates/cloudkitty/config/cloudkitty.conf @@ -4,12 +4,12 @@ policy_file = policy.yaml [DEFAULT] auth_strategy = keystone debug = True -# CloudKitty uses TCP Messaging Bus, not notifications +# CloudKitty uses RPC Messaging Bus, not notifications # notification_topics = notifications transport_url = {{ .TransportURL }} [oslo_messaging_notifications] -# CloudKitty uses the TCP Messaging Bus and never sends Notifications +# CloudKitty uses the RPC Messaging Bus and never sends Notifications driver = noop [authinfos] From 11f9bbdaec6c14833039a9407fe1530420bdba4d Mon Sep 17 00:00:00 2001 From: Luca Miccini Date: Thu, 29 Jan 2026 11:52:44 +0100 Subject: [PATCH 4/5] Make deprecated parameter optional --- .../telemetry.openstack.org_ceilometers.yaml | 1 - .../telemetry.openstack.org_cloudkitties.yaml | 1 - .../telemetry.openstack.org_telemetries.yaml | 2 - api/v1beta1/autoscaling_webhook.go | 15 ++---- api/v1beta1/ceilometer_types.go | 2 +- api/v1beta1/ceilometer_webhook.go | 13 ++--- api/v1beta1/cloudkitty_types.go | 3 +- api/v1beta1/cloudkitty_webhook.go | 9 ++-- api/v1beta1/telemetry_webhook_test.go | 54 +++++++++---------- .../telemetry.openstack.org_ceilometers.yaml | 1 - .../telemetry.openstack.org_cloudkitties.yaml | 1 - .../telemetry.openstack.org_telemetries.yaml | 2 - internal/controller/ceilometer_controller.go | 7 +++ test/kuttl/tests/cloudkitty/02-deploy.yaml | 3 +- .../cloudkitty/03-custom-config-secret.yaml | 3 +- 15 files changed, 50 insertions(+), 67 deletions(-) diff --git a/api/bases/telemetry.openstack.org_ceilometers.yaml b/api/bases/telemetry.openstack.org_ceilometers.yaml index bd5810823..9cdc781e4 100644 --- a/api/bases/telemetry.openstack.org_ceilometers.yaml +++ b/api/bases/telemetry.openstack.org_ceilometers.yaml @@ -249,7 +249,6 @@ spec: proxyImage: type: string rabbitMqClusterName: - default: rabbitmq description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Telemetry diff --git a/api/bases/telemetry.openstack.org_cloudkitties.yaml b/api/bases/telemetry.openstack.org_cloudkitties.yaml index 40fe06c36..0e74745d2 100644 --- a/api/bases/telemetry.openstack.org_cloudkitties.yaml +++ b/api/bases/telemetry.openstack.org_cloudkitties.yaml @@ -649,7 +649,6 @@ spec: type: object x-kubernetes-map-type: atomic rabbitMqClusterName: - default: rabbitmq description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in CloudKitty diff --git a/api/bases/telemetry.openstack.org_telemetries.yaml b/api/bases/telemetry.openstack.org_telemetries.yaml index 90d5969a0..e5e82ab9e 100644 --- a/api/bases/telemetry.openstack.org_telemetries.yaml +++ b/api/bases/telemetry.openstack.org_telemetries.yaml @@ -603,7 +603,6 @@ spec: proxyImage: type: string rabbitMqClusterName: - default: rabbitmq description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Telemetry @@ -1271,7 +1270,6 @@ spec: type: object x-kubernetes-map-type: atomic rabbitMqClusterName: - default: rabbitmq description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in CloudKitty diff --git a/api/v1beta1/autoscaling_webhook.go b/api/v1beta1/autoscaling_webhook.go index 49be6e3ca..716deb13a 100644 --- a/api/v1beta1/autoscaling_webhook.go +++ b/api/v1beta1/autoscaling_webhook.go @@ -19,7 +19,7 @@ package v1beta1 import ( "fmt" - rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" + common_webhook "github.com/openstack-k8s-operators/lib-common/modules/common/webhook" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -27,7 +27,6 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - common_webhook "github.com/openstack-k8s-operators/lib-common/modules/common/webhook" ) // AutoscalingDefaults - @@ -78,15 +77,11 @@ func (spec *AutoscalingSpec) Default() { // Default - note only *Core* versions like this will have validations that are called from the // Controlplane webhook func (spec *AodhCore) Default() { - if spec.RabbitMqClusterName == "" { - spec.RabbitMqClusterName = "rabbitmq" - } - - // Aodh only uses Notifications (never RPC), so only default NotificationsBus - if spec.NotificationsBus == nil { - spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{} + // Default NotificationsBus.Cluster if NotificationsBus is present but Cluster is empty + // Migration from deprecated fields is handled by openstack-operator + if spec.NotificationsBus != nil && spec.NotificationsBus.Cluster == "" { + spec.NotificationsBus.Cluster = "rabbitmq" } - rabbitmqv1.DefaultRabbitMqConfig(spec.NotificationsBus, spec.RabbitMqClusterName) if spec.MemcachedInstance == "" { spec.MemcachedInstance = "memcached" diff --git a/api/v1beta1/ceilometer_types.go b/api/v1beta1/ceilometer_types.go index c75c4a85f..b1f9a87ae 100644 --- a/api/v1beta1/ceilometer_types.go +++ b/api/v1beta1/ceilometer_types.go @@ -86,10 +86,10 @@ type CeilometerSpecCore struct { // NotificationsBus configuration (username, vhost, and cluster) for notifications NotificationsBus *rabbitmqv1.RabbitMqConfig `json:"notificationsBus,omitempty"` + // +kubebuilder:validation:Optional // RabbitMQ instance name // Needed to request a transportURL that is created and used in Telemetry // Deprecated: Use NotificationsBus.Cluster instead - // +kubebuilder:default=rabbitmq RabbitMqClusterName string `json:"rabbitMqClusterName,omitempty"` // PasswordSelectors - Selectors to identify the service from the Secret diff --git a/api/v1beta1/ceilometer_webhook.go b/api/v1beta1/ceilometer_webhook.go index 307ec3e97..b2dbb56a4 100644 --- a/api/v1beta1/ceilometer_webhook.go +++ b/api/v1beta1/ceilometer_webhook.go @@ -17,7 +17,6 @@ limitations under the License. package v1beta1 import ( - rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -92,15 +91,11 @@ func (spec *CeilometerSpec) Default() { // Default - set defaults for this CeilometerSpecCore. NOTE: this version is used by the OpenStackControlplane webhook func (spec *CeilometerSpecCore) Default() { - if spec.RabbitMqClusterName == "" { - spec.RabbitMqClusterName = "rabbitmq" + // Default NotificationsBus.Cluster if NotificationsBus is present but Cluster is empty + // Migration from deprecated fields is handled by openstack-operator + if spec.NotificationsBus != nil && spec.NotificationsBus.Cluster == "" { + spec.NotificationsBus.Cluster = "rabbitmq" } - - // Ceilometer only uses Notifications (never RPC), so only default NotificationsBus - if spec.NotificationsBus == nil { - spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{} - } - rabbitmqv1.DefaultRabbitMqConfig(spec.NotificationsBus, spec.RabbitMqClusterName) } // getDeprecatedFields returns the centralized list of deprecated fields for CeilometerSpecCore diff --git a/api/v1beta1/cloudkitty_types.go b/api/v1beta1/cloudkitty_types.go index 7c6c18ddc..ef5472d92 100644 --- a/api/v1beta1/cloudkitty_types.go +++ b/api/v1beta1/cloudkitty_types.go @@ -139,11 +139,10 @@ type CloudKittySpecBase struct { MessagingBus rabbitmqv1.RabbitMqConfig `json:"messagingBus,omitempty"` // +kubebuilder:validation:Optional - // +kubebuilder:default=rabbitmq // RabbitMQ instance name // Needed to request a transportURL that is created and used in CloudKitty // Deprecated: Use MessagingBus.Cluster instead - RabbitMqClusterName string `json:"rabbitMqClusterName"` + RabbitMqClusterName string `json:"rabbitMqClusterName,omitempty"` // +kubebuilder:validation:Optional // +kubebuilder:default=memcached diff --git a/api/v1beta1/cloudkitty_webhook.go b/api/v1beta1/cloudkitty_webhook.go index e77722747..5ee16e600 100644 --- a/api/v1beta1/cloudkitty_webhook.go +++ b/api/v1beta1/cloudkitty_webhook.go @@ -20,7 +20,6 @@ import ( "fmt" "slices" - rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -83,12 +82,10 @@ func (spec *CloudKittySpecCore) Default() { // Default - set defaults for this CloudKittySpecBase func (spec *CloudKittySpecBase) Default() { - if spec.RabbitMqClusterName == "" { - spec.RabbitMqClusterName = "rabbitmq" - } - // Only migrate from deprecated field if the new field is not already set + // Default MessagingBus.Cluster if not set + // Migration from deprecated fields is handled by openstack-operator if spec.MessagingBus.Cluster == "" { - rabbitmqv1.DefaultRabbitMqConfig(&spec.MessagingBus, spec.RabbitMqClusterName) + spec.MessagingBus.Cluster = "rabbitmq" } } diff --git a/api/v1beta1/telemetry_webhook_test.go b/api/v1beta1/telemetry_webhook_test.go index d3d54744e..5246698ff 100644 --- a/api/v1beta1/telemetry_webhook_test.go +++ b/api/v1beta1/telemetry_webhook_test.go @@ -11,45 +11,42 @@ func TestTelemetrySpecCoreDefault(t *testing.T) { g := NewWithT(t) spec := &TelemetrySpecCore{} - spec.Ceilometer.RabbitMqClusterName = "test-rabbitmq" - spec.CloudKitty.RabbitMqClusterName = "test-cloudkitty-rabbitmq" + // Set NotificationsBus and MessagingBus without Cluster to test defaulting + spec.Ceilometer.NotificationsBus = &rabbitmqv1.RabbitMqConfig{} + spec.CloudKitty.MessagingBus = rabbitmqv1.RabbitMqConfig{} - // Call Default() which should migrate rabbitMqClusterName to the appropriate bus config + // Call Default() spec.Default() - // Verify Ceilometer got notificationsBus defaulted (Ceilometer only uses Notifications, not RPC) - g.Expect(spec.Ceilometer.NotificationsBus).ToNot(BeNil(), - "Ceilometer notificationsBus should be initialized") - g.Expect(spec.Ceilometer.NotificationsBus.Cluster).To(Equal("test-rabbitmq"), - "Ceilometer notificationsBus.cluster should be defaulted from rabbitMqClusterName") + // Verify Ceilometer NotificationsBus.Cluster was defaulted + g.Expect(spec.Ceilometer.NotificationsBus.Cluster).To(Equal("rabbitmq"), + "Ceilometer notificationsBus.cluster should be defaulted to rabbitmq") - // Verify CloudKitty got messagingBus defaulted (CloudKitty uses RPC, not Notifications) - g.Expect(spec.CloudKitty.MessagingBus.Cluster).To(Equal("test-cloudkitty-rabbitmq"), - "CloudKitty messagingBus.cluster should be defaulted from rabbitMqClusterName") + // Verify CloudKitty MessagingBus.Cluster was defaulted + g.Expect(spec.CloudKitty.MessagingBus.Cluster).To(Equal("rabbitmq"), + "CloudKitty messagingBus.cluster should be defaulted to rabbitmq") } func TestCeilometerSpecCoreDefault(t *testing.T) { g := NewWithT(t) spec := &CeilometerSpecCore{} - spec.RabbitMqClusterName = "test-rabbitmq" + // Set NotificationsBus without Cluster to test defaulting + spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{} // Call Default() spec.Default() - // Verify NotificationsBus is defaulted (Ceilometer only uses Notifications) - g.Expect(spec.NotificationsBus).ToNot(BeNil(), - "Ceilometer notificationsBus should be initialized") - g.Expect(spec.NotificationsBus.Cluster).To(Equal("test-rabbitmq"), - "Ceilometer notificationsBus.cluster should be defaulted from rabbitMqClusterName") + // Verify NotificationsBus.Cluster is defaulted + g.Expect(spec.NotificationsBus.Cluster).To(Equal("rabbitmq"), + "Ceilometer notificationsBus.cluster should be defaulted to rabbitmq") } func TestCeilometerSpecCoreDefaultWithExistingNotificationsBus(t *testing.T) { g := NewWithT(t) spec := &CeilometerSpecCore{} - spec.RabbitMqClusterName = "test-rabbitmq" - // User explicitly sets notificationsBus + // User explicitly sets notificationsBus with all fields spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{ Cluster: "custom-notifications-rabbitmq", User: "custom-user", @@ -72,28 +69,27 @@ func TestAodhCoreDefault(t *testing.T) { g := NewWithT(t) spec := &AodhCore{} - spec.RabbitMqClusterName = "test-rabbitmq" + // Set NotificationsBus without Cluster to test defaulting + spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{} // Call Default() spec.Default() - // Verify NotificationsBus is defaulted (Aodh only uses Notifications) - g.Expect(spec.NotificationsBus).ToNot(BeNil(), - "Aodh notificationsBus should be initialized") - g.Expect(spec.NotificationsBus.Cluster).To(Equal("test-rabbitmq"), - "Aodh notificationsBus.cluster should be defaulted from rabbitMqClusterName") + // Verify NotificationsBus.Cluster is defaulted + g.Expect(spec.NotificationsBus.Cluster).To(Equal("rabbitmq"), + "Aodh notificationsBus.cluster should be defaulted to rabbitmq") } func TestCloudKittySpecBaseDefault(t *testing.T) { g := NewWithT(t) spec := &CloudKittySpecBase{} - spec.RabbitMqClusterName = "test-rabbitmq" + // MessagingBus.Cluster is empty, should be defaulted // Call Default() spec.Default() - // Verify MessagingBus is defaulted (CloudKitty uses RPC messaging) - g.Expect(spec.MessagingBus.Cluster).To(Equal("test-rabbitmq"), - "CloudKitty messagingBus.cluster should be defaulted from rabbitMqClusterName") + // Verify MessagingBus.Cluster is defaulted + g.Expect(spec.MessagingBus.Cluster).To(Equal("rabbitmq"), + "CloudKitty messagingBus.cluster should be defaulted to rabbitmq") } diff --git a/config/crd/bases/telemetry.openstack.org_ceilometers.yaml b/config/crd/bases/telemetry.openstack.org_ceilometers.yaml index bd5810823..9cdc781e4 100644 --- a/config/crd/bases/telemetry.openstack.org_ceilometers.yaml +++ b/config/crd/bases/telemetry.openstack.org_ceilometers.yaml @@ -249,7 +249,6 @@ spec: proxyImage: type: string rabbitMqClusterName: - default: rabbitmq description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Telemetry diff --git a/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml b/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml index 40fe06c36..0e74745d2 100644 --- a/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml +++ b/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml @@ -649,7 +649,6 @@ spec: type: object x-kubernetes-map-type: atomic rabbitMqClusterName: - default: rabbitmq description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in CloudKitty diff --git a/config/crd/bases/telemetry.openstack.org_telemetries.yaml b/config/crd/bases/telemetry.openstack.org_telemetries.yaml index 90d5969a0..e5e82ab9e 100644 --- a/config/crd/bases/telemetry.openstack.org_telemetries.yaml +++ b/config/crd/bases/telemetry.openstack.org_telemetries.yaml @@ -603,7 +603,6 @@ spec: proxyImage: type: string rabbitMqClusterName: - default: rabbitmq description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Telemetry @@ -1271,7 +1270,6 @@ spec: type: object x-kubernetes-map-type: atomic rabbitMqClusterName: - default: rabbitmq description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in CloudKitty diff --git a/internal/controller/ceilometer_controller.go b/internal/controller/ceilometer_controller.go index e5842e19c..d31067969 100644 --- a/internal/controller/ceilometer_controller.go +++ b/internal/controller/ceilometer_controller.go @@ -1700,7 +1700,14 @@ func (r *CeilometerReconciler) transportURLCreateOrUpdate( ) (*rabbitmqv1.TransportURL, controllerutil.OperationResult, error) { // Ceilometer only uses NotificationsBus TransportURL rmqName := fmt.Sprintf("%s-notifications-transport", ceilometer.ServiceName) + + // Initialize config if nil (webhook only defaults Cluster if NotificationsBus exists) config := rabbitmqConfig + if config == nil { + config = &rabbitmqv1.RabbitMqConfig{ + Cluster: "rabbitmq", + } + } // Prepare the spec values before CreateOrUpdate so webhooks see them during CREATE clusterName := config.Cluster diff --git a/test/kuttl/tests/cloudkitty/02-deploy.yaml b/test/kuttl/tests/cloudkitty/02-deploy.yaml index 52f2ac0d9..57d7ba095 100644 --- a/test/kuttl/tests/cloudkitty/02-deploy.yaml +++ b/test/kuttl/tests/cloudkitty/02-deploy.yaml @@ -38,7 +38,8 @@ spec: cloudKittyService: CloudKittyPassword period: 300 preserveJobs: false - rabbitMqClusterName: rabbitmq + messagingBus: + cluster: rabbitmq s3StorageConfig: schemas: - effectiveDate: "2024-11-18" diff --git a/test/kuttl/tests/cloudkitty/03-custom-config-secret.yaml b/test/kuttl/tests/cloudkitty/03-custom-config-secret.yaml index 050cb2b87..0672145b9 100644 --- a/test/kuttl/tests/cloudkitty/03-custom-config-secret.yaml +++ b/test/kuttl/tests/cloudkitty/03-custom-config-secret.yaml @@ -50,7 +50,8 @@ spec: cloudKittyService: CloudKittyPassword period: 300 preserveJobs: false - rabbitMqClusterName: rabbitmq + messagingBus: + cluster: rabbitmq s3StorageConfig: schemas: - effectiveDate: "2024-11-18" From 873d6fa21bcac3ac15c74a4c5d753d06c97fc3a6 Mon Sep 17 00:00:00 2001 From: Luca Miccini Date: Fri, 30 Jan 2026 07:06:19 +0100 Subject: [PATCH 5/5] return warnings --- .../telemetry.openstack.org_autoscalings.yaml | 1 - .../telemetry.openstack.org_cloudkitties.yaml | 4 -- .../telemetry.openstack.org_telemetries.yaml | 1 - api/v1beta1/autoscaling_types.go | 1 - api/v1beta1/autoscaling_webhook.go | 40 ++++++++++------- api/v1beta1/ceilometer_webhook.go | 45 ++++++++++--------- api/v1beta1/cloudkitty_types.go | 3 -- api/v1beta1/cloudkitty_webhook.go | 38 +++++++++------- api/v1beta1/telemetry_webhook.go | 16 +++++-- api/v1beta1/telemetry_webhook_test.go | 24 +++++----- api/v1beta1/zz_generated.deepcopy.go | 5 --- .../telemetry.openstack.org_autoscalings.yaml | 1 - .../telemetry.openstack.org_cloudkitties.yaml | 4 -- .../telemetry.openstack.org_telemetries.yaml | 1 - ...emetry-operator.clusterserviceversion.yaml | 42 +++++++++++++++++ .../telemetry_v1beta1_autoscaling.yaml | 2 + .../telemetry_v1beta1_autoscaling_tls.yaml | 2 + .../samples/telemetry_v1beta1_ceilometer.yaml | 2 + .../telemetry_v1beta1_ceilometer_tls.yaml | 2 + .../samples/telemetry_v1beta1_telemetry.yaml | 4 ++ .../telemetry_v1beta1_telemetry_tls.yaml | 4 ++ .../telemetry_v1beta1_telemetry_topology.yaml | 4 ++ go.sum | 20 --------- internal/ceilometer/const.go | 16 ------- internal/controller/autoscaling_controller.go | 6 ++- internal/controller/ceilometer_controller.go | 14 +++--- test/kuttl/tests/autoscaling/01-deploy.yaml | 2 + .../autoscaling/02-custom-config-secret.yaml | 2 + .../deps/OpenStackControlPlane.yaml | 2 + test/kuttl/tests/ceilometer/00-deploy.yaml | 2 + .../ceilometer/01-custom-config-secret.yaml | 2 + test/kuttl/tests/default/01-deploy.yaml | 4 ++ .../default/deps/OpenStackControlPlane.yaml | 2 + test/kuttl/tests/metricstorage/01-deploy.yaml | 2 + test/kuttl/tests/tls/02-deploy.yaml | 4 ++ .../tests/tls/deps/OpenStackControlPlane.yaml | 2 + test/kuttl/tests/topology/01-deploy.yaml | 4 ++ .../topology/deps/OpenStackControlPlane.yaml | 2 + 38 files changed, 197 insertions(+), 135 deletions(-) diff --git a/api/bases/telemetry.openstack.org_autoscalings.yaml b/api/bases/telemetry.openstack.org_autoscalings.yaml index 756b3540d..33f7fd366 100644 --- a/api/bases/telemetry.openstack.org_autoscalings.yaml +++ b/api/bases/telemetry.openstack.org_autoscalings.yaml @@ -336,7 +336,6 @@ spec: e.g. to check logs type: boolean rabbitMqClusterName: - default: rabbitmq description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Aodh diff --git a/api/bases/telemetry.openstack.org_cloudkitties.yaml b/api/bases/telemetry.openstack.org_cloudkitties.yaml index 0e74745d2..40b51bb26 100644 --- a/api/bases/telemetry.openstack.org_cloudkitties.yaml +++ b/api/bases/telemetry.openstack.org_cloudkitties.yaml @@ -822,10 +822,6 @@ spec: type: string description: Map of hashes to track e.g. job status type: object - notificationsURLSecret: - description: NotificationsURLSecret - Secret containing RabbitMQ notification - transportURL - type: string observedGeneration: description: |- ObservedGeneration - the most recent generation observed for this service. diff --git a/api/bases/telemetry.openstack.org_telemetries.yaml b/api/bases/telemetry.openstack.org_telemetries.yaml index e5e82ab9e..0cf9c6c6f 100644 --- a/api/bases/telemetry.openstack.org_telemetries.yaml +++ b/api/bases/telemetry.openstack.org_telemetries.yaml @@ -339,7 +339,6 @@ spec: finished e.g. to check logs type: boolean rabbitMqClusterName: - default: rabbitmq description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Aodh diff --git a/api/v1beta1/autoscaling_types.go b/api/v1beta1/autoscaling_types.go index 5ee118c17..e1d2a2396 100644 --- a/api/v1beta1/autoscaling_types.go +++ b/api/v1beta1/autoscaling_types.go @@ -71,7 +71,6 @@ type AodhCore struct { // RabbitMQ instance name // Needed to request a transportURL that is created and used in Aodh // Deprecated: Use NotificationsBus.Cluster instead - // +kubebuilder:default=rabbitmq RabbitMqClusterName string `json:"rabbitMqClusterName,omitempty"` // +kubebuilder:validation:Required diff --git a/api/v1beta1/autoscaling_webhook.go b/api/v1beta1/autoscaling_webhook.go index 716deb13a..14e37abf9 100644 --- a/api/v1beta1/autoscaling_webhook.go +++ b/api/v1beta1/autoscaling_webhook.go @@ -77,11 +77,9 @@ func (spec *AutoscalingSpec) Default() { // Default - note only *Core* versions like this will have validations that are called from the // Controlplane webhook func (spec *AodhCore) Default() { - // Default NotificationsBus.Cluster if NotificationsBus is present but Cluster is empty + // NotificationsBus.Cluster is not defaulted - it must be explicitly set if NotificationsBus is configured // Migration from deprecated fields is handled by openstack-operator - if spec.NotificationsBus != nil && spec.NotificationsBus.Cluster == "" { - spec.NotificationsBus.Cluster = "rabbitmq" - } + // This ensures users make a conscious choice about which cluster to use for notifications if spec.MemcachedInstance == "" { spec.MemcachedInstance = "memcached" @@ -169,19 +167,22 @@ func (r *Autoscaling) ValidateCreate() (admission.Warnings, error) { autoscalinglog.Info("validate create", "name", r.Name) var allErrs field.ErrorList + var allWarns []string basePath := field.NewPath("spec") - if err := r.Spec.Aodh.ValidateCreate(basePath.Child("aodh"), r.Namespace); err != nil { + warns, err := r.Spec.Aodh.ValidateCreate(basePath.Child("aodh"), r.Namespace) + allWarns = append(allWarns, warns...) + if err != nil { allErrs = append(allErrs, err...) } if len(allErrs) != 0 { - return nil, apierrors.NewInvalid( + return allWarns, apierrors.NewInvalid( schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Autoscaling"}, r.Name, allErrs) } - return nil, nil + return allWarns, nil } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type @@ -194,19 +195,22 @@ func (r *Autoscaling) ValidateUpdate(old runtime.Object) (admission.Warnings, er } var allErrs field.ErrorList + var allWarns []string basePath := field.NewPath("spec") - if err := r.Spec.Aodh.ValidateUpdate(oldAutoscaling.Spec.Aodh.AodhCore, basePath.Child("aodh"), r.Namespace); err != nil { + warns, err := r.Spec.Aodh.ValidateUpdate(oldAutoscaling.Spec.Aodh.AodhCore, basePath.Child("aodh"), r.Namespace) + allWarns = append(allWarns, warns...) + if err != nil { allErrs = append(allErrs, err...) } if len(allErrs) != 0 { - return nil, apierrors.NewInvalid( + return allWarns, apierrors.NewInvalid( schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Autoscaling"}, r.Name, allErrs) } - return nil, nil + return allWarns, nil } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type @@ -218,28 +222,32 @@ func (r *Autoscaling) ValidateDelete() (admission.Warnings, error) { // ValidateCreate - Exported function wrapping non-exported validate functions, // this function can be called externally to validate an aodh spec. -func (spec *AodhCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList { +func (spec *AodhCore) ValidateCreate(basePath *field.Path, namespace string) ([]string, field.ErrorList) { var allErrs field.ErrorList + var allWarns []string // Validate deprecated fields using shared helper - _, errs := spec.validateDeprecatedFieldsCreate(basePath) + warns, errs := spec.validateDeprecatedFieldsCreate(basePath) + allWarns = append(allWarns, warns...) allErrs = append(allErrs, errs...) allErrs = append(allErrs, spec.ValidateTopology(basePath, namespace)...) - return allErrs + return allWarns, allErrs } // ValidateUpdate - Exported function wrapping non-exported validate functions, // this function can be called externally to validate an aodh spec. -func (spec *AodhCore) ValidateUpdate(old AodhCore, basePath *field.Path, namespace string) field.ErrorList { +func (spec *AodhCore) ValidateUpdate(old AodhCore, basePath *field.Path, namespace string) ([]string, field.ErrorList) { var allErrs field.ErrorList + var allWarns []string // Validate deprecated fields using shared helper - _, errs := spec.validateDeprecatedFieldsUpdate(old, basePath) + warns, errs := spec.validateDeprecatedFieldsUpdate(old, basePath) + allWarns = append(allWarns, warns...) allErrs = append(allErrs, errs...) allErrs = append(allErrs, spec.ValidateTopology(basePath, namespace)...) - return allErrs + return allWarns, allErrs } diff --git a/api/v1beta1/ceilometer_webhook.go b/api/v1beta1/ceilometer_webhook.go index b2dbb56a4..ff708da0f 100644 --- a/api/v1beta1/ceilometer_webhook.go +++ b/api/v1beta1/ceilometer_webhook.go @@ -91,11 +91,9 @@ func (spec *CeilometerSpec) Default() { // Default - set defaults for this CeilometerSpecCore. NOTE: this version is used by the OpenStackControlplane webhook func (spec *CeilometerSpecCore) Default() { - // Default NotificationsBus.Cluster if NotificationsBus is present but Cluster is empty + // NotificationsBus.Cluster is not defaulted - it must be explicitly set if NotificationsBus is configured // Migration from deprecated fields is handled by openstack-operator - if spec.NotificationsBus != nil && spec.NotificationsBus.Cluster == "" { - spec.NotificationsBus.Cluster = "rabbitmq" - } + // This ensures users make a conscious choice about which cluster to use for notifications } // getDeprecatedFields returns the centralized list of deprecated fields for CeilometerSpecCore @@ -143,11 +141,6 @@ func (spec *CeilometerSpecCore) validateDeprecatedFieldsUpdate(old CeilometerSpe return common_webhook.ValidateDeprecatedFieldsUpdate(deprecatedFields, basePath) } -func (spec *CeilometerSpecCore) Default() { - // NOTE: ApplicationCredentialSecret is NOT defaulted here. - // AppCred is opt-in: only used when explicitly configured by the user. -} - var _ webhook.Validator = &Ceilometer{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type @@ -155,19 +148,22 @@ func (r *Ceilometer) ValidateCreate() (admission.Warnings, error) { ceilometerlog.Info("validate create", "name", r.Name) var allErrs field.ErrorList + var allWarns []string basePath := field.NewPath("spec") - if err := r.Spec.CeilometerSpecCore.ValidateCreate(basePath, r.Namespace); err != nil { + warns, err := r.Spec.CeilometerSpecCore.ValidateCreate(basePath, r.Namespace) + allWarns = append(allWarns, warns...) + if err != nil { allErrs = append(allErrs, err...) } if len(allErrs) != 0 { - return nil, apierrors.NewInvalid( + return allWarns, apierrors.NewInvalid( schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Ceilometer"}, r.Name, allErrs) } - return nil, nil + return allWarns, nil } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type @@ -180,19 +176,22 @@ func (r *Ceilometer) ValidateUpdate(old runtime.Object) (admission.Warnings, err } var allErrs field.ErrorList + var allWarns []string basePath := field.NewPath("spec") - if err := r.Spec.CeilometerSpecCore.ValidateUpdate(oldCeilometer.Spec.CeilometerSpecCore, basePath, r.Namespace); err != nil { + warns, err := r.Spec.CeilometerSpecCore.ValidateUpdate(oldCeilometer.Spec.CeilometerSpecCore, basePath, r.Namespace) + allWarns = append(allWarns, warns...) + if err != nil { allErrs = append(allErrs, err...) } if len(allErrs) != 0 { - return nil, apierrors.NewInvalid( + return allWarns, apierrors.NewInvalid( schema.GroupKind{Group: "telemetry.openstack.org", Kind: "Ceilometer"}, r.Name, allErrs) } - return nil, nil + return allWarns, nil } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type @@ -204,28 +203,32 @@ func (r *Ceilometer) ValidateDelete() (admission.Warnings, error) { // ValidateCreate - Exported function wrapping non-exported validate functions, // this function can be called externally to validate a ceilometer spec. -func (spec *CeilometerSpecCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList { +func (spec *CeilometerSpecCore) ValidateCreate(basePath *field.Path, namespace string) ([]string, field.ErrorList) { var allErrs field.ErrorList + var allWarns []string // Validate deprecated fields using shared helper - _, errs := spec.validateDeprecatedFieldsCreate(basePath) + warns, errs := spec.validateDeprecatedFieldsCreate(basePath) + allWarns = append(allWarns, warns...) allErrs = append(allErrs, errs...) allErrs = append(allErrs, spec.ValidateTopology(basePath, namespace)...) - return allErrs + return allWarns, allErrs } // ValidateUpdate - Exported function wrapping non-exported validate functions, // this function can be called externally to validate a ceilometer spec. -func (spec *CeilometerSpecCore) ValidateUpdate(old CeilometerSpecCore, basePath *field.Path, namespace string) field.ErrorList { +func (spec *CeilometerSpecCore) ValidateUpdate(old CeilometerSpecCore, basePath *field.Path, namespace string) ([]string, field.ErrorList) { var allErrs field.ErrorList + var allWarns []string // Validate deprecated fields using shared helper - _, errs := spec.validateDeprecatedFieldsUpdate(old, basePath) + warns, errs := spec.validateDeprecatedFieldsUpdate(old, basePath) + allWarns = append(allWarns, warns...) allErrs = append(allErrs, errs...) allErrs = append(allErrs, spec.ValidateTopology(basePath, namespace)...) - return allErrs + return allWarns, allErrs } diff --git a/api/v1beta1/cloudkitty_types.go b/api/v1beta1/cloudkitty_types.go index ef5472d92..631568ed7 100644 --- a/api/v1beta1/cloudkitty_types.go +++ b/api/v1beta1/cloudkitty_types.go @@ -324,9 +324,6 @@ type CloudKittyStatus struct { // TransportURLSecret - Secret containing RabbitMQ transportURL TransportURLSecret string `json:"transportURLSecret,omitempty"` - // NotificationsURLSecret - Secret containing RabbitMQ notification transportURL - NotificationsURLSecret *string `json:"notificationsURLSecret,omitempty"` - // API endpoints APIEndpoints map[string]map[string]string `json:"apiEndpoints,omitempty"` diff --git a/api/v1beta1/cloudkitty_webhook.go b/api/v1beta1/cloudkitty_webhook.go index 5ee16e600..38f2fc3aa 100644 --- a/api/v1beta1/cloudkitty_webhook.go +++ b/api/v1beta1/cloudkitty_webhook.go @@ -195,41 +195,43 @@ func (r *ObjectStorageSpec) Validate(basePath *field.Path) field.ErrorList { func (r *CloudKitty) ValidateCreate() (admission.Warnings, error) { cloudKittyLog.Info("validate create", "name", r.Name) - allErrs := r.Spec.ValidateCreate(field.NewPath("spec"), r.Namespace) + allWarns, allErrs := r.Spec.ValidateCreate(field.NewPath("spec"), r.Namespace) if len(allErrs) != 0 { - return nil, apierrors.NewInvalid( + return allWarns, apierrors.NewInvalid( schema.GroupKind{Group: "cloudkitties.telemetry.openstack.org", Kind: "CloudKitty"}, r.Name, allErrs) } - return nil, nil + return allWarns, nil } // ValidateCreate validates the CloudKittySpec during the webhook invocation. -func (r *CloudKittySpec) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList { +func (r *CloudKittySpec) ValidateCreate(basePath *field.Path, namespace string) ([]string, field.ErrorList) { return r.CloudKittySpecBase.ValidateCreate(basePath, namespace) } // ValidateCreate validates the CloudKittySpecCore during the webhook invocation. It is // expected to be called by the validation webhook in the higher level telemetry webhook -func (r *CloudKittySpecCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList { +func (r *CloudKittySpecCore) ValidateCreate(basePath *field.Path, namespace string) ([]string, field.ErrorList) { return r.CloudKittySpecBase.ValidateCreate(basePath, namespace) } // ValidateCreate validates the CloudKittySpecBase during the webhook invocation. -func (r *CloudKittySpecBase) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList { +func (r *CloudKittySpecBase) ValidateCreate(basePath *field.Path, namespace string) ([]string, field.ErrorList) { var allErrs field.ErrorList + var allWarns []string // Validate deprecated fields using shared helper - _, errs := r.validateDeprecatedFieldsCreate(basePath) + warns, errs := r.validateDeprecatedFieldsCreate(basePath) + allWarns = append(allWarns, warns...) allErrs = append(allErrs, errs...) allErrs = append(allErrs, r.S3StorageConfig.Validate(basePath.Child("s3StorageConfig"))...) // TODO: Add other CK spec field validations as needed - return allErrs + return allWarns, allErrs } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type @@ -241,42 +243,44 @@ func (r *CloudKitty) ValidateUpdate(old runtime.Object) (admission.Warnings, err return nil, apierrors.NewInternalError(fmt.Errorf("unable to convert existing object")) } - allErrs := r.Spec.ValidateUpdate(oldCloudKitty.Spec, field.NewPath("spec"), r.Namespace) + allWarns, allErrs := r.Spec.ValidateUpdate(oldCloudKitty.Spec, field.NewPath("spec"), r.Namespace) if len(allErrs) != 0 { - return nil, apierrors.NewInvalid( + return allWarns, apierrors.NewInvalid( schema.GroupKind{Group: "cloudkitties.telemetry.openstack.org", Kind: "CloudKitty"}, r.Name, allErrs) } - return nil, nil + return allWarns, nil } -// ValidateCreate validates the CloudKittySpec during the webhook invocation. -func (r *CloudKittySpec) ValidateUpdate(old CloudKittySpec, basePath *field.Path, namespace string) field.ErrorList { +// ValidateUpdate validates the CloudKittySpec during the webhook invocation. +func (r *CloudKittySpec) ValidateUpdate(old CloudKittySpec, basePath *field.Path, namespace string) ([]string, field.ErrorList) { return r.CloudKittySpecBase.ValidateUpdate(old.CloudKittySpecBase, basePath, namespace) } // ValidateUpdate validates the CloudKittySpecCore during the webhook invocation. It is // expected to be called by the validation webhook in the higher level telemetry webhook -func (r *CloudKittySpecCore) ValidateUpdate(old CloudKittySpecCore, basePath *field.Path, namespace string) field.ErrorList { +func (r *CloudKittySpecCore) ValidateUpdate(old CloudKittySpecCore, basePath *field.Path, namespace string) ([]string, field.ErrorList) { return r.CloudKittySpecBase.ValidateUpdate(old.CloudKittySpecBase, basePath, namespace) } // ValidateUpdate validates the CloudKittySpecBase during the webhook invocation. -func (r *CloudKittySpecBase) ValidateUpdate(old CloudKittySpecBase, basePath *field.Path, namespace string) field.ErrorList { +func (r *CloudKittySpecBase) ValidateUpdate(old CloudKittySpecBase, basePath *field.Path, namespace string) ([]string, field.ErrorList) { var allErrs field.ErrorList + var allWarns []string // Validate deprecated fields using shared helper - _, errs := r.validateDeprecatedFieldsUpdate(old, basePath) + warns, errs := r.validateDeprecatedFieldsUpdate(old, basePath) + allWarns = append(allWarns, warns...) allErrs = append(allErrs, errs...) allErrs = append(allErrs, r.S3StorageConfig.Validate(basePath.Child("s3StorageConfig"))...) // TODO: Add other CK spec field validations as needed - return allErrs + return allWarns, allErrs } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type diff --git a/api/v1beta1/telemetry_webhook.go b/api/v1beta1/telemetry_webhook.go index 463730bee..3012b0546 100644 --- a/api/v1beta1/telemetry_webhook.go +++ b/api/v1beta1/telemetry_webhook.go @@ -158,7 +158,9 @@ func (r TelemetrySpec) ValidateCreate(basePath *field.Path, namespace string) ([ allErrs = append(allErrs, r.ValidateTelemetryTopology(basePath, namespace)...) if r.CloudKitty.Enabled != nil && *r.CloudKitty.Enabled { - allErrs = append(allErrs, r.CloudKitty.CloudKittySpec.ValidateCreate(basePath.Child("cloudkitty"), namespace)...) + warns, errs := r.CloudKitty.CloudKittySpec.ValidateCreate(basePath.Child("cloudkitty"), namespace) + allWarns = append(allWarns, warns...) + allErrs = append(allErrs, errs...) } return allWarns, allErrs } @@ -169,7 +171,9 @@ func (r TelemetrySpecCore) ValidateCreate(basePath *field.Path, namespace string allErrs = append(allErrs, r.ValidateTelemetryTopology(basePath, namespace)...) if r.CloudKitty.Enabled != nil && *r.CloudKitty.Enabled { - allErrs = append(allErrs, r.CloudKitty.CloudKittySpecCore.ValidateCreate(basePath.Child("cloudkitty"), namespace)...) + warns, errs := r.CloudKitty.CloudKittySpecCore.ValidateCreate(basePath.Child("cloudkitty"), namespace) + allWarns = append(allWarns, warns...) + allErrs = append(allErrs, errs...) } return allWarns, allErrs } @@ -205,7 +209,9 @@ func (r TelemetrySpec) ValidateUpdate(old TelemetrySpec, basePath *field.Path, n allErrs = append(allErrs, r.ValidateTelemetryTopology(basePath, namespace)...) if r.CloudKitty.Enabled != nil && *r.CloudKitty.Enabled { - allErrs = append(allErrs, r.CloudKitty.CloudKittySpec.ValidateUpdate(old.CloudKitty.CloudKittySpec, basePath.Child("cloudkitty"), namespace)...) + warns, errs := r.CloudKitty.CloudKittySpec.ValidateUpdate(old.CloudKitty.CloudKittySpec, basePath.Child("cloudkitty"), namespace) + allWarns = append(allWarns, warns...) + allErrs = append(allErrs, errs...) } return allWarns, allErrs } @@ -216,7 +222,9 @@ func (r TelemetrySpecCore) ValidateUpdate(old TelemetrySpecCore, basePath *field allErrs = append(allErrs, r.ValidateTelemetryTopology(basePath, namespace)...) if r.CloudKitty.Enabled != nil && *r.CloudKitty.Enabled { - allErrs = append(allErrs, r.CloudKitty.CloudKittySpecCore.ValidateUpdate(old.CloudKitty.CloudKittySpecCore, basePath.Child("cloudkitty"), namespace)...) + warns, errs := r.CloudKitty.CloudKittySpecCore.ValidateUpdate(old.CloudKitty.CloudKittySpecCore, basePath.Child("cloudkitty"), namespace) + allWarns = append(allWarns, warns...) + allErrs = append(allErrs, errs...) } return allWarns, allErrs } diff --git a/api/v1beta1/telemetry_webhook_test.go b/api/v1beta1/telemetry_webhook_test.go index 5246698ff..931009028 100644 --- a/api/v1beta1/telemetry_webhook_test.go +++ b/api/v1beta1/telemetry_webhook_test.go @@ -11,16 +11,16 @@ func TestTelemetrySpecCoreDefault(t *testing.T) { g := NewWithT(t) spec := &TelemetrySpecCore{} - // Set NotificationsBus and MessagingBus without Cluster to test defaulting + // Set NotificationsBus and MessagingBus without Cluster spec.Ceilometer.NotificationsBus = &rabbitmqv1.RabbitMqConfig{} spec.CloudKitty.MessagingBus = rabbitmqv1.RabbitMqConfig{} // Call Default() spec.Default() - // Verify Ceilometer NotificationsBus.Cluster was defaulted - g.Expect(spec.Ceilometer.NotificationsBus.Cluster).To(Equal("rabbitmq"), - "Ceilometer notificationsBus.cluster should be defaulted to rabbitmq") + // Verify Ceilometer NotificationsBus.Cluster is NOT defaulted (must be explicitly set) + g.Expect(spec.Ceilometer.NotificationsBus.Cluster).To(Equal(""), + "Ceilometer notificationsBus.cluster should not be defaulted - it must be explicitly set") // Verify CloudKitty MessagingBus.Cluster was defaulted g.Expect(spec.CloudKitty.MessagingBus.Cluster).To(Equal("rabbitmq"), @@ -31,15 +31,15 @@ func TestCeilometerSpecCoreDefault(t *testing.T) { g := NewWithT(t) spec := &CeilometerSpecCore{} - // Set NotificationsBus without Cluster to test defaulting + // Set NotificationsBus without Cluster spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{} // Call Default() spec.Default() - // Verify NotificationsBus.Cluster is defaulted - g.Expect(spec.NotificationsBus.Cluster).To(Equal("rabbitmq"), - "Ceilometer notificationsBus.cluster should be defaulted to rabbitmq") + // Verify NotificationsBus.Cluster is NOT defaulted (must be explicitly set) + g.Expect(spec.NotificationsBus.Cluster).To(Equal(""), + "Ceilometer notificationsBus.cluster should not be defaulted - it must be explicitly set") } func TestCeilometerSpecCoreDefaultWithExistingNotificationsBus(t *testing.T) { @@ -69,15 +69,15 @@ func TestAodhCoreDefault(t *testing.T) { g := NewWithT(t) spec := &AodhCore{} - // Set NotificationsBus without Cluster to test defaulting + // Set NotificationsBus without Cluster spec.NotificationsBus = &rabbitmqv1.RabbitMqConfig{} // Call Default() spec.Default() - // Verify NotificationsBus.Cluster is defaulted - g.Expect(spec.NotificationsBus.Cluster).To(Equal("rabbitmq"), - "Aodh notificationsBus.cluster should be defaulted to rabbitmq") + // Verify NotificationsBus.Cluster is NOT defaulted (must be explicitly set) + g.Expect(spec.NotificationsBus.Cluster).To(Equal(""), + "Aodh notificationsBus.cluster should not be defaulted - it must be explicitly set") } func TestCloudKittySpecBaseDefault(t *testing.T) { diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index f6c76af4a..467fe3676 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -1235,11 +1235,6 @@ func (in *CloudKittyStatus) DeepCopyInto(out *CloudKittyStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.NotificationsURLSecret != nil { - in, out := &in.NotificationsURLSecret, &out.NotificationsURLSecret - *out = new(string) - **out = **in - } if in.APIEndpoints != nil { in, out := &in.APIEndpoints, &out.APIEndpoints *out = make(map[string]map[string]string, len(*in)) diff --git a/config/crd/bases/telemetry.openstack.org_autoscalings.yaml b/config/crd/bases/telemetry.openstack.org_autoscalings.yaml index 756b3540d..33f7fd366 100644 --- a/config/crd/bases/telemetry.openstack.org_autoscalings.yaml +++ b/config/crd/bases/telemetry.openstack.org_autoscalings.yaml @@ -336,7 +336,6 @@ spec: e.g. to check logs type: boolean rabbitMqClusterName: - default: rabbitmq description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Aodh diff --git a/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml b/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml index 0e74745d2..40b51bb26 100644 --- a/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml +++ b/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml @@ -822,10 +822,6 @@ spec: type: string description: Map of hashes to track e.g. job status type: object - notificationsURLSecret: - description: NotificationsURLSecret - Secret containing RabbitMQ notification - transportURL - type: string observedGeneration: description: |- ObservedGeneration - the most recent generation observed for this service. diff --git a/config/crd/bases/telemetry.openstack.org_telemetries.yaml b/config/crd/bases/telemetry.openstack.org_telemetries.yaml index e5e82ab9e..0cf9c6c6f 100644 --- a/config/crd/bases/telemetry.openstack.org_telemetries.yaml +++ b/config/crd/bases/telemetry.openstack.org_telemetries.yaml @@ -339,7 +339,6 @@ spec: finished e.g. to check logs type: boolean rabbitMqClusterName: - default: rabbitmq description: |- RabbitMQ instance name Needed to request a transportURL that is created and used in Aodh diff --git a/config/manifests/bases/telemetry-operator.clusterserviceversion.yaml b/config/manifests/bases/telemetry-operator.clusterserviceversion.yaml index 48e8b55d9..8a0201ecf 100644 --- a/config/manifests/bases/telemetry-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/telemetry-operator.clusterserviceversion.yaml @@ -25,6 +25,12 @@ spec: kind: Autoscaling name: autoscalings.telemetry.openstack.org specDescriptors: + - description: Auth - authentication settings for keystone integration + displayName: Auth + path: aodh.auth + - description: ApplicationCredentialSecret - secret name for application credential + displayName: Application Credential Secret + path: aodh.auth.applicationCredentialSecret - description: TLS - Parameters related to the TLS displayName: TLS path: aodh.tls @@ -34,6 +40,12 @@ spec: kind: Ceilometer name: ceilometers.telemetry.openstack.org specDescriptors: + - description: Auth - authentication settings for keystone integration + displayName: Auth + path: auth + - description: ApplicationCredentialSecret - secret name for application credential + displayName: Application Credential Secret + path: auth.applicationCredentialSecret - description: KSMTLS - Parameters related to the TLS for kube-state-metrics displayName: KSMTLS path: ksmTls @@ -49,6 +61,12 @@ spec: kind: CloudKitty name: cloudkitties.telemetry.openstack.org specDescriptors: + - description: Auth - authentication settings for keystone integration + displayName: Auth + path: auth + - description: ApplicationCredentialSecret - secret name for application credential + displayName: Application Credential Secret + path: auth.applicationCredentialSecret - description: TLS - Parameters related to the TLS displayName: TLS path: cloudKittyAPI.tls @@ -61,6 +79,12 @@ spec: kind: CloudKittyProc name: cloudkittyprocs.telemetry.openstack.org specDescriptors: + - description: Auth - authentication settings for keystone integration + displayName: Auth + path: auth + - description: ApplicationCredentialSecret - secret name for application credential + displayName: Application Credential Secret + path: auth.applicationCredentialSecret - description: TLS - Parameters related to the TLS displayName: TLS path: tls @@ -84,6 +108,12 @@ spec: kind: Telemetry name: telemetries.telemetry.openstack.org specDescriptors: + - description: Auth - authentication settings for keystone integration + displayName: Auth + path: autoscaling.aodh.auth + - description: ApplicationCredentialSecret - secret name for application credential + displayName: Application Credential Secret + path: autoscaling.aodh.auth.applicationCredentialSecret - description: TLS - Parameters related to the TLS displayName: TLS path: autoscaling.aodh.tls @@ -93,6 +123,12 @@ spec: path: autoscaling.enabled x-descriptors: - urn:alm:descriptor:com.tectonic.ui:booleanSwitch + - description: Auth - authentication settings for keystone integration + displayName: Auth + path: ceilometer.auth + - description: ApplicationCredentialSecret - secret name for application credential + displayName: Application Credential Secret + path: ceilometer.auth.applicationCredentialSecret - description: Enabled - Whether OpenStack Ceilometer service should be deployed and managed displayName: Enabled @@ -108,6 +144,12 @@ spec: - description: TLS - Parameters related to the TLS displayName: TLS path: ceilometer.tls + - description: Auth - authentication settings for keystone integration + displayName: Auth + path: cloudkitty.auth + - description: ApplicationCredentialSecret - secret name for application credential + displayName: Application Credential Secret + path: cloudkitty.auth.applicationCredentialSecret - description: TLS - Parameters related to the TLS displayName: TLS path: cloudkitty.cloudKittyAPI.tls diff --git a/config/samples/telemetry_v1beta1_autoscaling.yaml b/config/samples/telemetry_v1beta1_autoscaling.yaml index 4d51cf6be..bb5501762 100644 --- a/config/samples/telemetry_v1beta1_autoscaling.yaml +++ b/config/samples/telemetry_v1beta1_autoscaling.yaml @@ -15,3 +15,5 @@ spec: databaseAccount: aodh databaseInstance: openstack memcachedInstance: memcached + notificationsBus: + cluster: rabbitmq # Required for receiving notifications from OpenStack services diff --git a/config/samples/telemetry_v1beta1_autoscaling_tls.yaml b/config/samples/telemetry_v1beta1_autoscaling_tls.yaml index fd176421e..e404c1cf2 100644 --- a/config/samples/telemetry_v1beta1_autoscaling_tls.yaml +++ b/config/samples/telemetry_v1beta1_autoscaling_tls.yaml @@ -15,6 +15,8 @@ spec: databaseAccount: aodh databaseInstance: openstack memcachedInstance: memcached + notificationsBus: + cluster: rabbitmq # Required for receiving notifications from OpenStack services tls: api: internal: diff --git a/config/samples/telemetry_v1beta1_ceilometer.yaml b/config/samples/telemetry_v1beta1_ceilometer.yaml index fc1b573db..9ff8d37ca 100644 --- a/config/samples/telemetry_v1beta1_ceilometer.yaml +++ b/config/samples/telemetry_v1beta1_ceilometer.yaml @@ -5,3 +5,5 @@ metadata: namespace: openstack spec: secret: osp-secret + notificationsBus: + cluster: rabbitmq # Required for receiving notifications from OpenStack services diff --git a/config/samples/telemetry_v1beta1_ceilometer_tls.yaml b/config/samples/telemetry_v1beta1_ceilometer_tls.yaml index 75629ff2b..53fb40e15 100644 --- a/config/samples/telemetry_v1beta1_ceilometer_tls.yaml +++ b/config/samples/telemetry_v1beta1_ceilometer_tls.yaml @@ -5,6 +5,8 @@ metadata: namespace: openstack spec: secret: osp-secret + notificationsBus: + cluster: rabbitmq # Required for receiving notifications from OpenStack services tls: caBundleSecretName: combined-ca-bundle secretName: cert-ceilometer-internal-svc diff --git a/config/samples/telemetry_v1beta1_telemetry.yaml b/config/samples/telemetry_v1beta1_telemetry.yaml index b67789d8c..55a0a9ec5 100644 --- a/config/samples/telemetry_v1beta1_telemetry.yaml +++ b/config/samples/telemetry_v1beta1_telemetry.yaml @@ -21,10 +21,14 @@ spec: databaseInstance: openstack memcachedInstance: memcached secret: osp-secret + notificationsBus: + cluster: rabbitmq # Required for receiving notifications from OpenStack services heatInstance: heat ceilometer: enabled: true secret: osp-secret + notificationsBus: + cluster: rabbitmq # Required for receiving notifications from OpenStack services logging: enabled: false port: 10514 diff --git a/config/samples/telemetry_v1beta1_telemetry_tls.yaml b/config/samples/telemetry_v1beta1_telemetry_tls.yaml index 6722aacaa..3553e2c2f 100644 --- a/config/samples/telemetry_v1beta1_telemetry_tls.yaml +++ b/config/samples/telemetry_v1beta1_telemetry_tls.yaml @@ -24,6 +24,8 @@ spec: databaseInstance: openstack memcachedInstance: memcached secret: osp-secret + notificationsBus: + cluster: rabbitmq # Required for receiving notifications from OpenStack services tls: api: internal: @@ -35,6 +37,8 @@ spec: ceilometer: enabled: true secret: osp-secret + notificationsBus: + cluster: rabbitmq # Required for receiving notifications from OpenStack services tls: caBundleSecretName: combined-ca-bundle secretName: cert-ceilometer-internal-svc diff --git a/config/samples/telemetry_v1beta1_telemetry_topology.yaml b/config/samples/telemetry_v1beta1_telemetry_topology.yaml index acdb3c95c..6375db675 100644 --- a/config/samples/telemetry_v1beta1_telemetry_topology.yaml +++ b/config/samples/telemetry_v1beta1_telemetry_topology.yaml @@ -23,10 +23,14 @@ spec: databaseInstance: openstack memcachedInstance: memcached secret: osp-secret + notificationsBus: + cluster: rabbitmq # Required for receiving notifications from OpenStack services heatInstance: heat ceilometer: enabled: true secret: osp-secret + notificationsBus: + cluster: rabbitmq # Required for receiving notifications from OpenStack services logging: enabled: false port: 10514 diff --git a/go.sum b/go.sum index 6d36bc127..8cffc5630 100644 --- a/go.sum +++ b/go.sum @@ -105,31 +105,12 @@ github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWu github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -<<<<<<< HEAD -github.com/onsi/ginkgo/v2 v2.27.3 h1:ICsZJ8JoYafeXFFlFAG75a7CxMsJHwgKwtO+82SE9L8= -github.com/onsi/ginkgo/v2 v2.27.3/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo= -======= github.com/onsi/ginkgo/v2 v2.27.4 h1:fcEcQW/A++6aZAZQNUmNjvA9PSOzefMJBerHJ4t8v8Y= github.com/onsi/ginkgo/v2 v2.27.4/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo= ->>>>>>> f2528a7 (Rabbitmq vhost and user support) github.com/onsi/gomega v1.39.0 h1:y2ROC3hKFmQZJNFeGAMeHZKkjBL65mIZcvrLQBF9k6Q= github.com/onsi/gomega v1.39.0/go.mod h1:ZCU1pkQcXDO5Sl9/VVEGlDyp+zm0m1cmeG5TOzLgdh4= github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e h1:E1OdwSpqWuDPCedyUt0GEdoAE+r5TXy7YS21yNEo+2U= github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo= -<<<<<<< HEAD -github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20260105161809-cf030b344d79 h1:KxkelBuKUkKWfa37nQsTNcmGvJ7Jfl51LIYHlDeKh3Y= -github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20260105161809-cf030b344d79/go.mod h1:LM4ZO7tDrBZQWTQlyUAOSaDEaIRWVtWwcGMFWHYDlFQ= -github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260108154501-11e5091cddf1 h1:zAbZVtpldi1TU/CO9aU2ZByzcsi+N3aIv6snpSjBVLY= -github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260108154501-11e5091cddf1/go.mod h1:ZXwFlspJCdZEUjMbmaf61t5AMB4u2vMyAMMoe/vJroE= -github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20260120112029-cd452f0497ba h1:4VaDkZFawGCkzwvfijnFLz0Gduxh17buj9fIwk0WULo= -github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20260120112029-cd452f0497ba/go.mod h1:xqvebn9DqLavxp2z8Rz/7i1S6M9MJhxmZVHC+S1uHX0= -github.com/openstack-k8s-operators/lib-common/modules/ansible v0.6.1-0.20251230215914-6ba873b49a35 h1:TNEUTF0Yj8qmIRgUppbzH0MuYtVcgT4+EdMdTYP/kI0= -github.com/openstack-k8s-operators/lib-common/modules/ansible v0.6.1-0.20251230215914-6ba873b49a35/go.mod h1:tXxVkkk8HlATwTmDA5RTP3b+c8apfuMM15mZ2wW5iNs= -github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.6.1-0.20251230215914-6ba873b49a35 h1:087A4QSgeXtTLrAkI5lRZhyrOxp9bRM0ivjhcwSQUUg= -github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.6.1-0.20251230215914-6ba873b49a35/go.mod h1:DXZa8jn1R4GNDNBvKJhOFEFjg/6v8TRu9J1AHKj5TJc= -github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251230215914-6ba873b49a35 h1:pF3mJ3nwq6r4qwom+rEWZNquZpcQW/iftHlJ1KPIDsk= -github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20251230215914-6ba873b49a35/go.mod h1:kycZyoe7OZdW1HUghr2nI3N7wSJtNahXf6b/ypD14f4= -======= github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20260126095359-39e97ca5471e h1:0bCc5n4IBF2vkb7bh+xU+eXHFLYlyrzGBDQYjzwhm0g= github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20260126095359-39e97ca5471e/go.mod h1:NQxR8xE2FtkWS5rY4cZ0rLGWqme6p7UCg8MCrSiv1C0= github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260126091827-7758173fbb09 h1:vhAGLKZitJIffj7ONiPpKmOX7Tmt/LGJpaY0Z2LeyfQ= @@ -142,7 +123,6 @@ github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.6.1-0.20260 github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.6.1-0.20260126081203-efc2df9207eb/go.mod h1:chsg6x4P7376/8MlmsC3OiasuDatbOLwC5D5KRD9fbo= github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260126081203-efc2df9207eb h1:S7tnYO/E1f1KQfcp7N5bam8+ax/ExDTOhZ1WqG4Bfu0= github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260126081203-efc2df9207eb/go.mod h1:ndqfy1KbVorHH6+zlUFPIrCRhMSxO3ImYJUGaooE0x0= ->>>>>>> f2528a7 (Rabbitmq vhost and user support) github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20251230215914-6ba873b49a35 h1:IdcI8DFvW8rXtchONSzbDmhhRp1YyO2YaBJDBXr44Gk= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20251230215914-6ba873b49a35/go.mod h1:zOX7Y05keiSppIvLabuyh42QHBMhCcoskAtxFRbwXKo= github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20251230215914-6ba873b49a35 h1:8WZYfCt1VJHa5sJRX0UhpmoXud/fn8LHQhXsakdYXuQ= diff --git a/internal/ceilometer/const.go b/internal/ceilometer/const.go index 6a86af3bd..68c3d8cf5 100644 --- a/internal/ceilometer/const.go +++ b/internal/ceilometer/const.go @@ -16,10 +16,6 @@ limitations under the License. // Package ceilometer provides functionality for managing OpenStack Ceilometer telemetry components package ceilometer -import ( - condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" -) - const ( // ServiceName - ServiceName = "ceilometer" @@ -41,16 +37,4 @@ const ( // CeilometerUserID - CeilometerUserID = 42405 - - // CeilometerNotificationBusReadyCondition Status=True condition indicates if the RabbitMQ NotificationsBus TransportURL is configured - CeilometerNotificationBusReadyCondition condition.Type = "CeilometerNotificationBusReady" - - // CeilometerNotificationBusReadyMessage is the message for CeilometerNotificationBusReady condition - CeilometerNotificationBusReadyMessage = "NotificationsBus TransportURL successfully created" - - // CeilometerNotificationBusReadyRunningMessage is the message for CeilometerNotificationBusReady running state - CeilometerNotificationBusReadyRunningMessage = "NotificationsBus TransportURL creation in progress" - - // CeilometerNotificationBusReadyErrorMessage is the message for CeilometerNotificationBusReady error state - CeilometerNotificationBusReadyErrorMessage = "NotificationsBus TransportURL error occured %s" ) diff --git a/internal/controller/autoscaling_controller.go b/internal/controller/autoscaling_controller.go index bb1dd8c22..d76540512 100644 --- a/internal/controller/autoscaling_controller.go +++ b/internal/controller/autoscaling_controller.go @@ -18,6 +18,7 @@ package controller import ( "context" + "errors" "fmt" "maps" "strconv" @@ -67,6 +68,9 @@ import ( autoscaling "github.com/openstack-k8s-operators/telemetry-operator/internal/autoscaling" ) +// ErrNotificationsURLSecretNotSet is returned when NotificationsURLSecret is not set in the instance status +var ErrNotificationsURLSecretNotSet = errors.New("NotificationsURLSecret is not set") + // AutoscalingReconciler reconciles a Autoscaling object type AutoscalingReconciler struct { client.Client @@ -730,7 +734,7 @@ func (r *AutoscalingReconciler) generateServiceConfig( // Ensure NotificationsURLSecret is not nil before dereferencing if instance.Status.NotificationsURLSecret == nil { - return fmt.Errorf("NotificationsURLSecret is not set") + return ErrNotificationsURLSecretNotSet } transportURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) diff --git a/internal/controller/ceilometer_controller.go b/internal/controller/ceilometer_controller.go index d31067969..c35c2e7c8 100644 --- a/internal/controller/ceilometer_controller.go +++ b/internal/controller/ceilometer_controller.go @@ -541,10 +541,10 @@ func (r *CeilometerReconciler) reconcileCeilometer( notificationBusInstanceURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels, instance.Spec.NotificationsBus) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( - ceilometer.CeilometerNotificationBusReadyCondition, + condition.NotificationBusInstanceReadyCondition, condition.ErrorReason, condition.SeverityWarning, - ceilometer.CeilometerNotificationBusReadyErrorMessage, + condition.NotificationBusInstanceReadyErrorMessage, err.Error())) return ctrl.Result{}, err } @@ -558,14 +558,14 @@ func (r *CeilometerReconciler) reconcileCeilometer( if instance.Status.NotificationsURLSecret == nil || *instance.Status.NotificationsURLSecret == "" { Log.Info(fmt.Sprintf("Waiting for NotificationBusInstanceURL %s secret to be created", notificationBusInstanceURL.Name)) instance.Status.Conditions.Set(condition.FalseCondition( - ceilometer.CeilometerNotificationBusReadyCondition, + condition.NotificationBusInstanceReadyCondition, condition.RequestedReason, condition.SeverityInfo, - ceilometer.CeilometerNotificationBusReadyRunningMessage)) + condition.NotificationBusInstanceReadyRunningMessage)) return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil } - instance.Status.Conditions.MarkTrue(ceilometer.CeilometerNotificationBusReadyCondition, ceilometer.CeilometerNotificationBusReadyMessage) + instance.Status.Conditions.MarkTrue(condition.NotificationBusInstanceReadyCondition, condition.NotificationBusInstanceReadyMessage) // end notificationsBus // @@ -1252,7 +1252,7 @@ func (r *CeilometerReconciler) generateServiceConfig( // Ensure NotificationsURLSecret is not nil before dereferencing if instance.Status.NotificationsURLSecret == nil { - return fmt.Errorf("NotificationsURLSecret is not set") + return ErrNotificationsURLSecretNotSet } transportURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) @@ -1377,7 +1377,7 @@ func (r *CeilometerReconciler) generateComputeServiceConfig( // Ensure NotificationsURLSecret is not nil before dereferencing if instance.Status.NotificationsURLSecret == nil { - return fmt.Errorf("NotificationsURLSecret is not set") + return ErrNotificationsURLSecretNotSet } transportURLSecret, _, err := secret.GetSecret(ctx, h, *instance.Status.NotificationsURLSecret, instance.Namespace) diff --git a/test/kuttl/tests/autoscaling/01-deploy.yaml b/test/kuttl/tests/autoscaling/01-deploy.yaml index 26580dfe6..e25efe5e0 100644 --- a/test/kuttl/tests/autoscaling/01-deploy.yaml +++ b/test/kuttl/tests/autoscaling/01-deploy.yaml @@ -9,4 +9,6 @@ spec: databaseAccount: aodh databaseInstance: openstack memcachedInstance: memcached + notificationsBus: + cluster: rabbitmq heatInstance: heat diff --git a/test/kuttl/tests/autoscaling/02-custom-config-secret.yaml b/test/kuttl/tests/autoscaling/02-custom-config-secret.yaml index e94eb2c51..52a58c7ea 100644 --- a/test/kuttl/tests/autoscaling/02-custom-config-secret.yaml +++ b/test/kuttl/tests/autoscaling/02-custom-config-secret.yaml @@ -20,4 +20,6 @@ spec: databaseAccount: aodh databaseInstance: openstack memcachedInstance: memcached + notificationsBus: + cluster: rabbitmq heatInstance: heat diff --git a/test/kuttl/tests/autoscaling/deps/OpenStackControlPlane.yaml b/test/kuttl/tests/autoscaling/deps/OpenStackControlPlane.yaml index 6210b48b1..b768a695a 100644 --- a/test/kuttl/tests/autoscaling/deps/OpenStackControlPlane.yaml +++ b/test/kuttl/tests/autoscaling/deps/OpenStackControlPlane.yaml @@ -33,3 +33,5 @@ spec: heatEngine: replicas: 1 secret: osp-secret + notificationsBus: + cluster: rabbitmq diff --git a/test/kuttl/tests/ceilometer/00-deploy.yaml b/test/kuttl/tests/ceilometer/00-deploy.yaml index bd8e16524..8c12e82b7 100644 --- a/test/kuttl/tests/ceilometer/00-deploy.yaml +++ b/test/kuttl/tests/ceilometer/00-deploy.yaml @@ -6,3 +6,5 @@ spec: secret: osp-secret mysqldExporterEnabled: true ksmEnabled: true + notificationsBus: + cluster: rabbitmq diff --git a/test/kuttl/tests/ceilometer/01-custom-config-secret.yaml b/test/kuttl/tests/ceilometer/01-custom-config-secret.yaml index 913719ef6..1460dc6e9 100644 --- a/test/kuttl/tests/ceilometer/01-custom-config-secret.yaml +++ b/test/kuttl/tests/ceilometer/01-custom-config-secret.yaml @@ -15,3 +15,5 @@ metadata: spec: customConfigsSecretName: custom-config secret: osp-secret + notificationsBus: + cluster: rabbitmq diff --git a/test/kuttl/tests/default/01-deploy.yaml b/test/kuttl/tests/default/01-deploy.yaml index 18e35fb34..4d07a804e 100644 --- a/test/kuttl/tests/default/01-deploy.yaml +++ b/test/kuttl/tests/default/01-deploy.yaml @@ -21,10 +21,14 @@ spec: databaseAccount: aodh databaseInstance: openstack memcachedInstance: memcached + notificationsBus: + cluster: rabbitmq heatInstance: heat ceilometer: enabled: true secret: osp-secret + notificationsBus: + cluster: rabbitmq cloudkitty: enabled: true s3StorageConfig: diff --git a/test/kuttl/tests/default/deps/OpenStackControlPlane.yaml b/test/kuttl/tests/default/deps/OpenStackControlPlane.yaml index 6210b48b1..b768a695a 100644 --- a/test/kuttl/tests/default/deps/OpenStackControlPlane.yaml +++ b/test/kuttl/tests/default/deps/OpenStackControlPlane.yaml @@ -33,3 +33,5 @@ spec: heatEngine: replicas: 1 secret: osp-secret + notificationsBus: + cluster: rabbitmq diff --git a/test/kuttl/tests/metricstorage/01-deploy.yaml b/test/kuttl/tests/metricstorage/01-deploy.yaml index f16d5a42f..11d2f67fa 100644 --- a/test/kuttl/tests/metricstorage/01-deploy.yaml +++ b/test/kuttl/tests/metricstorage/01-deploy.yaml @@ -22,3 +22,5 @@ metadata: spec: secret: osp-secret mysqldExporterEnabled: true + notificationsBus: + cluster: rabbitmq diff --git a/test/kuttl/tests/tls/02-deploy.yaml b/test/kuttl/tests/tls/02-deploy.yaml index 89c94a656..3cdf2180a 100644 --- a/test/kuttl/tests/tls/02-deploy.yaml +++ b/test/kuttl/tests/tls/02-deploy.yaml @@ -13,6 +13,8 @@ spec: databaseAccount: aodh databaseInstance: openstack memcachedInstance: memcached + notificationsBus: + cluster: rabbitmq tls: api: internal: @@ -28,6 +30,8 @@ metadata: name: telemetry-kuttl-ceilometer spec: secret: osp-secret + notificationsBus: + cluster: rabbitmq tls: caBundleSecretName: combined-ca-bundle secretName: cert-ceilometer-internal-svc diff --git a/test/kuttl/tests/tls/deps/OpenStackControlPlane.yaml b/test/kuttl/tests/tls/deps/OpenStackControlPlane.yaml index 6210b48b1..b768a695a 100644 --- a/test/kuttl/tests/tls/deps/OpenStackControlPlane.yaml +++ b/test/kuttl/tests/tls/deps/OpenStackControlPlane.yaml @@ -33,3 +33,5 @@ spec: heatEngine: replicas: 1 secret: osp-secret + notificationsBus: + cluster: rabbitmq diff --git a/test/kuttl/tests/topology/01-deploy.yaml b/test/kuttl/tests/topology/01-deploy.yaml index 0178f9342..94239f4e2 100644 --- a/test/kuttl/tests/topology/01-deploy.yaml +++ b/test/kuttl/tests/topology/01-deploy.yaml @@ -23,12 +23,16 @@ spec: databaseAccount: aodh databaseInstance: openstack memcachedInstance: memcached + notificationsBus: + cluster: rabbitmq heatInstance: heat ceilometer: enabled: true secret: osp-secret mysqldExporterEnabled: true ksmEnabled: true + notificationsBus: + cluster: rabbitmq cloudkitty: enabled: true s3StorageConfig: diff --git a/test/kuttl/tests/topology/deps/OpenStackControlPlane.yaml b/test/kuttl/tests/topology/deps/OpenStackControlPlane.yaml index 6210b48b1..b768a695a 100644 --- a/test/kuttl/tests/topology/deps/OpenStackControlPlane.yaml +++ b/test/kuttl/tests/topology/deps/OpenStackControlPlane.yaml @@ -33,3 +33,5 @@ spec: heatEngine: replicas: 1 secret: osp-secret + notificationsBus: + cluster: rabbitmq