Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #43 from rapid7/erik-debug-drain-tool
Browse files Browse the repository at this point in the history
check if instance is a null object first before calling a class method
  • Loading branch information
eheaney-r7 authored Sep 8, 2020
2 parents 422c898 + 51fedfa commit a85aef4
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/elasticsearch/drain/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,18 @@ def remove_nodes(nodes) # rubocop:disable Metrics/MethodLength
sleep_time = wait_sleep_time
nodes.each do |instance|
instance = drainer.nodes.filter_nodes([instance.ipaddress], true).first
if instance.bytes_stored > 0
say_status 'Drain Status', "Node #{instance.ipaddress} has #{instance.bytes_stored} bytes to move", :blue
sleep sleep_time
else
next unless remove_node(instance)
deleted_nodes.push(nodes.find { |n| n.ipaddress == instance.ipaddress })
nodes.delete_if { |n| n.ipaddress == instance.ipaddress }
break if nodes.length < 1
say_status 'Waiting', 'Sleeping for 1 minute before removing the next node', :green
sleep 60
unless instance.nil? || instance == 0
if instance.bytes_stored > 0
say_status 'Drain Status', "Node #{instance.ipaddress} has #{instance.bytes_stored} bytes to move", :blue
sleep sleep_time
else
next unless remove_node(instance)
deleted_nodes.push(nodes.find { |n| n.ipaddress == instance.ipaddress })
nodes.delete_if { |n| n.ipaddress == instance.ipaddress }
break if nodes.length < 1
say_status 'Waiting', 'Sleeping for 1 minute before removing the next node', :green
sleep 60
end
end
end
end
Expand Down

0 comments on commit a85aef4

Please sign in to comment.