redis: Support multiple sentinel servers
Redis Sentinel client implementation support using multiple sentinel servers for redundancy, but only a single server from the servers list was passed down to it. This uses the new taskflow interface to add fallback servers, and register the remaining servers in the list as fallbacks. Depends-on: https://review.opendev.org/c/openstack/taskflow/+/907674 Change-Id: I6b281d2520db0048329b12b33108273ba2f96534
This commit is contained in:
parent
16f6b2e8f6
commit
bd3ef61a0c
|
@ -87,12 +87,22 @@ class RedisTaskFlowDriver(JobboardTaskFlowDriver):
|
|||
self.persistence_driver = persistence_driver
|
||||
|
||||
def job_board(self, persistence):
|
||||
|
||||
def _format_server(host, port):
|
||||
if ':' in host:
|
||||
return '[%s]:%d' % (host, port)
|
||||
return '%s:%d' % (host, port)
|
||||
|
||||
jobboard_backend_conf = {
|
||||
'board': 'redis',
|
||||
'host': CONF.task_flow.jobboard_backend_hosts[0],
|
||||
'port': CONF.task_flow.jobboard_backend_port,
|
||||
'namespace': CONF.task_flow.jobboard_backend_namespace,
|
||||
'sentinel': CONF.task_flow.jobboard_redis_sentinel,
|
||||
'sentinel_fallbacks': [
|
||||
_format_server(host, CONF.task_flow.jobboard_backend_port)
|
||||
for host in CONF.task_flow.jobboard_backend_hosts[1:]
|
||||
]
|
||||
}
|
||||
if CONF.task_flow.jobboard_backend_username is not None:
|
||||
jobboard_backend_conf['username'] = (
|
||||
|
|
Loading…
Reference in New Issue