@@ -25,6 +25,7 @@ package v1beta1
2525import (
2626 "fmt"
2727
28+ rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
2829 topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
2930 "github.com/openstack-k8s-operators/lib-common/modules/common/service"
3031 "github.com/openstack-k8s-operators/lib-common/modules/common/util"
@@ -101,6 +102,18 @@ func (spec *ManilaSpec) Default() {
101102
102103// Default - set defaults for this Manila spec base
103104func (spec * ManilaSpecBase ) Default () {
105+ // Default MessagingBus with cluster name from RabbitMqClusterName
106+ rabbitmqv1 .DefaultRabbitMqConfig (& spec .MessagingBus , spec .RabbitMqClusterName )
107+
108+ // Default NotificationsBus if NotificationsBusInstance is specified
109+ if spec .NotificationsBusInstance != nil && * spec .NotificationsBusInstance != "" {
110+ if spec .NotificationsBus == nil {
111+ // Initialize empty NotificationsBus - credentials will be created dynamically
112+ // to ensure separation from MessagingBus (RPC and notifications should never share credentials)
113+ spec .NotificationsBus = & rabbitmqv1.RabbitMqConfig {}
114+ }
115+ rabbitmqv1 .DefaultRabbitMqConfig (spec .NotificationsBus , * spec .NotificationsBusInstance )
116+ }
104117
105118 if spec .APITimeout == 0 {
106119 spec .APITimeout = manilaDefaults .APITimeout
@@ -200,6 +213,21 @@ func (r *Manila) ValidateUpdate(old runtime.Object) (admission.Warnings, error)
200213func (spec * ManilaSpec ) ValidateUpdate (old ManilaSpec , basePath * field.Path , namespace string ) field.ErrorList {
201214 var allErrs field.ErrorList
202215
216+ // Reject changes to deprecated RabbitMqClusterName field - users should use the new messagingBus.cluster field instead
217+ if spec .RabbitMqClusterName != old .RabbitMqClusterName {
218+ allErrs = append (allErrs , field .Forbidden (
219+ basePath .Child ("rabbitMqClusterName" ),
220+ "rabbitMqClusterName is deprecated and cannot be changed. Please use messagingBus.cluster instead" ))
221+ }
222+
223+ // Reject changes to deprecated NotificationsBusInstance field
224+ if spec .NotificationsBusInstance != nil && old .NotificationsBusInstance != nil &&
225+ * spec .NotificationsBusInstance != * old .NotificationsBusInstance {
226+ allErrs = append (allErrs , field .Forbidden (
227+ basePath .Child ("notificationsBusInstance" ),
228+ "notificationsBusInstance is deprecated and cannot be changed. Please use notificationsBus.cluster instead" ))
229+ }
230+
203231 // validate the service base parameters
204232 allErrs = append (allErrs , spec .ValidateBaseParams (basePath )... )
205233
@@ -217,6 +245,21 @@ func (spec *ManilaSpec) ValidateUpdate(old ManilaSpec, basePath *field.Path, nam
217245func (spec * ManilaSpecCore ) ValidateUpdate (old ManilaSpecCore , basePath * field.Path , namespace string ) field.ErrorList {
218246 var allErrs field.ErrorList
219247
248+ // Reject changes to deprecated RabbitMqClusterName field - users should use the new messagingBus.cluster field instead
249+ if spec .RabbitMqClusterName != old .RabbitMqClusterName {
250+ allErrs = append (allErrs , field .Forbidden (
251+ basePath .Child ("rabbitMqClusterName" ),
252+ "rabbitMqClusterName is deprecated and cannot be changed. Please use messagingBus.cluster instead" ))
253+ }
254+
255+ // Reject changes to deprecated NotificationsBusInstance field
256+ if spec .NotificationsBusInstance != nil && old .NotificationsBusInstance != nil &&
257+ * spec .NotificationsBusInstance != * old .NotificationsBusInstance {
258+ allErrs = append (allErrs , field .Forbidden (
259+ basePath .Child ("notificationsBusInstance" ),
260+ "notificationsBusInstance is deprecated and cannot be changed. Please use notificationsBus.cluster instead" ))
261+ }
262+
220263 // validate the service base parameters
221264 allErrs = append (allErrs , spec .ValidateBaseParams (basePath )... )
222265
0 commit comments