Skip to content

Commit

Permalink
Merge pull request #519 from openshift-cherrypick-robot/cherry-pick-5…
Browse files Browse the repository at this point in the history
…18-to-18.0-fr1

[18.0-fr1] Fix default cache config for no tls
  • Loading branch information
openshift-merge-bot[bot] authored Dec 13, 2024
2 parents 187a11e + d1cb351 commit 233ad1a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
7 changes: 4 additions & 3 deletions controllers/keystoneapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1180,9 +1180,10 @@ func (r *KeystoneAPIReconciler) generateServiceConfigMaps(
dbSecret := db.GetSecret()

templateParameters := map[string]interface{}{
"memcachedServers": mc.GetMemcachedServerListString(),
"memcachedTLS": mc.GetMemcachedTLSSupport(),
"TransportURL": string(transportURLSecret.Data["transport_url"]),
"memcachedServers": mc.GetMemcachedServerListString(),
"memcachedServersWithInet": mc.GetMemcachedServerListWithInetString(),
"memcachedTLS": mc.GetMemcachedTLSSupport(),
"TransportURL": string(transportURLSecret.Data["transport_url"]),
"DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s?read_default_file=/etc/my.cnf",
databaseAccount.Spec.UserName,
string(dbSecret.Data[mariadbv1.DatabasePasswordSelector]),
Expand Down
3 changes: 2 additions & 1 deletion templates/keystoneapi/config/keystone.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ use_stderr=true
[cache]
{{if .memcachedTLS}}
backend = dogpile.cache.pymemcache
memcache_servers={{ .memcachedServers }}
{{else}}
backend = dogpile.cache.memcached
memcache_servers={{ .memcachedServersWithInet }}
{{end}}
enabled=true
memcache_servers={{ .memcachedServers }}
tls_enabled={{ .memcachedTLS }}

[database]
Expand Down
8 changes: 6 additions & 2 deletions tests/functional/keystoneapi_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@ var _ = Describe("Keystone controller", func() {
scrt := th.GetSecret(keystoneAPIConfigDataName)
configData := string(scrt.Data["keystone.conf"])
Expect(configData).To(
ContainSubstring(fmt.Sprintf("memcache_servers=memcached-0.memcached.%s.svc:11211,memcached-1.memcached.%s.svc:11211,memcached-2.memcached.%s.svc:11211",
ContainSubstring("backend = dogpile.cache.memcached"))
Expect(configData).To(
ContainSubstring(fmt.Sprintf("memcache_servers=inet:[memcached-0.memcached.%s.svc]:11211,inet:[memcached-1.memcached.%s.svc]:11211,inet:[memcached-2.memcached.%s.svc]:11211",
keystoneAPIName.Namespace, keystoneAPIName.Namespace, keystoneAPIName.Namespace)))
mariadbAccount := mariadb.GetMariaDBAccount(keystoneAccountName)
mariadbSecret := th.GetSecret(types.NamespacedName{Name: mariadbAccount.Spec.Secret, Namespace: keystoneAPIName.Namespace})
Expand Down Expand Up @@ -851,7 +853,7 @@ var _ = Describe("Keystone controller", func() {
Name: fmt.Sprintf("%s-keystone-transport", keystoneAPIName.Name),
Namespace: namespace,
})
infra.SimulateMemcachedReady(types.NamespacedName{
infra.SimulateTLSMemcachedReady(types.NamespacedName{
Name: "memcached",
Namespace: namespace,
})
Expand Down Expand Up @@ -945,6 +947,8 @@ var _ = Describe("Keystone controller", func() {
It("should create a Secret for keystone.conf and my.cnf", func() {
scrt := th.GetSecret(keystoneAPIConfigDataName)
configData := string(scrt.Data["keystone.conf"])
Expect(configData).To(
ContainSubstring("backend = dogpile.cache.pymemcache"))
Expect(configData).To(
ContainSubstring(fmt.Sprintf("memcache_servers=memcached-0.memcached.%s.svc:11211,memcached-1.memcached.%s.svc:11211,memcached-2.memcached.%s.svc:11211",
keystoneAPIName.Namespace, keystoneAPIName.Namespace, keystoneAPIName.Namespace)))
Expand Down

0 comments on commit 233ad1a

Please sign in to comment.