From: Arran Cudbard-Bell Date: Sun, 1 Oct 2017 05:31:07 +0000 (+0800) Subject: Allow for node ID and other elements in cluster slots output X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a80fe84f918687ff15f8659dd3f41e70dffac8af;p=thirdparty%2Ffreeradius-server.git Allow for node ID and other elements in cluster slots output --- diff --git a/src/modules/rlm_redis/cluster.c b/src/modules/rlm_redis/cluster.c index ec1954bf2d8..1c2a8aa586c 100644 --- a/src/modules/rlm_redis/cluster.c +++ b/src/modules/rlm_redis/cluster.c @@ -771,9 +771,21 @@ static int cluster_map_node_validate(redisReply *node, int map_idx, int node_idx return CLUSTER_OP_BAD_INPUT; } - if (node->elements != 2) { - fr_strerror_printf("Cluster map %i node %i has incorrect number of elements, expected 2 got %zu", - map_idx, node_idx, node->elements); + /* + * As per the redis docs: https://redis.io/commands/cluster-slots + * + * Newer versions of Redis Cluster will output, for each Redis instance, + * not just the IP and port, but also the node ID as third element of the + * array. In future versions there could be more elements describing the + * node better. In general a client implementation should just rely on + * the fact that certain parameters are at fixed positions as specified, + * but more parameters may follow and should be ignored. + * Similarly a client library should try if possible to cope with the fact + * that older versions may just have the IP and port parameter. + */ + if (node->elements >= 2) { + fr_strerror_printf("Cluster map %i node %i has incorrect number of elements, expected at least " + "2 got %zu", map_idx, node_idx, node->elements); return CLUSTER_OP_BAD_INPUT; }