Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/openstack-k8s-operators/lib-common/modules/test v0.6.1-0.20251230215914-6ba873b49a35
github.com/openstack-k8s-operators/manila-operator/api v0.0.0-00010101000000-000000000000
github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20260105160121-f7a8ef85ce8d
gopkg.in/ini.v1 v1.67.0
k8s.io/api v0.31.14
k8s.io/apimachinery v0.31.14
k8s.io/client-go v0.31.14
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSP
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
Expand Down
1 change: 1 addition & 0 deletions internal/controller/manila_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,7 @@ func (r *ManilaReconciler) generateServiceConfig(
"MemcachedServersWithInet": memcached.GetMemcachedServerListWithInetString(),
"MemcachedServers": memcached.GetMemcachedServerListString(),
"TimeOut": instance.Spec.APITimeout,
"Region": keystoneAPI.GetRegion(),
}

// MTLS
Expand Down
12 changes: 12 additions & 0 deletions templates/manila/config/00-config.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ project_name = service
username = {{ .ServiceUser }}
password = {{ .ServicePassword }}
interface = internal
{{ if (index . "Region") -}}
region_name = {{ .Region }}
{{ end -}}
{{if (index . "MemcachedAuthCert")}}
memcache_tls_certfile = {{ .MemcachedAuthCert }}
memcache_tls_keyfile = {{ .MemcachedAuthKey }}
Expand All @@ -53,6 +56,9 @@ project_name=service
user_domain_name=Default
username = {{ .ServiceUser }}
password = {{ .ServicePassword }}
{{ if (index . "Region") -}}
region_name = {{ .Region }}
{{ end -}}

[nova]
interface = internal
Expand All @@ -63,6 +69,9 @@ password = {{ .ServicePassword }}
user_domain_name = Default
project_name = service
project_domain_name = Default
{{ if (index . "Region") -}}
region_name = {{ .Region }}
{{ end -}}

[oslo_concurrency]
lock_path=/tmp/manila/manila_locks
Expand Down Expand Up @@ -110,6 +119,9 @@ project_name=service
user_domain_name=Default
username = {{ .ServiceUser }}
password = {{ .ServicePassword }}
{{ if (index . "Region") -}}
barbican_region_name = {{ .Region }}
{{ end -}}

[key_manager]
backend = barbican
54 changes: 54 additions & 0 deletions test/functional/manila_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

. "github.com/onsi/ginkgo/v2" //revive:disable:dot-imports
. "github.com/onsi/gomega" //revive:disable:dot-imports
"gopkg.in/ini.v1"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

//revive:disable-next-line:dot-imports
Expand Down Expand Up @@ -1338,6 +1339,59 @@ var _ = Describe("Manila controller", func() {
g.Expect(conf).To(ContainSubstring("amqp_durable_queues=true"))
}, timeout, interval).Should(Succeed())
})

It("includes region_name in config when KeystoneAPI has region set", func() {
const testRegion = "regionTwo"
// Create and update KeystoneAPI with region in status
keystoneAPIName := keystone.CreateKeystoneAPI(manilaTest.Instance.Namespace)
DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName)
keystoneAPI := keystone.GetKeystoneAPI(keystoneAPIName)
keystoneAPI.Status.Region = testRegion
keystoneAPI.Status.APIEndpoints = map[string]string{
"internal": "http://keystone-internal-openstack.testing",
"public": "http://keystone-public-openstack.testing",
}
Eventually(func(g Gomega) {
g.Expect(k8sClient.Status().Update(ctx, keystoneAPI.DeepCopy())).Should(Succeed())
}, timeout, interval).Should(Succeed())

// Trigger reconciliation
th.ExpectCondition(
manilaTest.Instance,
ConditionGetterFunc(ManilaConditionGetter),
condition.ServiceConfigReadyCondition,
corev1.ConditionTrue,
)

configSecret := th.GetSecret(manilaTest.ManilaConfigSecret)
Expect(configSecret).ShouldNot(BeNil())
Expect(configSecret.Data).Should(HaveKey("00-config.conf"))
configData := string(configSecret.Data["00-config.conf"])

// Parse the INI file to properly access sections
cfg, err := ini.Load([]byte(configData))
Expect(err).ShouldNot(HaveOccurred(), "Should be able to parse config as INI")

// Verify region_name in [keystone_authtoken]
section := cfg.Section("keystone_authtoken")
Expect(section).ShouldNot(BeNil(), "Should find [keystone_authtoken] section")
Expect(section.Key("region_name").String()).Should(Equal(testRegion))

// Verify region_name in [neutron]
section = cfg.Section("neutron")
Expect(section).ShouldNot(BeNil(), "Should find [neutron] section")
Expect(section.Key("region_name").String()).Should(Equal(testRegion))

// Verify region_name in [nova]
section = cfg.Section("nova")
Expect(section).ShouldNot(BeNil(), "Should find [nova] section")
Expect(section.Key("region_name").String()).Should(Equal(testRegion))

// Verify barbican_region_name in [barbican]
section = cfg.Section("barbican")
Expect(section).ShouldNot(BeNil(), "Should find [barbican] section")
Expect(section.Key("barbican_region_name").String()).Should(Equal(testRegion))
})
})

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