diff --git a/oslo_cache/core.py b/oslo_cache/core.py index a97780d3..3e860177 100644 --- a/oslo_cache/core.py +++ b/oslo_cache/core.py @@ -175,16 +175,9 @@ def _build_cache_config(conf): value = getattr(conf.cache, 'redis_' + arg) conf_dict['%s.arguments.%s' % (prefix, arg)] = value elif conf.cache.backend == 'dogpile.cache.redis_sentinel': - for arg in ('password', 'socket_timeout'): + for arg in ('username', 'password', 'socket_timeout'): value = getattr(conf.cache, 'redis_' + arg) conf_dict['%s.arguments.%s' % (prefix, arg)] = value - if conf.cache.redis_username: - # TODO(tkajinam): Update dogpile.cache to add username argument, - # similarly to password. - conf_dict['%s.arguments.connection_kwargs' % prefix] = \ - {'username': conf.cache.redis_username} - conf_dict['%s.arguments.sentinel_kwargs' % prefix] = \ - {'username': conf.cache.redis_username} conf_dict['%s.arguments.service_name' % prefix] = \ conf.cache.redis_sentinel_service_name if conf.cache.redis_sentinels: @@ -287,16 +280,13 @@ def _build_cache_config(conf): }) if conf.cache.backend == 'dogpile.cache.redis_sentinel': conn_kwargs.update({'ssl': True}) - conf_dict.setdefault( - '%s.arguments.connection_kwargs' % prefix, - {}).update(conn_kwargs) - conf_dict.setdefault( - '%s.arguments.sentinel_kwargs' % prefix, - {}).update(conn_kwargs) + conf_dict['%s.arguments.connection_kwargs' % prefix] = \ + conn_kwargs + conf_dict['%s.arguments.sentinel_kwargs' % prefix] = \ + conn_kwargs else: - conf_dict.setdefault( - '%s.arguments.connection_kwargs' % prefix, - {}).update(conn_kwargs) + conf_dict['%s.arguments.connection_kwargs' % prefix] = \ + conn_kwargs else: raise exception.ConfigurationError( "TLS setting via [cache] tls_enabled is not supported by the " diff --git a/oslo_cache/tests/unit/test_cache_basics.py b/oslo_cache/tests/unit/test_cache_basics.py index aa51a071..083dc5ce 100644 --- a/oslo_cache/tests/unit/test_cache_basics.py +++ b/oslo_cache/tests/unit/test_cache_basics.py @@ -830,14 +830,10 @@ class CacheRegionTest(test_cache.BaseTestCase): ('::1', 26379), ('localhost', 26379), ], config_dict['test_prefix.arguments.sentinels']) + self.assertEqual( + 'user', config_dict['test_prefix.arguments.username']) self.assertEqual( 'secrete', config_dict['test_prefix.arguments.password']) - self.assertEqual({ - 'username': 'user' - }, config_dict['test_prefix.arguments.connection_kwargs']) - self.assertEqual({ - 'username': 'user' - }, config_dict['test_prefix.arguments.sentinel_kwargs']) def test_cache_debug_proxy(self): single_value = 'Test Value' diff --git a/requirements.txt b/requirements.txt index 410731a3..fa24c25c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -dogpile.cache>=1.1.5 # BSD +dogpile.cache>=1.3.1 # BSD oslo.config>=8.1.0 # Apache-2.0 oslo.i18n>=5.0.0 # Apache-2.0 oslo.log>=4.2.1 # Apache-2.0