Skip to content

Commit d469e6b

Browse files
Merge pull request #782 from lmiccini/quorum2
Use quorum queues if enabled
2 parents 7ec9dea + 3d5455e commit d469e6b

File tree

9 files changed

+123
-11
lines changed

9 files changed

+123
-11
lines changed

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.21
44

55
require (
66
github.com/google/go-cmp v0.7.0
7-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250821143610-c8ef7b9a21ec
7+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250909143828-e33d35ffd64f
88
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250823121217-7e1cd2e3dd03
99
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20250823121217-7e1cd2e3dd03
1010
k8s.io/api v0.29.15

api/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
7575
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
7676
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6Beb1gQ96Ptej9AE/BvwCBiRj1E=
7777
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
78-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250821143610-c8ef7b9a21ec h1:Jvz2BuTWCvjeCbDzpPzlPMrUQpEe04Rzi8LPNxeW0Ts=
79-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250821143610-c8ef7b9a21ec/go.mod h1:Dv8qpmBIQy3Jv/EyQnOyc0w61X8vyfxpjcIQONP5CwY=
78+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250909143828-e33d35ffd64f h1:chuu4iBT5sXHYw8aPeP/pWC+S3yGo6hdy39foP7c5vs=
79+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250909143828-e33d35ffd64f/go.mod h1:Dv8qpmBIQy3Jv/EyQnOyc0w61X8vyfxpjcIQONP5CwY=
8080
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250823121217-7e1cd2e3dd03 h1:9VanDdvg1APf9B1nzGElLvWr6dM5GsSayMLSV/nJZnE=
8181
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250823121217-7e1cd2e3dd03/go.mod h1:Z+rmtn3qhuPZfx2EDVmloUh2MkYbvDMgcpJneRYerS0=
8282
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20250823121217-7e1cd2e3dd03 h1:DrKbzsweRx8VBNb5ur+/XcHSi+MR3VdzCsIEXYGc5SM=

controllers/glance_common.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ import (
4545

4646
// fields to index to reconcile when change
4747
const (
48-
passwordSecretField = ".spec.secret"
49-
caBundleSecretNameField = ".spec.tls.caBundleSecretName"
50-
tlsAPIInternalField = ".spec.tls.api.internal.secretName"
51-
tlsAPIPublicField = ".spec.tls.api.public.secretName"
52-
topologyField = ".spec.topologyRef.Name"
48+
passwordSecretField = ".spec.secret"
49+
caBundleSecretNameField = ".spec.tls.caBundleSecretName"
50+
tlsAPIInternalField = ".spec.tls.api.internal.secretName"
51+
tlsAPIPublicField = ".spec.tls.api.public.secretName"
52+
topologyField = ".spec.topologyRef.Name"
53+
notificationBusSecretField = ".spec.notificationBusSecret"
5354
)
5455

5556
var (
@@ -62,6 +63,7 @@ var (
6263
tlsAPIInternalField,
6364
tlsAPIPublicField,
6465
topologyField,
66+
notificationBusSecretField,
6567
}
6668
)
6769

controllers/glanceapi_controller.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,18 @@ func (r *GlanceAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
273273
return err
274274
}
275275

276+
// index notificationBusSecretField
277+
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &glancev1.GlanceAPI{}, notificationBusSecretField, func(rawObj client.Object) []string {
278+
// Extract the notification bus secret name from the spec, if one is provided
279+
cr := rawObj.(*glancev1.GlanceAPI)
280+
if cr.Spec.NotificationBusSecret == "" {
281+
return nil
282+
}
283+
return []string{cr.Spec.NotificationBusSecret}
284+
}); err != nil {
285+
return err
286+
}
287+
276288
// Watch for changes to any CustomServiceConfigSecrets. Global secrets
277289
svcSecretFn := func(_ context.Context, o client.Object) []reconcile.Request {
278290
var namespace string = o.GetNamespace()
@@ -1282,6 +1294,7 @@ func (r *GlanceAPIReconciler) generateServiceConfig(
12821294
return err
12831295
}
12841296
templateParameters["TransportURL"] = string(notificationBusSecret.Data["transport_url"])
1297+
templateParameters["QuorumQueues"] = string(notificationBusSecret.Data["quorumqueues"]) == "true"
12851298
}
12861299

12871300
// Try to get Horizon endpoint and setup CORS section if the CR is found

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/openstack-k8s-operators/cinder-operator/api v0.6.1-0.20250902141512-aaa8d7e75046
1313
github.com/openstack-k8s-operators/glance-operator/api v0.0.0-00010101000000-000000000000
1414
github.com/openstack-k8s-operators/horizon-operator/api v0.6.1-0.20250902143657-1a0c8d38827e
15-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250821143610-c8ef7b9a21ec
15+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250909143828-e33d35ffd64f
1616
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250905083405-40d18a7ca650
1717
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250823121217-7e1cd2e3dd03
1818
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20250823121217-7e1cd2e3dd03

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ github.com/openstack-k8s-operators/cinder-operator/api v0.6.1-0.20250902141512-a
8282
github.com/openstack-k8s-operators/cinder-operator/api v0.6.1-0.20250902141512-aaa8d7e75046/go.mod h1:tM7pBGkx9fDgaT7OAg0gXsfivNq6fm+Bsza5OLo8P0M=
8383
github.com/openstack-k8s-operators/horizon-operator/api v0.6.1-0.20250902143657-1a0c8d38827e h1:4IxW5NtFbIMvmuWOgFWopDvzxsO/BJkpZ0IZHRgeu0s=
8484
github.com/openstack-k8s-operators/horizon-operator/api v0.6.1-0.20250902143657-1a0c8d38827e/go.mod h1:j9yGw80eA38kEvHEkx/BONqIhLnKFmpjAtyAB8S817E=
85-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250821143610-c8ef7b9a21ec h1:Jvz2BuTWCvjeCbDzpPzlPMrUQpEe04Rzi8LPNxeW0Ts=
86-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250821143610-c8ef7b9a21ec/go.mod h1:Dv8qpmBIQy3Jv/EyQnOyc0w61X8vyfxpjcIQONP5CwY=
85+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250909143828-e33d35ffd64f h1:chuu4iBT5sXHYw8aPeP/pWC+S3yGo6hdy39foP7c5vs=
86+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250909143828-e33d35ffd64f/go.mod h1:Dv8qpmBIQy3Jv/EyQnOyc0w61X8vyfxpjcIQONP5CwY=
8787
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250905083405-40d18a7ca650 h1:n1s6jr8GJ6cn/1tjLVGPkTURb4ooHwjdS5YeppKdB0g=
8888
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250905083405-40d18a7ca650/go.mod h1:G6BkoPfgALryMlOZwIH036iSWUMiDJQAYL1lXuLyPZ0=
8989
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250823121217-7e1cd2e3dd03 h1:9VanDdvg1APf9B1nzGElLvWr6dM5GsSayMLSV/nJZnE=

templates/common/config/00-config.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ password = {{ .ServicePassword }}
6666
{{ if (index . "TransportURL") -}}
6767
driver=messagingv2
6868
transport_url = {{ .TransportURL }}
69+
{{ if (index . "QuorumQueues") -}}
70+
[oslo_messaging_rabbit]
71+
rabbit_quorum_queue=true
72+
rabbit_transient_quorum_queue=true
73+
amqp_durable_queues=true
74+
{{ end }}
6975
{{ else -}}
7076
driver=noop
7177
{{ end -}}

test/functional/base_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package functional
1818

1919
import (
2020
"fmt"
21+
2122
"golang.org/x/exp/maps"
2223
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
2324
"k8s.io/apimachinery/pkg/types"

test/functional/glanceapi_controller_test.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,96 @@ var _ = Describe("Glanceapi controller", func() {
157157
}, timeout, interval).Should(Succeed())
158158
})
159159
})
160+
When("the Secret is created with quorum queues enabled", func() {
161+
BeforeEach(func() {
162+
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, glanceTest.MemcachedInstance, memcachedSpec))
163+
infra.SimulateMemcachedReady(glanceTest.GlanceMemcached)
164+
DeferCleanup(k8sClient.Delete, ctx, infra.CreateTransportURLSecret(glanceTest.Instance.Namespace, glanceTest.RabbitmqSecretName, true))
165+
DeferCleanup(th.DeleteInstance, CreateDefaultGlance(glanceTest.Instance))
166+
DeferCleanup(
167+
mariadb.DeleteDBService,
168+
mariadb.CreateDBService(
169+
glanceName.Namespace,
170+
GetGlance(glanceTest.Instance).Spec.DatabaseInstance,
171+
corev1.ServiceSpec{
172+
Ports: []corev1.ServicePort{{Port: 3306}},
173+
},
174+
),
175+
)
176+
mariadb.CreateMariaDBDatabase(glanceTest.GlanceDatabaseName.Namespace, glanceTest.GlanceDatabaseName.Name, mariadbv1.MariaDBDatabaseSpec{})
177+
DeferCleanup(k8sClient.Delete, ctx, mariadb.GetMariaDBDatabase(glanceTest.GlanceDatabaseName))
178+
179+
spec := GetDefaultGlanceAPISpec(GlanceAPITypeSingle)
180+
spec["notificationBusSecret"] = glanceTest.RabbitmqSecretName
181+
DeferCleanup(th.DeleteInstance, CreateGlanceAPI(glanceTest.GlanceSingle, spec))
182+
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(glanceTest.Instance.Namespace))
183+
})
184+
It("generated configs with quorum queue settings", func() {
185+
th.ExpectCondition(
186+
glanceTest.GlanceSingle,
187+
ConditionGetterFunc(GlanceAPIConditionGetter),
188+
condition.ServiceConfigReadyCondition,
189+
corev1.ConditionTrue,
190+
)
191+
secretDataMap := th.GetSecret(glanceTest.GlanceSingleConfigMapData)
192+
Expect(secretDataMap).ShouldNot(BeNil())
193+
configData := string(secretDataMap.Data["00-config.conf"])
194+
Expect(configData).Should(ContainSubstring("rabbit_quorum_queue=true"))
195+
Expect(configData).Should(ContainSubstring("rabbit_transient_quorum_queue=true"))
196+
Expect(configData).Should(ContainSubstring("amqp_durable_queues=true"))
197+
})
198+
})
199+
When("quorum queues are enabled dynamically", func() {
200+
BeforeEach(func() {
201+
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, glanceTest.MemcachedInstance, memcachedSpec))
202+
infra.SimulateMemcachedReady(glanceTest.GlanceMemcached)
203+
DeferCleanup(k8sClient.Delete, ctx, infra.CreateTransportURLSecret(glanceTest.Instance.Namespace, glanceTest.RabbitmqSecretName, false))
204+
DeferCleanup(th.DeleteInstance, CreateDefaultGlance(glanceTest.Instance))
205+
DeferCleanup(
206+
mariadb.DeleteDBService,
207+
mariadb.CreateDBService(
208+
glanceName.Namespace,
209+
GetGlance(glanceTest.Instance).Spec.DatabaseInstance,
210+
corev1.ServiceSpec{
211+
Ports: []corev1.ServicePort{{Port: 3306}},
212+
},
213+
),
214+
)
215+
mariadb.CreateMariaDBDatabase(glanceTest.GlanceDatabaseName.Namespace, glanceTest.GlanceDatabaseName.Name, mariadbv1.MariaDBDatabaseSpec{})
216+
DeferCleanup(k8sClient.Delete, ctx, mariadb.GetMariaDBDatabase(glanceTest.GlanceDatabaseName))
217+
218+
spec := GetDefaultGlanceAPISpec(GlanceAPITypeSingle)
219+
spec["notificationBusSecret"] = glanceTest.RabbitmqSecretName
220+
DeferCleanup(th.DeleteInstance, CreateGlanceAPI(glanceTest.GlanceSingle, spec))
221+
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(glanceTest.Instance.Namespace))
222+
})
223+
It("updates configs when quorum queues are enabled", func() {
224+
// First verify no quorum queue settings initially
225+
th.ExpectCondition(
226+
glanceTest.GlanceSingle,
227+
ConditionGetterFunc(GlanceAPIConditionGetter),
228+
condition.ServiceConfigReadyCondition,
229+
corev1.ConditionTrue,
230+
)
231+
secretDataMap := th.GetSecret(glanceTest.GlanceSingleConfigMapData)
232+
configData := string(secretDataMap.Data["00-config.conf"])
233+
Expect(configData).ShouldNot(ContainSubstring("rabbit_quorum_queue=true"))
234+
235+
// Enable quorum queues by updating the secret
236+
secret := th.GetSecret(types.NamespacedName{Namespace: glanceTest.Instance.Namespace, Name: glanceTest.RabbitmqSecretName})
237+
_ = k8sClient.Delete(ctx, &secret)
238+
infra.CreateTransportURLSecret(glanceTest.Instance.Namespace, glanceTest.RabbitmqSecretName, true)
239+
240+
// Verify quorum queue settings are now present
241+
Eventually(func(g Gomega) {
242+
secretDataMap := th.GetSecret(glanceTest.GlanceSingleConfigMapData)
243+
configData := string(secretDataMap.Data["00-config.conf"])
244+
g.Expect(configData).Should(ContainSubstring("rabbit_quorum_queue=true"))
245+
g.Expect(configData).Should(ContainSubstring("rabbit_transient_quorum_queue=true"))
246+
g.Expect(configData).Should(ContainSubstring("amqp_durable_queues=true"))
247+
}, timeout, interval).Should(Succeed())
248+
})
249+
})
160250
When("GlanceAPI is deployed with Cinder backend", func() {
161251
BeforeEach(func() {
162252
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, glanceTest.MemcachedInstance, memcachedSpec))

0 commit comments

Comments
 (0)