From 1c477f62bc34cc6c5ea42f48aac40148cd778441 Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Thu, 8 Jan 2015 13:28:35 -0500 Subject: [PATCH] Fix redis-trib cluster create Under certain conditions the node list wasn't being fully populated and 'create' would fail trying to call methods on nil objects. --- src/redis-trib.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/redis-trib.rb b/src/redis-trib.rb index e5e7f2da..6b395b0d 100755 --- a/src/redis-trib.rb +++ b/src/redis-trib.rb @@ -563,8 +563,17 @@ class RedisTrib # Take one node from each IP until we run out of nodes # across every IP. ips.each do |ip,nodes| - stop = nodes.empty? and next - interleaved.push nodes.shift + if nodes.empty? + # if this IP has no remaining nodes, check for termination + if interleaved.length == nodes_count + # stop when 'interleaved' has accumulated all nodes + stop = true + next + end + else + # else, move one node from this IP to 'interleaved' + interleaved.push nodes.shift + end end end