Skip to content

Commit 089fe53

Browse files
committed
Implement top-scope notifications bus interface
Let other services to consume the common notifications bus config from the top scope spec. Make it working for Nova yet, with more services to come by. Signed-off-by: Bohdan Dobrelia <bdobreli@redhat.com>
1 parent 2637b7e commit 089fe53

4 files changed

Lines changed: 61 additions & 28 deletions

File tree

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/openstack-k8s-operators/nova-operator/api v0.6.1-0.20250522172041-c71791ea3caa

tests/functional/ctlplane/base_test.go

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,38 +58,41 @@ type Names struct {
5858
HorizonName types.NamespacedName
5959
HeatName types.NamespacedName
6060
NovaName types.NamespacedName
61+
PlacementName types.NamespacedName
6162
TelemetryName types.NamespacedName
6263
DBName types.NamespacedName
6364
DBCertName types.NamespacedName
6465
DBCell1Name types.NamespacedName
6566
DBCell1CertName types.NamespacedName
6667
RabbitMQName types.NamespacedName
6768
RabbitMQCertName types.NamespacedName
69+
RabbitMQNotificationsCertName types.NamespacedName
6870
RabbitMQCell1Name types.NamespacedName
6971
RabbitMQCell1CertName types.NamespacedName
7072
NoVNCProxyCell1CertPublicRouteName types.NamespacedName
7173
NoVNCProxyCell1CertPublicSvcName types.NamespacedName
7274
NoVNCProxyCell1CertVencryptName types.NamespacedName
73-
ServiceAccountName types.NamespacedName
74-
RoleName types.NamespacedName
75-
RoleBindingName types.NamespacedName
76-
RootCAPublicName types.NamespacedName
77-
RootCAInternalName types.NamespacedName
78-
RootCAOvnName types.NamespacedName
79-
RootCALibvirtName types.NamespacedName
80-
SelfSignedIssuerName types.NamespacedName
81-
CustomIssuerName types.NamespacedName
82-
CustomServiceCertSecretName types.NamespacedName
83-
CABundleName types.NamespacedName
84-
OpenStackClientName types.NamespacedName
85-
OVNNorthdName types.NamespacedName
86-
OVNNorthdCertName types.NamespacedName
87-
OVNControllerName types.NamespacedName
88-
OVNControllerCertName types.NamespacedName
89-
OVNDbServerNBName types.NamespacedName
90-
OVNDbServerSBName types.NamespacedName
91-
NeutronOVNCertName types.NamespacedName
92-
OpenStackTopology []types.NamespacedName
75+
RabbitMQNotificationsName types.NamespacedName
76+
ServiceAccountName types.NamespacedName
77+
RoleName types.NamespacedName
78+
RoleBindingName types.NamespacedName
79+
RootCAPublicName types.NamespacedName
80+
RootCAInternalName types.NamespacedName
81+
RootCAOvnName types.NamespacedName
82+
RootCALibvirtName types.NamespacedName
83+
SelfSignedIssuerName types.NamespacedName
84+
CustomIssuerName types.NamespacedName
85+
CustomServiceCertSecretName types.NamespacedName
86+
CABundleName types.NamespacedName
87+
OpenStackClientName types.NamespacedName
88+
OVNNorthdName types.NamespacedName
89+
OVNNorthdCertName types.NamespacedName
90+
OVNControllerName types.NamespacedName
91+
OVNControllerCertName types.NamespacedName
92+
OVNDbServerNBName types.NamespacedName
93+
OVNDbServerSBName types.NamespacedName
94+
NeutronOVNCertName types.NamespacedName
95+
OpenStackTopology []types.NamespacedName
9396
}
9497

