From 4d7521da143375af4ba6789e669867cbf69dbfd7 Mon Sep 17 00:00:00 2001 From: Lauren Helm Date: Wed, 10 Mar 2021 16:52:56 -0500 Subject: [PATCH] prevents drain from failing when object is empty --- lib/elasticsearch/drain/node.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/elasticsearch/drain/node.rb b/lib/elasticsearch/drain/node.rb index dc453ed..f6a6533 100644 --- a/lib/elasticsearch/drain/node.rb +++ b/lib/elasticsearch/drain/node.rb @@ -97,7 +97,10 @@ def address(str) end def in_recovery? - recovery = client.cat.recovery(format: 'json', v: true).first.values + recovery = client.cat.recovery(format: 'json', v: true) + if recovery.first != nil + recovery = recovery.first.values + end [hostname, name].any? { |a| recovery.include?(a) } end