Skip to content

Commit 82a7638

Browse files
Merge pull request #615 from lmiccini/quorum2
Use quorum queues if enabled
2 parents e5b178b + e5f9909 commit 82a7638

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed

controllers/keystoneapi_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ func (r *KeystoneAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M
397397
Owns(&corev1.ServiceAccount{}).
398398
Owns(&rbacv1.Role{}).
399399
Owns(&rbacv1.RoleBinding{}).
400+
Owns(&rabbitmqv1.TransportURL{}).
400401
Watches(&memcachedv1.Memcached{},
401402
handler.EnqueueRequestsFromMapFunc(memcachedFn)).
402403
Watches(
@@ -1359,6 +1360,9 @@ func (r *KeystoneAPIReconciler) generateServiceConfigMaps(
13591360
templateParameters["MemcachedAuthCa"] = fmt.Sprint(memcachedv1.CaMountPath())
13601361
}
13611362

1363+
// Check if Quorum Queues are enabled
1364+
templateParameters["QuorumQueues"] = string(transportURLSecret.Data["quorumqueues"]) == "true"
1365+
13621366
httpdOverrideSecret := &corev1.Secret{}
13631367
if instance.Spec.HttpdCustomization.CustomConfigSecret != nil && *instance.Spec.HttpdCustomization.CustomConfigSecret != "" {
13641368
httpdOverrideSecret, _, err = oko_secret.GetSecret(ctx, h, *instance.Spec.HttpdCustomization.CustomConfigSecret, instance.Namespace)

templates/keystoneapi/config/keystone.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,10 @@ max_active_keys={{ .FernetMaxActiveKeys }}
3838
driver=messagingv2
3939
transport_url={{ .TransportURL }}
4040
topics = barbican_notifications
41+
{{ if (index . "QuorumQueues") -}}
42+
[oslo_messaging_rabbit]
43+
rabbit_quorum_queue=true
44+
rabbit_transient_quorum_queue=true
45+
amqp_durable_queues=true
46+
{{- end -}}
4147
{{ end }}

tests/functional/keystoneapi_controller_test.go

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,154 @@ OIDCRedirectURI "{{ .KeystoneEndpointPublic }}/v3/auth/OS-FEDERATION/websso/open
20302030
})
20312031
})
20322032

