@@ -26,6 +26,7 @@ import (
2626 "fmt"
2727
2828 "github.com/google/go-cmp/cmp"
29+ rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
2930 service "github.com/openstack-k8s-operators/lib-common/modules/common/service"
3031 "github.com/robfig/cron/v3"
3132
@@ -88,6 +89,24 @@ func (spec *NovaSpecCore) Default() {
8889 spec .APITimeout = novaDefaults .APITimeout
8990 }
9091
92+ // Default MessagingBus.Cluster from APIMessageBusInstance if not already set
93+ if spec .MessagingBus .Cluster == "" {
94+ spec .MessagingBus .Cluster = spec .APIMessageBusInstance
95+ }
96+
97+ // Default NotificationsBus if NotificationsBusInstance is specified
98+ if spec .NotificationsBusInstance != nil && * spec .NotificationsBusInstance != "" {
99+ if spec .NotificationsBus == nil {
100+ // Initialize empty NotificationsBus - credentials will be created dynamically
101+ // to ensure separation from MessagingBus (RPC and notifications should never share credentials)
102+ spec .NotificationsBus = & rabbitmqv1.RabbitMqConfig {}
103+ }
104+ // Default cluster name if not already set
105+ if spec .NotificationsBus .Cluster == "" {
106+ spec .NotificationsBus .Cluster = * spec .NotificationsBusInstance
107+ }
108+ }
109+
91110 for cellName , cellTemplate := range spec .CellTemplates {
92111
93112 if cellTemplate .MetadataServiceTemplate .Enabled == nil {
@@ -106,6 +125,11 @@ func (spec *NovaSpecCore) Default() {
106125 }
107126 }
108127
128+ // Default MessagingBus.Cluster from CellMessageBusInstance if not already set
129+ if cellTemplate .MessagingBus .Cluster == "" {
130+ cellTemplate .MessagingBus .Cluster = cellTemplate .CellMessageBusInstance
131+ }
132+
109133 // "cellTemplate" is a by-value copy, so we need to re-inject the updated version of it into the map
110134 spec .CellTemplates [cellName ] = cellTemplate
111135 }
@@ -315,7 +339,34 @@ func (spec *NovaSpec) ValidateUpdate(old NovaSpec, basePath *field.Path, namespa
315339// expected to be called by the validation webhook in the higher level meta
316340// operator
317341func (spec * NovaSpecCore ) ValidateUpdate (old NovaSpecCore , basePath * field.Path , namespace string ) field.ErrorList {
318- errors := spec .ValidateCellTemplates (basePath , namespace )
342+ var errors field.ErrorList
343+
344+ // Reject changes to deprecated messagingBusInstance fields - users should use the new messagingBus fields instead
345+ if spec .APIMessageBusInstance != old .APIMessageBusInstance {
346+ errors = append (errors , field .Forbidden (
347+ basePath .Child ("apiMessageBusInstance" ),
348+ "apiMessageBusInstance is deprecated and cannot be changed. Please use messagingBus.cluster instead" ))
349+ }
350+
351+ if spec .NotificationsBusInstance != nil && old .NotificationsBusInstance != nil &&
352+ * spec .NotificationsBusInstance != * old .NotificationsBusInstance {
353+ errors = append (errors , field .Forbidden (
354+ basePath .Child ("notificationsBusInstance" ),
355+ "notificationsBusInstance is deprecated and cannot be changed. Please use notificationsBus.cluster instead" ))
356+ }
357+
358+ // Check cell template changes
359+ for cellName , cellTemplate := range spec .CellTemplates {
360+ if oldCell , exists := old .CellTemplates [cellName ]; exists {
361+ if cellTemplate .CellMessageBusInstance != oldCell .CellMessageBusInstance {
362+ errors = append (errors , field .Forbidden (
363+ basePath .Child ("cellTemplates" ).Key (cellName ).Child ("cellMessageBusInstance" ),
364+ "cellMessageBusInstance is deprecated and cannot be changed. Please use messagingBus.cluster instead" ))
365+ }
366+ }
367+ }
368+
369+ errors = append (errors , spec .ValidateCellTemplates (basePath , namespace )... )
319370 // Validate top-level TopologyRef
320371 errors = append (errors , topologyv1 .ValidateTopologyRef (
321372 spec .TopologyRef , * basePath .Child ("topologyRef" ), namespace )... )
0 commit comments