From b5938ce90f05168d4e4c7672f9f049a34d8e166b Mon Sep 17 00:00:00 2001 From: Bohdan Dobrelia Date: Thu, 27 Mar 2025 16:27:16 +0100 Subject: [PATCH] Add Notfications message bus instance for Nova CRD Extend CRDs to support a RabbitMqCluster reference as AMQP instance for notifications. To provide a way for human user to define the notifications bus for Nova CR via the OpenStackControlPlane CR's nova section, add a new field to the NovaSpecCore as that is the struct used when the OpenStackControlPlaneSpec struct is defined. At NovaSpec level having just "" or a name of the bus is OK as either we need a bus, or we don't need notifications at all. However, for empedded NovaSpecCore we might need the 3rd possibility to "inherit from somewhere higher", which we represent as: *string field where null means inherit, "" means disable notification, "foo" means send notification to bus foo. Note that overriding NotificationsBusInstance for cells is not supported as that implies that consumers of notifications can maintain simultanous AMQP connections via multiple transport_url endpoints, which is not a thing in Openstack. Assume that in the implementation the required information will be transferred via the existing internal secret via notifications specific transport_url key (as the transport_url key is already taken by the RPC bus value). Thus we do not modify other Nova services' CRDs. Note that the pointer type is redundant for NovaSpec, but since we have already defined it as a such in NovaSpecCore, and changing the types system is not planned (requires changes in openstack operator), it should be used as is for also NovaSpec. However there shall be only a real use of a nil value in NovaSpecCore (while unused in NovaSpec). Signed-off-by: Bohdan Dobrelia --- api/bases/nova.openstack.org_nova.yaml | 9 +++++++++ api/v1beta1/nova_types.go | 13 ++++++++++++- api/v1beta1/novacell_types.go | 2 +- api/v1beta1/zz_generated.deepcopy.go | 5 +++++ config/crd/bases/nova.openstack.org_nova.yaml | 9 +++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/api/bases/nova.openstack.org_nova.yaml b/api/bases/nova.openstack.org_nova.yaml index 0b44d0323..f449820b2 100644 --- a/api/bases/nova.openstack.org_nova.yaml +++ b/api/bases/nova.openstack.org_nova.yaml @@ -1624,6 +1624,15 @@ spec: NodeSelector here acts as a default value and can be overridden by service specific NodeSelector Settings. type: object + notificationsBusInstance: + description: |- + NotificationsBusInstance is the name of the RabbitMqCluster CR to select + the Message Bus Service instance used by the Nova top level services and all cells to publish notifications. + If undefined, the value will be inherited from OpenStackControlPlane. + An empty value "" leaves the notification drivers unconfigured and emitting no notifications at all. + Avoid colocating it with RabbitMqClusterName, APIMessageBusInstance or CellMessageBusInstance used for RPC. + For particular Nova cells, notifications cannot be disabled, nor configured differently. + type: string novncproxyContainerImageURL: description: NoVNCContainerImageURL type: string diff --git a/api/v1beta1/nova_types.go b/api/v1beta1/nova_types.go index 75ee72468..53b864da9 100644 --- a/api/v1beta1/nova_types.go +++ b/api/v1beta1/nova_types.go @@ -17,9 +17,9 @@ limitations under the License. package v1beta1 import ( + topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1" condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1" ) // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! @@ -122,10 +122,21 @@ type NovaSpecCore struct { // TopologyRef to apply the Topology defined by the associated CR referenced // by name TopologyRef *topologyv1.TopoRef `json:"topologyRef,omitempty"` + + // +kubebuilder:validation:Optional + // NotificationsBusInstance is the name of the RabbitMqCluster CR to select + // the Message Bus Service instance used by the Nova top level services and all cells to publish notifications. + // If undefined, the value will be inherited from OpenStackControlPlane. + // An empty value "" leaves the notification drivers unconfigured and emitting no notifications at all. + // Avoid colocating it with RabbitMqClusterName, APIMessageBusInstance or CellMessageBusInstance used for RPC. + // For particular Nova cells, notifications cannot be disabled, nor configured differently. + NotificationsBusInstance *string `json:"notificationsBusInstance,omitempty"` } // NovaSpec defines the desired state of Nova type NovaSpec struct { + // NOTE(bogdando): Anything that is only submitted by opentack-operator should be in NovaSpec but not in NovaSpecCore. + // +kubebuilder:validation:Required NovaSpecCore `json:",inline"` diff --git a/api/v1beta1/novacell_types.go b/api/v1beta1/novacell_types.go index 1269a4b95..23c5d6214 100644 --- a/api/v1beta1/novacell_types.go +++ b/api/v1beta1/novacell_types.go @@ -17,10 +17,10 @@ limitations under the License. package v1beta1 import ( + 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" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1" ) // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index b1a79c985..e493aca03 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -1686,6 +1686,11 @@ func (in *NovaSpecCore) DeepCopyInto(out *NovaSpecCore) { *out = new(topologyv1beta1.TopoRef) **out = **in } + if in.NotificationsBusInstance != nil { + in, out := &in.NotificationsBusInstance, &out.NotificationsBusInstance + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NovaSpecCore. diff --git a/config/crd/bases/nova.openstack.org_nova.yaml b/config/crd/bases/nova.openstack.org_nova.yaml index 0b44d0323..f449820b2 100644 --- a/config/crd/bases/nova.openstack.org_nova.yaml +++ b/config/crd/bases/nova.openstack.org_nova.yaml @@ -1624,6 +1624,15 @@ spec: NodeSelector here acts as a default value and can be overridden by service specific NodeSelector Settings. type: object + notificationsBusInstance: + description: |- + NotificationsBusInstance is the name of the RabbitMqCluster CR to select + the Message Bus Service instance used by the Nova top level services and all cells to publish notifications. + If undefined, the value will be inherited from OpenStackControlPlane. + An empty value "" leaves the notification drivers unconfigured and emitting no notifications at all. + Avoid colocating it with RabbitMqClusterName, APIMessageBusInstance or CellMessageBusInstance used for RPC. + For particular Nova cells, notifications cannot be disabled, nor configured differently. + type: string novncproxyContainerImageURL: description: NoVNCContainerImageURL type: string