Allow using non-default Redis database

Redis supports multiple databases and the redis driver in taskflow is
capable to select the one used as backend.

Add the new option to select the database so that non-default database
can be used.

Change-Id: I9a44d2c5bc4a524e194a090ba66871beac4d618d
This commit is contained in:
Takashi Kajinami 2024-07-09 13:31:45 +09:00
parent 7974e755e1
commit e0b5f91626
4 changed files with 17 additions and 0 deletions

View File

@ -576,6 +576,9 @@ task_flow_opts = [
cfg.StrOpt('jobboard_backend_namespace', default='octavia_jobboard',
help='Jobboard name that should be used to store taskflow '
'job id and claims for it.'),
cfg.IntOpt('jobboard_redis_backend_db',
default=0, min=0,
help='Database ID in redis server.'),
cfg.StrOpt('jobboard_redis_sentinel', default=None,
help='Sentinel name if it is used for Redis.'),
cfg.StrOpt('jobboard_redis_sentinel_username',

View File

@ -99,6 +99,7 @@ class RedisTaskFlowDriver(JobboardTaskFlowDriver):
'board': 'redis',
'host': CONF.task_flow.jobboard_backend_hosts[0],
'port': CONF.task_flow.jobboard_backend_port,
'db': CONF.task_flow.jobboard_redis_backend_db,
'namespace': CONF.task_flow.jobboard_backend_namespace,
'sentinel': CONF.task_flow.jobboard_redis_sentinel,
'sentinel_fallbacks': [

View File

@ -33,6 +33,7 @@ class TestRedisTaskFlowDriver(base.TestCase):
'board': 'redis',
'host': '127.0.0.1',
'port': 6379,
'db': 0,
'namespace': 'octavia_jobboard',
'sentinel': None,
'sentinel_fallbacks': [],
@ -65,6 +66,7 @@ class TestRedisTaskFlowDriver(base.TestCase):
'board': 'redis',
'host': '127.0.0.1',
'port': 6379,
'db': 0,
'namespace': 'octavia_jobboard',
'password': 'redispass',
'sentinel': None,
@ -100,6 +102,7 @@ class TestRedisTaskFlowDriver(base.TestCase):
'board': 'redis',
'host': '127.0.0.1',
'port': 6379,
'db': 0,
'namespace': 'octavia_jobboard',
'username': 'redisuser',
'password': 'redispass',
@ -142,6 +145,7 @@ class TestRedisTaskFlowDriver(base.TestCase):
'board': 'redis',
'host': '127.0.0.1',
'port': 6379,
'db': 0,
'namespace': 'octavia_jobboard',
'sentinel': None,
'sentinel_fallbacks': [],
@ -179,6 +183,7 @@ class TestRedisTaskFlowDriver(base.TestCase):
'board': 'redis',
'host': 'host1',
'port': 26379,
'db': 0,
'namespace': 'octavia_jobboard',
'sentinel': 'mymaster',
'sentinel_fallbacks': ['host2:26379', 'host3:26379'],
@ -220,6 +225,7 @@ class TestRedisTaskFlowDriver(base.TestCase):
'board': 'redis',
'host': 'host1',
'port': 26379,
'db': 0,
'namespace': 'octavia_jobboard',
'password': 'redispass',
'sentinel': 'mymaster',
@ -267,6 +273,7 @@ class TestRedisTaskFlowDriver(base.TestCase):
'board': 'redis',
'host': 'host1',
'port': 26379,
'db': 0,
'namespace': 'octavia_jobboard',
'username': 'redisuser',
'password': 'redispass',
@ -328,6 +335,7 @@ class TestRedisTaskFlowDriver(base.TestCase):
'board': 'redis',
'host': 'host1',
'port': 26379,
'db': 0,
'namespace': 'octavia_jobboard',
'sentinel': 'mymaster',
'sentinel_fallbacks': ['host2:26379', 'host3:26379'],

View File

@ -0,0 +1,5 @@
---
features:
- |
The new ``[task_flow] jobboard_redis_backend_db`` option has been added.
This option allows using non default database in redis as backend.