Skip to content

Commit

Permalink
fix ambiguous redis connection config
Browse files Browse the repository at this point in the history
Redis sentinel is what's deployed in S3C, to connect to it
we use "sentinels" field in redis config that contains the host/port
of each sentinel.

In Artesca we use the "host" and "port" fields to connect to the redis
instance.

The config rules were adapted to make sure we don't pass all the fields at once
which might make the config ambiguous to understand, although the redis client
seems to handle this case well, as it first checks the sentinel config before connecting
using the host/port fields.

Default values for redis host/port were removed from the config definition and put inside
the default/dev config file.

Issue: BB-522
  • Loading branch information
Kerkesni committed Sep 24, 2024
1 parent a1e9895 commit d20c311
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions conf/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@
"host": "127.0.0.1",
"port": 6379
},
"redis": {
"host": "localhost",
"port": 6379
},
"certFilePaths": {
"key": "",
"cert": "",
Expand Down
12 changes: 10 additions & 2 deletions lib/config.joi.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,16 @@ const joiSchema = joi.object({
port: joi.number().default(8900),
},
redis: {
host: joi.string().default('localhost'),
port: joi.number().default(6379),
host: joi.string().when('sentinels', {
is: joi.exist(),
then: joi.forbidden(),
otherwise: joi.required(),
}),
port: joi.number().when('sentinels', {
is: joi.exist(),
then: joi.forbidden(),
otherwise: joi.required(),
}),
name: joi.string().default('backbeat'),
password: joi.string().default('').allow(''),
sentinels: joi.alternatives([joi.string(), joi.array().items(
Expand Down

0 comments on commit d20c311

Please sign in to comment.