Skip to content

Commit 1c477f6

Browse files
committed
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.
1 parent 622c69e commit 1c477f6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/redis-trib.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,17 @@ def alloc_slots
563563
# Take one node from each IP until we run out of nodes
564564
# across every IP.
565565
ips.each do |ip,nodes|
566-
stop = nodes.empty? and next
567-
interleaved.push nodes.shift
566+
if nodes.empty?
567+
# if this IP has no remaining nodes, check for termination
568+
if interleaved.length == nodes_count
569+
# stop when 'interleaved' has accumulated all nodes
570+
stop = true
571+
next
572+
end
573+
else
574+
# else, move one node from this IP to 'interleaved'
575+
interleaved.push nodes.shift
576+
end
568577
end
569578
end
570579

0 commit comments

Comments
 (0)