Skip to content

Commit b9b1944

Browse files
committed
DNM draft implementation of common notifications
Signed-off-by: Bohdan Dobrelia <bdobreli@redhat.com>
1 parent 0ba95b9 commit b9b1944

11 files changed

Lines changed: 160 additions & 57 deletions

‎apis/bases/core.openstack.org_openstackcontrolplanes.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9018,6 +9018,7 @@ spec:
90189018
notificationsBus:
90199019
properties:
90209020
rabbitMqClusterName:
9021+
default: rabbitmq
90219022
type: string
90229023
type: object
90239024
nova:
@@ -9980,6 +9981,8 @@ spec:
99809981
additionalProperties:
99819982
type: string
99829983
type: object
9984+
notificationsBusInstance:
9985+
type: string
99839986
passwordSelectors:
99849987
default:
99859988
service: NovaPassword

‎apis/core/v1beta1/openstackcontrolplane_types.go‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,15 +498,14 @@ type RabbitmqSection struct {
498498
// NotificationsBusSection defines the desired state of AMQP messaging Bus Services for producers and consumers of notifications
499499
type NotificationsBusSection struct {
500500
// +kubebuilder:validation:Optional
501+
// +kubebuilder:default=rabbitmq
501502
// The name of RabbitMQ Cluster CR to select a Messaging
502503
// Bus Service instance used by all services that produce or consume notifications.
503504
// Avoid colocating it with RabbitMQ services used for PRC.
504505
// That instance will be pushed down for services, unless overriden in templates.
505-
// An empty value disables notifications drivers, and makes the services emitting no notifications at all.
506-
// When undefined, no configuration will be pushed down for services, which provides backward compatibility during upgrades,
507-
// and leaves a possibility for services to override the configuration, stick with its default behavior, or disable notifications only for itself.
506+
// TODO: An empty value disables notifications drivers, and makes the services emitting no notifications at all.
508507
// Services that support this global configuration interface include: Nova
509-
RabbitMqClusterName *string `json:"rabbitMqClusterName,omitempty"`
508+
RabbitMqClusterName string `json:"rabbitMqClusterName"`
510509
}
511510

512511
// MemcachedSection defines the desired state of Memcached services

‎apis/core/v1beta1/zz_generated.deepcopy.go‎

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bindata/crds/crds.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9181,7 +9181,8 @@ spec:
91819181
type: object
91829182
notificationsBus:
91839183
properties:
9184-
rabbitMQCluster:
9184+
rabbitMqClusterName:
9185+
default: rabbitmq
91859186
type: string
91869187
type: object
91879188
nova:

‎config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9018,6 +9018,7 @@ spec:
90189018
notificationsBus:
90199019
properties:
90209020
rabbitMqClusterName:
9021+
default: rabbitmq
90219022
type: string
90229023
type: object
90239024
nova:
@@ -9980,6 +9981,8 @@ spec:
99809981
additionalProperties:
99819982
type: string
99829983
type: object
9984+
notificationsBusInstance:
9985+
type: string
99839986
passwordSelectors:
99849987
default:
99859988
service: NovaPassword

‎go.mod‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,5 @@ replace github.com/openshift/api => github.com/openshift/api v0.0.0-202408300231
127127

128128
// custom RabbitmqClusterSpecCore for OpenStackControlplane (v2.9.0_patches_tag)
129129
replace github.com/rabbitmq/cluster-operator/v2 => github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20241017142550-a3524acedd49 //allow-merging
130+
131+
replace github.com/openstack-k8s-operators/nova-operator/api => github.com/bogdando/nova-operator/api v0.0.0-20250512104915-dcbaf22bcfbe

‎go.sum‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
22
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
3+
github.com/bogdando/nova-operator/api v0.0.0-20250512104915-dcbaf22bcfbe h1:INWUY8C0WFvzmp/nexxgv2uQeIjPM5iL75CtPvJ9aNY=
4+
github.com/bogdando/nova-operator/api v0.0.0-20250512104915-dcbaf22bcfbe/go.mod h1:NNhtdwoGV4PW+Ca4KwoNM1EaEWFc9Rf4N7T1gz0bNQo=
35
github.com/cert-manager/cert-manager v1.14.7 h1:C2L59sMGMdSpd8SPx5qfPAL7ejZaNxJBRd24S7Ws5Ek=
46
github.com/cert-manager/cert-manager v1.14.7/go.mod h1:0QE/Hzfs2SxNrFFYgFh/d0c0cDfNv9qSrAev2LFt5nM=
57
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
@@ -134,8 +136,6 @@ github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20250415060817-
134136
github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20250415060817-dc849adfa27e/go.mod h1:ZgHSxZSgpgHg1FhKPnBm/cqxAJbVFbKiBkqQoRohn3Q=
135137
github.com/openstack-k8s-operators/neutron-operator/api v0.6.1-0.20250422103409-9ddf83d0f545 h1:m+0pOigO5fx+AynqTxd28XnXwDLYlCx87Elc1Hw7EI0=
136138
github.com/openstack-k8s-operators/neutron-operator/api v0.6.1-0.20250422103409-9ddf83d0f545/go.mod h1:v1HVsDjShu8h/jh/Ql35N0H6icGxfqOtoTJD6+SeWnM=
137-
github.com/openstack-k8s-operators/nova-operator/api v0.6.1-0.20250422095814-99e0f2e04f20 h1:cmou6VfxDe5RE66ZrmwGzozD5TCYkHLCI+PTKf9QiOI=
138-
github.com/openstack-k8s-operators/nova-operator/api v0.6.1-0.20250422095814-99e0f2e04f20/go.mod h1:TV2Q8RsQUj4rFCGJezrSM1MRybPw3zBqdWtBzkuF5WI=
139139
github.com/openstack-k8s-operators/octavia-operator/api v0.6.1-0.20250422141120-3b3a002bcbd6 h1:yhyspgVZ2DiGL4bzHSQepk9OUyk7HDhxKxrHdTBgzns=
140140
github.com/openstack-k8s-operators/octavia-operator/api v0.6.1-0.20250422141120-3b3a002bcbd6/go.mod h1:5p6SbWrnXSKs8sG4plfdXuJ1fGxKQP/kPwBYT5iZbuY=
141141
github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.6.1-0.20250422102839-2ae63e63226d h1:x0nZgS+DNtxmdM5BDfjd4oTJbKu8+dON2iqLIYMY3yI=

‎pkg/openstack/nova.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ func ReconcileNova(ctx context.Context, instance *corev1beta1.OpenStackControlPl
8080
instance.Spec.Nova.Template.TopologyRef = instance.Spec.TopologyRef
8181
}
8282

83+
// When there's no NotificationsBusInstance referenced in the Service Template,
84+
// inject the top-level one.
85+
// TODO(bogdando): extend this to other services as they start supporting this interface
86+
// TODO(bogdando): add webhook validation of the nova's value as an emitter should be matching the consumer's (ceiloneter) value
87+
if instance.Spec.Nova.Template.NotificationsBusInstance == nil {
88+
instance.Spec.Nova.Template.NotificationsBusInstance = ptr.To(instance.Spec.NotificationsBus.RabbitMqClusterName)
89+
}
90+
8391
// When component services got created check if there is the need to create routes and certificates
8492
if err := helper.GetClient().Get(ctx, types.NamespacedName{Name: "nova", Namespace: instance.Namespace}, nova); err != nil {
8593
if !k8s_errors.IsNotFound(err) {

‎tests/functional/ctlplane/base_test.go‎

Lines changed: 57 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -44,47 +44,49 @@ import (
4444
)
4545

4646
type Names struct {
47-
Namespace string
48-
OpenStackControlplaneName types.NamespacedName
49-
OpenStackVersionName types.NamespacedName
50-
KeystoneAPIName types.NamespacedName
51-
MemcachedName types.NamespacedName
52-
MemcachedCertName types.NamespacedName
53-
CinderName types.NamespacedName
54-
ManilaName types.NamespacedName
55-
GlanceName types.NamespacedName
56-
NeutronName types.NamespacedName
57-
HorizonName types.NamespacedName
58-
HeatName types.NamespacedName
59-
TelemetryName types.NamespacedName
60-
DBName types.NamespacedName
61-
DBCertName types.NamespacedName
62-
DBCell1Name types.NamespacedName
63-
DBCell1CertName types.NamespacedName
64-
RabbitMQName types.NamespacedName
65-
RabbitMQCertName types.NamespacedName
66-
RabbitMQCell1Name types.NamespacedName
67-
RabbitMQCell1CertName types.NamespacedName
68-
ServiceAccountName types.NamespacedName
69-
RoleName types.NamespacedName
70-
RoleBindingName types.NamespacedName
71-
RootCAPublicName types.NamespacedName
72-
RootCAInternalName types.NamespacedName
73-
RootCAOvnName types.NamespacedName
74-
RootCALibvirtName types.NamespacedName
75-
SelfSignedIssuerName types.NamespacedName
76-
CustomIssuerName types.NamespacedName
77-
CustomServiceCertSecretName types.NamespacedName
78-
CABundleName types.NamespacedName
79-
OpenStackClientName types.NamespacedName
80-
OVNNorthdName types.NamespacedName
81-
OVNNorthdCertName types.NamespacedName
82-
OVNControllerName types.NamespacedName
83-
OVNControllerCertName types.NamespacedName
84-
OVNDbServerNBName types.NamespacedName
85-
OVNDbServerSBName types.NamespacedName
86-
NeutronOVNCertName types.NamespacedName
87-
OpenStackTopology []types.NamespacedName
47+
Namespace string
48+
OpenStackControlplaneName types.NamespacedName
49+
OpenStackVersionName types.NamespacedName
50+
KeystoneAPIName types.NamespacedName
51+
MemcachedName types.NamespacedName
52+
MemcachedCertName types.NamespacedName
53+
CinderName types.NamespacedName
54+
ManilaName types.NamespacedName
55+
GlanceName types.NamespacedName
56+
NeutronName types.NamespacedName
57+
HorizonName types.NamespacedName
58+
HeatName types.NamespacedName
59+
TelemetryName types.NamespacedName
60+
DBName types.NamespacedName
61+
DBCertName types.NamespacedName
62+
DBCell1Name types.NamespacedName
63+
DBCell1CertName types.NamespacedName
64+
RabbitMQName types.NamespacedName
65+
RabbitMQCertName types.NamespacedName
66+
RabbitMQNotificationsCertName types.NamespacedName
67+
RabbitMQCell1Name types.NamespacedName
68+
RabbitMQCell1CertName types.NamespacedName
69+
RabbitMQNotificationsName types.NamespacedName
70+
ServiceAccountName types.NamespacedName
71+
RoleName types.NamespacedName
72+
RoleBindingName types.NamespacedName
73+
RootCAPublicName types.NamespacedName
74+
RootCAInternalName types.NamespacedName
75+
RootCAOvnName types.NamespacedName
76+
RootCALibvirtName types.NamespacedName
77+
SelfSignedIssuerName types.NamespacedName
78+
CustomIssuerName types.NamespacedName
79+
CustomServiceCertSecretName types.NamespacedName
80+
CABundleName types.NamespacedName
81+
OpenStackClientName types.NamespacedName
82+
OVNNorthdName types.NamespacedName
83+
OVNNorthdCertName types.NamespacedName
84+
OVNControllerName types.NamespacedName
85+
OVNControllerCertName types.NamespacedName
86+
OVNDbServerNBName types.NamespacedName
87+
OVNDbServerSBName types.NamespacedName
88+
NeutronOVNCertName types.NamespacedName
89+
OpenStackTopology []types.NamespacedName
8890
}
8991

9092
func CreateNames(openstackControlplaneName types.NamespacedName) Names {
@@ -192,10 +194,18 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
192194
Namespace: openstackControlplaneName.Namespace,
193195
Name: "cert-rabbitmq-svc",
194196
},
197+
RabbitMQNotificationsCertName: types.NamespacedName{
198+
Namespace: openstackControlplaneName.Namespace,
199+
Name: "cert-rabbitmq-notifications-svc",
200+
},
195201
RabbitMQCell1Name: types.NamespacedName{
196202
Namespace: openstackControlplaneName.Namespace,
197203
Name: "rabbitmq-cell1",
198204
},
205+
RabbitMQNotificationsName: types.NamespacedName{
206+
Namespace: openstackControlplaneName.Namespace,
207+
Name: "rabbitmq-notifications",
208+
},
199209
RabbitMQCell1CertName: types.NamespacedName{
200210
Namespace: openstackControlplaneName.Namespace,
201211
Name: "cert-rabbitmq-cell1-svc",
@@ -484,6 +494,9 @@ func GetDefaultOpenStackControlPlaneSpec() map[string]interface{} {
484494
names.RabbitMQCell1Name.Name: map[string]interface{}{
485495
"replicas": 1,
486496
},
497+
names.RabbitMQNotificationsName.Name: map[string]interface{}{
498+
"replicas": 1,
499+
},
487500
}
488501
galeraTemplate := map[string]interface{}{
489502
names.DBName.Name: map[string]interface{}{
@@ -525,6 +538,9 @@ func GetDefaultOpenStackControlPlaneSpec() map[string]interface{} {
525538
return map[string]interface{}{
526539
"secret": "osp-secret",
527540
"storageClass": "local-storage",
541+
// "notificationsBus": map[string]interface{}{
542+
// "rabbitMqClusterName": ptr.To("rabbitmq-notifications"),
543+
// },
528544
"galera": map[string]interface{}{
529545
"enabled": true,
530546
"templates": galeraTemplate,

‎tests/functional/ctlplane/openstackoperator_controller_test.go‎

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ var _ = Describe("OpenStackOperator controller", func() {
828828
BeforeEach(func() {
829829
// create cert secrets for rabbitmq instances
830830
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
831+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
831832
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
832833
// create cert secrets for memcached instance
833834
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
@@ -1141,6 +1142,7 @@ var _ = Describe("OpenStackOperator controller", func() {
11411142
BeforeEach(func() {
11421143
// create cert secrets for rabbitmq instances
11431144
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
1145+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
11441146
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
11451147
// create cert secrets for memcached instance
11461148
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
@@ -1268,6 +1270,7 @@ var _ = Describe("OpenStackOperator controller", func() {
12681270
BeforeEach(func() {
12691271
// create cert secrets for rabbitmq instances
12701272
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
1273+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
12711274
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
12721275
// create cert secrets for memcached instance
12731276
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
@@ -1807,6 +1810,76 @@ var _ = Describe("OpenStackOperator controller", func() {
18071810
})
18081811
})
18091812

1813+
When("A OpenStackControlplane instance is created with top-scope notifications config pushed down", func() {
1814+
BeforeEach(func() {
1815+
spec := GetDefaultOpenStackControlPlaneSpec()
1816+
spec["notificationsBus"] = map[string]interface{}{
1817+
"rabbitMqClusterName": ptr.To("rabbitmq-notifications"),
1818+
}
1819+
spec["nova"] = map[string]interface{}{
1820+
"enabled": false,
1821+
"template": map[string]interface{}{},
1822+
}
1823+
DeferCleanup(
1824+
th.DeleteInstance,
1825+
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
1826+
)
1827+
})
1828+
1829+
It("should have Nova notifications bus instance configured by inheritance", func() {
1830+
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1831+
Expect(*OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(ContainSubstring("rabbitmq-notifications"))
1832+
})
1833+
})
1834+
1835+
When("A OpenStackControlplane instance is created with notifications config override", func() {
1836+
BeforeEach(func() {
1837+
spec := GetDefaultOpenStackControlPlaneSpec()
1838+
spec["notificationsBus"] = map[string]interface{}{
1839+
"rabbitMqClusterName": ptr.To("rabbitmq-notifications-top-scope"),
1840+
}
1841+
spec["nova"] = map[string]interface{}{
1842+
"enabled": false,
1843+
"template": map[string]interface{}{
1844+
"notificationsBusInstance": ptr.To("rabbitmq-custom"),
1845+
},
1846+
}
1847+
DeferCleanup(
1848+
th.DeleteInstance,
1849+
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
1850+
)
1851+
})
1852+
1853+
It("should have Nova notifications bus instance configured from local templates", func() {
1854+
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1855+
Expect(*OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(Equal("rabbitmq-custom"))
1856+
})
1857+
})
1858+
1859+
When("A OpenStackControlplane instance is created with notifications config force-disabled", func() {
1860+
BeforeEach(func() {
1861+
spec := GetDefaultOpenStackControlPlaneSpec()
1862+
spec["notificationsBus"] = map[string]interface{}{
1863+
"rabbitMqClusterName": ptr.To(""),
1864+
}
1865+
spec["nova"] = map[string]interface{}{
1866+
"enabled": false,
1867+
"template": map[string]interface{}{
1868+
"notificationsBusInstance": ptr.To("rabbitmq-maybe"),
1869+
},
1870+
}
1871+
DeferCleanup(
1872+
th.DeleteInstance,
1873+
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
1874+
)
1875+
})
1876+
1877+
It("should have Nova enabled and its notifications bus instance configured for a special empty value", func() {
1878+
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1879+
Expect(*OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(Equal(""))
1880+
})
1881+
})
1882+
18101883
When("OpenStackControlplane instance is deleted", func() {
18111884
BeforeEach(func() {
18121885
DeferCleanup(
@@ -2089,6 +2162,7 @@ var _ = Describe("OpenStackOperator controller", func() {
20892162

20902163
// create cert secrets for rabbitmq instances
20912164
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
2165+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
20922166
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
20932167
// create cert secrets for memcached instance
20942168
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
@@ -2929,6 +3003,7 @@ var _ = Describe("OpenStackOperator controller galera and rabbitmq", func() {
29293003

29303004
// create cert secrets for rabbitmq instances
29313005
th.CreateCertSecret(names.RabbitMQCertName)
3006+
th.CreateCertSecret(names.RabbitMQNotificationsCertName)
29323007
th.CreateCertSecret(names.RabbitMQCell1CertName)
29333008

29343009
extGalera := CreateGaleraConfig(namespace, GetDefaultGaleraSpec())
@@ -3064,17 +3139,17 @@ var _ = Describe("OpenStackOperator controller galera and rabbitmq", func() {
30643139
Eventually(func(g Gomega) {
30653140
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
30663141
rabbitTemplates := *(OSCtlplane.Spec.Rabbitmq.Templates)
3067-
g.Expect(rabbitTemplates).Should(HaveLen(2))
3142+
g.Expect(rabbitTemplates).Should(HaveLen(3))
30683143
delete(rabbitTemplates, names.RabbitMQCell1Name.Name)
30693144
OSCtlplane.Spec.Rabbitmq.Templates = &rabbitTemplates
30703145
g.Expect(k8sClient.Update(ctx, OSCtlplane)).Should(Succeed())
30713146
}, timeout, interval).Should(Succeed())
30723147

3073-
// Only 1 cell in rabbitmq template
3148+
// Only 1 cell and notifications bus in rabbitmq template
30743149
Eventually(func(g Gomega) {
30753150
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
30763151
rabbitTemplates := *(OSCtlplane.Spec.Rabbitmq.Templates)
3077-
g.Expect(rabbitTemplates).Should(HaveLen(1))
3152+
g.Expect(rabbitTemplates).Should(HaveLen(2))
30783153
}, timeout, interval).Should(Succeed())
30793154

30803155
// cell1.rabbitmq should not exists in db

0 commit comments

Comments
 (0)