summaryrefslogtreecommitdiff
path: root/src/redis-trib.rb
diff options
context:
space:
mode:
authorMatt Stancliff <matt@genges.com>2015-01-08 13:28:35 -0500
committerMatt Stancliff <matt@genges.com>2015-01-08 13:28:35 -0500
commit1c477f62bc34cc6c5ea42f48aac40148cd778441 (patch)
tree004980118b85cafe08a3db6309d731af2002862f /src/redis-trib.rb
parent622c69e93db2b7b03bb3a547f6573654819cc29b (diff)
downloadredis-1c477f62bc34cc6c5ea42f48aac40148cd778441.tar.gz
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.
Diffstat (limited to 'src/redis-trib.rb')
-rwxr-xr-xsrc/redis-trib.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/redis-trib.rb b/src/redis-trib.rb
index e5e7f2da7..6b395b0dc 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