Skip to content

Commit 2a3818b

Browse files
committed
Add region support
1 parent 893591a commit 2a3818b

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

internal/controller/manila_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,7 @@ func (r *ManilaReconciler) generateServiceConfig(
10131013
"MemcachedServersWithInet": memcached.GetMemcachedServerListWithInetString(),
10141014
"MemcachedServers": memcached.GetMemcachedServerListString(),
10151015
"TimeOut": instance.Spec.APITimeout,
1016+
"Region": keystoneAPI.GetRegion(),
10161017
}
10171018

10181019
// MTLS

templates/manila/config/00-config.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ project_name = service
3838
username = {{ .ServiceUser }}
3939
password = {{ .ServicePassword }}
4040
interface = internal
41+
{{ if (index . "Region") -}}
42+
region_name = {{ .Region }}
43+
{{ end -}}
4144
{{if (index . "MemcachedAuthCert")}}
4245
memcache_tls_certfile = {{ .MemcachedAuthCert }}
4346
memcache_tls_keyfile = {{ .MemcachedAuthKey }}
@@ -53,6 +56,9 @@ project_name=service
5356
user_domain_name=Default
5457
username = {{ .ServiceUser }}
5558
password = {{ .ServicePassword }}
59+
{{ if (index . "Region") -}}
60+
region_name = {{ .Region }}
61+
{{ end -}}
5662

5763
[nova]
5864
interface = internal
@@ -63,6 +69,9 @@ password = {{ .ServicePassword }}
6369
user_domain_name = Default
6470
project_name = service
6571
project_domain_name = Default
72+
{{ if (index . "Region") -}}
73+
region_name = {{ .Region }}
74+
{{ end -}}
6675

6776
[oslo_concurrency]
6877
lock_path=/tmp/manila/manila_locks
@@ -110,6 +119,9 @@ project_name=service
110119
user_domain_name=Default
111120
username = {{ .ServiceUser }}
112121
password = {{ .ServicePassword }}
122+
{{ if (index . "Region") -}}
123+
region_name = {{ .Region }}
124+
{{ end -}}
113125

114126
[key_manager]
115127
backend = barbican

test/functional/manila_controller_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,51 @@ var _ = Describe("Manila controller", func() {
13381338
g.Expect(conf).To(ContainSubstring("amqp_durable_queues=true"))
13391339
}, timeout, interval).Should(Succeed())
13401340
})
1341+
1342+
It("includes region_name in config when KeystoneAPI has region set", func() {
1343+
const testRegion = "regionTwo"
1344+
// Create and update KeystoneAPI with region in status
1345+
keystoneAPIName := keystone.CreateKeystoneAPI(manilaTest.Instance.Namespace)
1346+
DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName)
1347+
keystoneAPI := keystone.GetKeystoneAPI(keystoneAPIName)
1348+
keystoneAPI.Status.Region = testRegion
1349+
keystoneAPI.Status.APIEndpoints = map[string]string{
1350+
"internal": "http://keystone-internal-openstack.testing",
1351+
"public": "http://keystone-public-openstack.testing",
1352+
}
1353+
Eventually(func(g Gomega) {
1354+
g.Expect(k8sClient.Status().Update(ctx, keystoneAPI.DeepCopy())).Should(Succeed())
1355+
}, timeout, interval).Should(Succeed())
1356+
1357+
// Trigger reconciliation
1358+
th.ExpectCondition(
1359+
manilaTest.Instance,
1360+
ConditionGetterFunc(ManilaConditionGetter),
1361+
condition.ServiceConfigReadyCondition,
1362+
corev1.ConditionTrue,
1363+
)
1364+
1365+
configSecret := th.GetSecret(manilaTest.ManilaConfigSecret)
1366+
Expect(configSecret).ShouldNot(BeNil())
1367+
Expect(configSecret.Data).Should(HaveKey("00-config.conf"))
1368+
configData := string(configSecret.Data["00-config.conf"])
1369+
1370+
// Verify region_name in [keystone_authtoken]
1371+
Expect(configData).Should(ContainSubstring(
1372+
fmt.Sprintf("[keystone_authtoken]\nregion_name = %s", testRegion)))
1373+
1374+
// Verify region_name in [neutron]
1375+
Expect(configData).Should(ContainSubstring(
1376+
fmt.Sprintf("[neutron]\nregion_name = %s", testRegion)))
1377+
1378+
// Verify region_name in [nova]
1379+
Expect(configData).Should(ContainSubstring(
1380+
fmt.Sprintf("[nova]\nregion_name = %s", testRegion)))
1381+
1382+
// Verify region_name in [barbican]
1383+
Expect(configData).Should(ContainSubstring(
1384+
fmt.Sprintf("[barbican]\nregion_name = %s", testRegion)))
1385+
})
13411386
})
13421387

13431388
When("Manila is created with quorum queues disabled in transport secret", func() {

0 commit comments

Comments
 (0)