Redis Sentinel: Use dogpile.cache interface for username
digpile.cache 1.3.1 introduced the new username argument to the Redis
Sentinel backend[1]. This interface can be used instead of directly
injecting username into connection/sentinel_kwargs.
[1] 6cbc6ad9d2
Change-Id: I2f6c13050e30ef829c545e5019aca5fc4de97dbb
This commit is contained in:
parent
e8de6c9ea5
commit
adb551c05d
|
@ -175,16 +175,9 @@ def _build_cache_config(conf):
|
||||||
value = getattr(conf.cache, 'redis_' + arg)
|
value = getattr(conf.cache, 'redis_' + arg)
|
||||||
conf_dict['%s.arguments.%s' % (prefix, arg)] = value
|
conf_dict['%s.arguments.%s' % (prefix, arg)] = value
|
||||||
elif conf.cache.backend == 'dogpile.cache.redis_sentinel':
|
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)
|
value = getattr(conf.cache, 'redis_' + arg)
|
||||||
conf_dict['%s.arguments.%s' % (prefix, arg)] = value
|
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_dict['%s.arguments.service_name' % prefix] = \
|
||||||
conf.cache.redis_sentinel_service_name
|
conf.cache.redis_sentinel_service_name
|
||||||
if conf.cache.redis_sentinels:
|
if conf.cache.redis_sentinels:
|
||||||
|
|
|
@ -830,14 +830,10 @@ class CacheRegionTest(test_cache.BaseTestCase):
|
||||||
('::1', 26379),
|
('::1', 26379),
|
||||||
('localhost', 26379),
|
('localhost', 26379),
|
||||||
], config_dict['test_prefix.arguments.sentinels'])
|
], config_dict['test_prefix.arguments.sentinels'])
|
||||||
|
self.assertEqual(
|
||||||
|
'user', config_dict['test_prefix.arguments.username'])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'secrete', config_dict['test_prefix.arguments.password'])
|
'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):
|
def test_cache_debug_proxy(self):
|
||||||
single_value = 'Test Value'
|
single_value = 'Test Value'
|
||||||
|
|
|
@ -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.config>=8.1.0 # Apache-2.0
|
||||||
oslo.i18n>=5.0.0 # Apache-2.0
|
oslo.i18n>=5.0.0 # Apache-2.0
|
||||||
oslo.log>=4.2.1 # Apache-2.0
|
oslo.log>=4.2.1 # Apache-2.0
|
||||||
|
|
Loading…
Reference in New Issue