9598
func CreateNames(openstackControlplaneName types.NamespacedName) Names {
@@ -181,6 +184,10 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
181184
Namespace: openstackControlplaneName.Namespace,
182185
Name: "nova",
183186
},
187+
PlacementName: types.NamespacedName{
188+
Namespace: openstackControlplaneName.Namespace,
189+
Name: "placement",
190+
},
184191
DBName: types.NamespacedName{
185192
Namespace: openstackControlplaneName.Namespace,
186193
Name: "openstack",
@@ -205,10 +212,18 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
205212
Namespace: openstackControlplaneName.Namespace,
206213
Name: "cert-rabbitmq-svc",
207214
},
215+
RabbitMQNotificationsCertName: types.NamespacedName{
216+
Namespace: openstackControlplaneName.Namespace,
217+
Name: "cert-rabbitmq-notifications-svc",
218+
},
208219
RabbitMQCell1Name: types.NamespacedName{
209220
Namespace: openstackControlplaneName.Namespace,
210221
Name: "rabbitmq-cell1",
211222
},
223+
RabbitMQNotificationsName: types.NamespacedName{
224+
Namespace: openstackControlplaneName.Namespace,
225+
Name: "rabbitmq-notifications",
226+
},
212227
RabbitMQCell1CertName: types.NamespacedName{
213228
Namespace: openstackControlplaneName.Namespace,
214229
Name: "cert-rabbitmq-cell1-svc",
@@ -509,6 +524,9 @@ func GetDefaultOpenStackControlPlaneSpec() map[string]interface{} {
509524
names.RabbitMQCell1Name.Name: map[string]interface{}{
510525
"replicas": 1,
511526
},
527+
names.RabbitMQNotificationsName.Name: map[string]interface{}{
528+
"replicas": 1,
529+
},
512530
}
513531
galeraTemplate := map[string]interface{}{
514532
names.DBName.Name: map[string]interface{}{

tests/functional/ctlplane/openstackoperator_controller_test.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ var _ = Describe("OpenStackOperator controller", func() {
832832
BeforeEach(func() {
833833
// create cert secrets for rabbitmq instances
834834
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
835+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
835836
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
836837
// create cert secrets for memcached instance
837838
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
@@ -1145,6 +1146,7 @@ var _ = Describe("OpenStackOperator controller", func() {
11451146
BeforeEach(func() {
11461147
// create cert secrets for rabbitmq instances
11471148
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
1149+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
11481150
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
11491151
// create cert secrets for memcached instance
11501152
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
@@ -1272,6 +1274,7 @@ var _ = Describe("OpenStackOperator controller", func() {
12721274
BeforeEach(func() {
12731275
// create cert secrets for rabbitmq instances
12741276
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
1277+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
12751278
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
12761279
// create cert secrets for memcached instance
12771280
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
@@ -1795,10 +1798,11 @@ var _ = Describe("OpenStackOperator controller", func() {
17951798
})
17961799
})
17971800

1798-
When("A OpenStackControlplane instance is created", func() {
1801+
When("A OpenStackControlplane instance is created with top-scope notifications config pushed down", func() {
17991802
BeforeEach(func() {
18001803
// NOTE(bogdando): DBs certs need to be created here as well, but those are already existing somehow
18011804
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
1805+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
18021806
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
18031807
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
18041808
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNNorthdCertName))
@@ -1811,6 +1815,7 @@ var _ = Describe("OpenStackOperator controller", func() {
18111815
th.CreateConfigMap(types.NamespacedName{Name: "openstack-config", Namespace: namespace}, map[string]interface{}{"clouds.yaml": string("foo"), "OS_CLOUD": "default"}))
18121816

18131817
spec := GetDefaultOpenStackControlPlaneSpec()
1818+
spec["notificationsBus"] = "rabbitmq-notifications"
18141819
// enable dependencies
18151820
spec["nova"] = map[string]interface{}{
18161821
"enabled": true,
@@ -1918,26 +1923,31 @@ var _ = Describe("OpenStackOperator controller", func() {
19181923
}, timeout, interval).Should(Succeed())
19191924
})
19201925

1921-
It("should have configured nova", func() {
1926+
It("should have configured nova notifications bus instance from top-scope", func() {
19221927
nova := &novav1.Nova{}
1928+
notificationBusName := "rabbitmq-notifications"
19231929
Eventually(func(g Gomega) {
19241930
g.Expect(k8sClient.Get(ctx, names.NovaName, nova)).Should(Succeed())
19251931
g.Expect(nova).ShouldNot(BeNil())
1932+
g.Expect(nova.Spec.NotificationsBusInstance).Should(Equal(&notificationBusName))
19261933
}, timeout, interval).Should(Succeed())
19271934
})
19281935

1929-
It("should have configured nova from the service template", func() {
1936+
It("should have configured nova notifications bus instance from the service template", func() {
19301937
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1938+
overrideBusName := "rabbitmq-custom"
19311939
Eventually(func(g Gomega) {
1932-
OSCtlplane.Spec.Nova.Template.APIDatabaseInstance = "custom-db"
1940+
// force-update the notifications bus instance, unless it is overriden in templates
1941+
OSCtlplane.Spec.NotificationsBus = ""
1942+
OSCtlplane.Spec.Nova.Template.NotificationsBusInstance = &overrideBusName
19331943
g.Expect(k8sClient.Update(ctx, OSCtlplane)).Should(Succeed())
19341944
}, timeout, interval).Should(Succeed())
19351945

19361946
nova := &novav1.Nova{}
19371947
Eventually(func(g Gomega) {
19381948
g.Expect(k8sClient.Get(ctx, names.NovaName, nova)).Should(Succeed())
19391949
g.Expect(nova).ShouldNot(BeNil())
1940-
g.Expect(nova.Spec.APIDatabaseInstance).Should(Equal("custom-db"))
1950+
g.Expect(nova.Spec.NotificationsBusInstance).Should(Equal(&overrideBusName))
19411951
}, timeout, interval).Should(Succeed())
19421952
})
19431953
})
@@ -2296,6 +2306,7 @@ var _ = Describe("OpenStackOperator controller", func() {
22962306

22972307
// create cert secrets for rabbitmq instances
22982308
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
2309+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
22992310
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
23002311
// create cert secrets for memcached instance
23012312
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
@@ -3136,6 +3147,7 @@ var _ = Describe("OpenStackOperator controller nova cell deletion", func() {
31363147

31373148
// create cert secrets for rabbitmq instances
31383149
th.CreateCertSecret(names.RabbitMQCertName)
3150+
th.CreateCertSecret(names.RabbitMQNotificationsCertName)
31393151
th.CreateCertSecret(names.RabbitMQCell1CertName)
31403152

31413153
// create cert secrets for ovn instance
@@ -3279,17 +3291,17 @@ var _ = Describe("OpenStackOperator controller nova cell deletion", func() {
32793291
Eventually(func(g Gomega) {
32803292
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
32813293
rabbitTemplates := *(OSCtlplane.Spec.Rabbitmq.Templates)
3282-
g.Expect(rabbitTemplates).Should(HaveLen(2))
3294+
g.Expect(rabbitTemplates).Should(HaveLen(3))
32833295
delete(rabbitTemplates, names.RabbitMQCell1Name.Name)
32843296
OSCtlplane.Spec.Rabbitmq.Templates = &rabbitTemplates
32853297
g.Expect(k8sClient.Update(ctx, OSCtlplane)).Should(Succeed())
32863298
}, timeout, interval).Should(Succeed())
32873299

3288-
// Only 1 cell in rabbitmq template
3300+
// Only 1 cell and notifications bus in rabbitmq template
32893301
Eventually(func(g Gomega) {
32903302
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
32913303
rabbitTemplates := *(OSCtlplane.Spec.Rabbitmq.Templates)
3292-
g.Expect(rabbitTemplates).Should(HaveLen(1))
3304+
g.Expect(rabbitTemplates).Should(HaveLen(2))
32933305
}, timeout, interval).Should(Succeed())
32943306

32953307
// 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
@@ -275,6 +275,7 @@ var _ = Describe("OpenStackOperator controller", func() {
275275

276276
// create cert secrets for rabbitmq instances
277277
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
278+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
278279
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
279280

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

0 commit comments

Comments
 (0)