2033+
When("A KeystoneAPI is created with quorum queues disabled", func() {
2034+
BeforeEach(func() {
2035+
DeferCleanup(th.DeleteInstance, CreateKeystoneAPI(keystoneAPIName, GetDefaultKeystoneAPISpec()))
2036+
DeferCleanup(
2037+
k8sClient.Delete, ctx, infra.CreateTransportURLSecret(namespace, "rabbitmq-secret", false))
2038+
DeferCleanup(
2039+
k8sClient.Delete, ctx, CreateKeystoneAPISecret(namespace, SecretName))
2040+
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, "memcached", memcachedSpec))
2041+
DeferCleanup(
2042+
mariadb.DeleteDBService,
2043+
mariadb.CreateDBService(
2044+
namespace,
2045+
GetKeystoneAPI(keystoneAPIName).Spec.DatabaseInstance,
2046+
corev1.ServiceSpec{
2047+
Ports: []corev1.ServicePort{{Port: 3306}},
2048+
},
2049+
),
2050+
)
2051+
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
2052+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
2053+
infra.SimulateTransportURLReady(types.NamespacedName{
2054+
Name: fmt.Sprintf("%s-keystone-transport", keystoneAPIName.Name),
2055+
Namespace: namespace,
2056+
})
2057+
infra.SimulateMemcachedReady(types.NamespacedName{
2058+
Name: "memcached",
2059+
Namespace: namespace,
2060+
})
2061+
th.SimulateJobSuccess(dbSyncJobName)
2062+
th.SimulateJobSuccess(bootstrapJobName)
2063+
th.SimulateDeploymentReplicaReady(deploymentName)
2064+
})
2065+
2066+
It("should not include quorum queue configuration in keystone.conf", func() {
2067+
scrt := th.GetSecret(keystoneAPIConfigDataName)
2068+
configData := string(scrt.Data["keystone.conf"])
2069+
Expect(configData).NotTo(ContainSubstring("rabbit_quorum_queue"))
2070+
Expect(configData).NotTo(ContainSubstring("rabbit_transient_quorum_queue"))
2071+
Expect(configData).NotTo(ContainSubstring("amqp_durable_queues"))
2072+
})
2073+
})
2074+
2075+
When("A KeystoneAPI is created with quorum queues enabled", func() {
2076+
BeforeEach(func() {
2077+
DeferCleanup(th.DeleteInstance, CreateKeystoneAPI(keystoneAPIName, GetDefaultKeystoneAPISpec()))
2078+
DeferCleanup(
2079+
k8sClient.Delete, ctx, infra.CreateTransportURLSecret(namespace, "rabbitmq-secret", true))
2080+
DeferCleanup(
2081+
k8sClient.Delete, ctx, CreateKeystoneAPISecret(namespace, SecretName))
2082+
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, "memcached", memcachedSpec))
2083+
DeferCleanup(
2084+
mariadb.DeleteDBService,
2085+
mariadb.CreateDBService(
2086+
namespace,
2087+
GetKeystoneAPI(keystoneAPIName).Spec.DatabaseInstance,
2088+
corev1.ServiceSpec{
2089+
Ports: []corev1.ServicePort{{Port: 3306}},
2090+
},
2091+
),
2092+
)
2093+
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
2094+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
2095+
infra.SimulateTransportURLReady(types.NamespacedName{
2096+
Name: fmt.Sprintf("%s-keystone-transport", keystoneAPIName.Name),
2097+
Namespace: namespace,
2098+
})
2099+
infra.SimulateMemcachedReady(types.NamespacedName{
2100+
Name: "memcached",
2101+
Namespace: namespace,
2102+
})
2103+
th.SimulateJobSuccess(dbSyncJobName)
2104+
th.SimulateJobSuccess(bootstrapJobName)
2105+
th.SimulateDeploymentReplicaReady(deploymentName)
2106+
})
2107+
2108+
It("should include quorum queue configuration in keystone.conf", func() {
2109+
scrt := th.GetSecret(keystoneAPIConfigDataName)
2110+
configData := string(scrt.Data["keystone.conf"])
2111+
Expect(configData).To(ContainSubstring("rabbit_quorum_queue=true"))
2112+
Expect(configData).To(ContainSubstring("rabbit_transient_quorum_queue=true"))
2113+
Expect(configData).To(ContainSubstring("amqp_durable_queues=true"))
2114+
})
2115+
})
2116+
2117+
When("A KeystoneAPI is created with quorum queues disabled and then updated to enable them", func() {
2118+
BeforeEach(func() {
2119+
DeferCleanup(th.DeleteInstance, CreateKeystoneAPI(keystoneAPIName, GetDefaultKeystoneAPISpec()))
2120+
DeferCleanup(
2121+
k8sClient.Delete, ctx, infra.CreateTransportURLSecret(namespace, "rabbitmq-secret", false))
2122+
DeferCleanup(
2123+
k8sClient.Delete, ctx, CreateKeystoneAPISecret(namespace, SecretName))
2124+
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, "memcached", memcachedSpec))
2125+
DeferCleanup(
2126+
mariadb.DeleteDBService,
2127+
mariadb.CreateDBService(
2128+
namespace,
2129+
GetKeystoneAPI(keystoneAPIName).Spec.DatabaseInstance,
2130+
corev1.ServiceSpec{
2131+
Ports: []corev1.ServicePort{{Port: 3306}},
2132+
},
2133+
),
2134+
)
2135+
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
2136+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
2137+
infra.SimulateTransportURLReady(types.NamespacedName{
2138+
Name: fmt.Sprintf("%s-keystone-transport", keystoneAPIName.Name),
2139+
Namespace: namespace,
2140+
})
2141+
infra.SimulateMemcachedReady(types.NamespacedName{
2142+
Name: "memcached",
2143+
Namespace: namespace,
2144+
})
2145+
th.SimulateJobSuccess(dbSyncJobName)
2146+
th.SimulateJobSuccess(bootstrapJobName)
2147+
th.SimulateDeploymentReplicaReady(deploymentName)
2148+
})
2149+
2150+
It("should correctly update keystone.conf when quorum queues are enabled", func() {
2151+
// First, verify the initial state - quorum queues disabled
2152+
scrt := th.GetSecret(keystoneAPIConfigDataName)
2153+
configData := string(scrt.Data["keystone.conf"])
2154+
Expect(configData).NotTo(ContainSubstring("rabbit_quorum_queue"))
2155+
Expect(configData).NotTo(ContainSubstring("rabbit_transient_quorum_queue"))
2156+
Expect(configData).NotTo(ContainSubstring("amqp_durable_queues"))
2157+
2158+
// Update the RabbitMQ secret to enable quorum queues
2159+
rabbitmqSecret := th.GetSecret(types.NamespacedName{
2160+
Name: "rabbitmq-secret",
2161+
Namespace: namespace,
2162+
})
2163+
2164+
// Update the quorum queue setting in the secret
2165+
Eventually(func(g Gomega) {
2166+
rabbitmqSecret.Data["quorumqueues"] = []byte("true")
2167+
g.Expect(k8sClient.Update(ctx, &rabbitmqSecret)).Should(Succeed())
2168+
}, timeout, interval).Should(Succeed())
2169+
2170+
// Wait for the configuration to be updated in keystone.conf
2171+
Eventually(func(g Gomega) {
2172+
scrt = th.GetSecret(keystoneAPIConfigDataName)
2173+
configData = string(scrt.Data["keystone.conf"])
2174+
g.Expect(configData).To(ContainSubstring("rabbit_quorum_queue=true"))
2175+
g.Expect(configData).To(ContainSubstring("rabbit_transient_quorum_queue=true"))
2176+
g.Expect(configData).To(ContainSubstring("amqp_durable_queues=true"))
2177+
}, timeout, interval).Should(Succeed())
2178+
})
2179+
})
2180+
20332181
// Run MariaDBAccount suite tests. these are pre-packaged ginkgo tests
20342182
// that exercise standard account create / update patterns that should be
20352183
// common to all controllers that ensure MariaDBAccount CRs.

0 commit comments

Comments
 (0)