Skip to content

Commit 821f0d6

Browse files
committed
Fix elasticsearch facts and http check
* Fix http response code and json context * Fix elasticsearch, return nil if nodes is empty
1 parent ff32c58 commit 821f0d6

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/facter/es_facts.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def self.run
6969
response = http.get('/')
7070
json_data = JSON.parse(response.body)
7171

72-
if json_data['status'] && json_data['status'] == 200
72+
if response.code == '200' && json_data['version'] && json_data['name']
7373
add_fact(key_prefix, 'name', json_data['name'])
7474
add_fact(key_prefix, 'version', json_data['version']['number'])
7575

@@ -128,9 +128,8 @@ def self.run
128128
end
129129
Facter.add(:elasticsearch) do
130130
setcode do
131-
nodes
131+
nodes unless nodes.empty?
132132
end
133-
nodes unless nodes.empty?
134133
end
135134
end
136135
end

0 commit comments

Comments
 (0)