From d5a21af2a669cb396b1f9bf52f240024e8722f71 Mon Sep 17 00:00:00 2001 From: yatinkarel Date: Mon, 9 Dec 2024 15:05:20 +0530 Subject: [PATCH] Fix default cache config for no tls When env is deployed with tls disabled, cache config was wrong as "dogpile.cache.memcached" backend requires inet[6] prefixes for memcache_servers setting while it was set without the prefix. with IPv4 issue not observed as "inet" is default prefix, this patch fixes it by setting [cache]/memcache_servers based on tls config. Resolves: OSPRH-12223 Related-Issue: OSPRH-12221 --- templates/neutronapi/config/01-neutron.conf | 3 ++- test/functional/neutronapi_controller_test.go | 22 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/templates/neutronapi/config/01-neutron.conf b/templates/neutronapi/config/01-neutron.conf index 96bb8aa0..6d3407b1 100644 --- a/templates/neutronapi/config/01-neutron.conf +++ b/templates/neutronapi/config/01-neutron.conf @@ -90,11 +90,12 @@ lock_path = /var/lib/neutron/tmp [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 }} [oslo_policy] diff --git a/test/functional/neutronapi_controller_test.go b/test/functional/neutronapi_controller_test.go index da0e2146..26ccb1c4 100644 --- a/test/functional/neutronapi_controller_test.go +++ b/test/functional/neutronapi_controller_test.go @@ -701,13 +701,21 @@ func getNeutronAPIControllerSuite(ml2MechanismDrivers []string) func() { Eventually(func() corev1.Secret { return th.GetSecret(secret) }, timeout, interval).ShouldNot(BeNil()) + memcacheInstance := infra.GetMemcached(memcachedName) neutronCfg := string(th.GetSecret(secret).Data["01-neutron.conf"]) + if memcacheInstance.GetMemcachedTLSSupport() { + Expect(neutronCfg).Should( + ContainSubstring("backend = dogpile.cache.pymemcache")) + Expect(neutronCfg).Should( + ContainSubstring(fmt.Sprintf("memcache_servers = %s", memcacheInstance.GetMemcachedServerListString()))) + } else { + Expect(neutronCfg).Should( + ContainSubstring("backend = dogpile.cache.memcached")) + Expect(neutronCfg).Should( + ContainSubstring(fmt.Sprintf("memcache_servers = %s", memcacheInstance.GetMemcachedServerListWithInetString()))) + } Expect(neutronCfg).Should( - ContainSubstring(fmt.Sprintf("memcache_servers=memcached-0.memcached.%s.svc:11211,memcached-1.memcached.%s.svc:11211,memcached-2.memcached.%s.svc:11211", - neutronAPIName.Namespace, neutronAPIName.Namespace, neutronAPIName.Namespace))) - Expect(neutronCfg).Should( - ContainSubstring(fmt.Sprintf("memcached_servers=inet:[memcached-0.memcached.%s.svc]:11211,inet:[memcached-1.memcached.%s.svc]:11211,inet:[memcached-2.memcached.%s.svc]:11211", - neutronAPIName.Namespace, neutronAPIName.Namespace, neutronAPIName.Namespace))) + ContainSubstring(fmt.Sprintf("memcached_servers=%s", memcacheInstance.GetMemcachedServerListWithInetString()))) }) if isOVNEnabled { @@ -1137,7 +1145,7 @@ func getNeutronAPIControllerSuite(ml2MechanismDrivers []string) func() { ) SimulateTransportURLReady(apiTransportURLName) DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, "memcached", memcachedSpec)) - infra.SimulateMemcachedReady(memcachedName) + infra.SimulateTLSMemcachedReady(memcachedName) DeferCleanup(DeleteOVNDBClusters, CreateOVNDBClusters(namespace)) DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(namespace)) mariadb.SimulateMariaDBAccountCompleted(types.NamespacedName{Namespace: namespace, Name: GetNeutronAPI(neutronAPIName).Spec.DatabaseAccount}) @@ -1325,7 +1333,7 @@ func getNeutronAPIControllerSuite(ml2MechanismDrivers []string) func() { ) SimulateTransportURLReady(apiTransportURLName) DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, "memcached", memcachedSpec)) - infra.SimulateMemcachedReady(memcachedName) + infra.SimulateTLSMemcachedReady(memcachedName) DeferCleanup(DeleteOVNDBClusters, CreateOVNDBClusters(namespace)) DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(namespace)) mariadb.SimulateMariaDBAccountCompleted(types.NamespacedName{Namespace: namespace, Name: GetNeutronAPI(neutronAPIName).Spec.DatabaseAccount})