memcache: Remove "default" username and password

Because these are not intentional default. This also adds a validation
logic to catch the case where SASL is requested but username or
password is not given.

Change-Id: Ia98bfc5f9a42c13acfdb2192bb1fa11773f6ccf8
This commit is contained in:
Takashi Kajinami 2024-02-03 22:01:56 +09:00
parent 33244f6aae
commit ced97d218b
2 changed files with 6 additions and 2 deletions

View File

@ -122,10 +122,8 @@ FILE_OPTIONS = {
help='Enable the SASL(Simple Authentication and Security'
'Layer) if the SASL_enable is true, else disable.'),
cfg.StrOpt('memcache_username',
default='',
help='the user name for the memcached which SASL enabled'),
cfg.StrOpt('memcache_password',
default='',
secret=True,
help='the password for the memcached which SASL enabled'),
cfg.BoolOpt('tls_enabled',

View File

@ -27,6 +27,7 @@ except ImportError as e:
else:
raise
from oslo_cache import _memcache_pool
from oslo_cache import exception
# Helper to ease backend refactoring
@ -63,6 +64,11 @@ class PooledMemcachedBackend(memcached_backend.MemcachedBackend):
def __init__(self, arguments):
super(PooledMemcachedBackend, self).__init__(arguments)
if arguments.get('sasl_enabled', False):
if (arguments.get('username') is None or
arguments.get('password') is None):
raise exception.ConfigurationError(
'username and password should be configured to use SASL '
'authentication.')
if not _bmemcache_pool:
raise ImportError("python-binary-memcached package is missing")
self.client_pool = _bmemcache_pool.BMemcacheClientPool(