]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow for node ID and other elements in cluster slots output
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 1 Oct 2017 05:31:07 +0000 (13:31 +0800)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 1 Oct 2017 05:31:37 +0000 (13:31 +0800)
src/modules/rlm_redis/cluster.c

index ec1954bf2d865a27c7a2a1ae9a1887d8babeceda..1c2a8aa586cc3431068aa7e9b47e5f04fa04006a 100644 (file)
@@ -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;
        }