Skip to content

Commit 1e37ac3

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

8 files changed

Lines changed: 150 additions & 46 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9980,6 +9980,8 @@ spec:
99809980
additionalProperties:
99819981
type: string
99829982
type: object
9983+
notificationsBusInstance:
9984+
type: string
99839985
passwordSelectors:
99849986
default:
99859987
service: NovaPassword

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9980,6 +9980,8 @@ spec:
99809980
additionalProperties:
99819981
type: string
99829982
type: object
9983+
notificationsBusInstance:
9984+
type: string
99839985
passwordSelectors:
99849986
default:
99859987
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 => ../nova-operator/api

‎go.sum‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20250415060817-
134134
github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20250415060817-dc849adfa27e/go.mod h1:ZgHSxZSgpgHg1FhKPnBm/cqxAJbVFbKiBkqQoRohn3Q=
135135
github.com/openstack-k8s-operators/neutron-operator/api v0.6.1-0.20250422103409-9ddf83d0f545 h1:m+0pOigO5fx+AynqTxd28XnXwDLYlCx87Elc1Hw7EI0=
136136
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=
139137
github.com/openstack-k8s-operators/octavia-operator/api v0.6.1-0.20250422141120-3b3a002bcbd6 h1:yhyspgVZ2DiGL4bzHSQepk9OUyk7HDhxKxrHdTBgzns=
140138
github.com/openstack-k8s-operators/octavia-operator/api v0.6.1-0.20250422141120-3b3a002bcbd6/go.mod h1:5p6SbWrnXSKs8sG4plfdXuJ1fGxKQP/kPwBYT5iZbuY=
141139
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 = 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

‎tests/functional/ctlplane/openstackversion_controller_test.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ var _ = Describe("OpenStackOperator controller", func() {
269269

270270
// create cert secrets for rabbitmq instances
271271
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
272+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
272273
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
273274

274275
// (mschuppert) create root CA secrets as there is no certmanager running.

0 commit comments

Comments
 (0)