philae 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db79bb92141b6234559b57f1d9cb0e0ef79bed45
4
- data.tar.gz: '08c32572e4c8544f8cbad1d32b99f0e94ad93823'
3
+ metadata.gz: 4fb2abe798bfe65ac1f77da6a0284195eb73db03
4
+ data.tar.gz: 841db519d68f08b8de7187415b5d428391154780
5
5
  SHA512:
6
- metadata.gz: c916f5131503c773392885413638cf307d7b0cd1a7a5417aaaf466b6615e887a746ab6a12610295ae655912f0e2172580afba0125a1e4feea37516c0297b8dc9
7
- data.tar.gz: c074e162e193e76af19ac28ad8c244a9cbfa4f08265b6f24249b2d85ff86038eb55a1de1400966460cf3f21e6871499995aa4bbfa2886a41a1f1e1e639e66c59
6
+ metadata.gz: 3c43748351457a9cdbe040a88fa8d557e47aae050fe73f3574e0ae56dafd22455d3ac940fc273239d328467bc9630714dba3fa5ae6963737cc5327cbcca08f21
7
+ data.tar.gz: 15527a9c4fa412943be8af12fdcaf96d8badf7d28c113798c987871954cfec84b8c7d1b323fe2b3077afc9a591f19cc41b996cf53c6e27ba37cecd71c4befc06
@@ -16,10 +16,10 @@ module Philae
16
16
  begin
17
17
  Docker::Container.all
18
18
  rescue
19
- return false
19
+ return {healthy: false, comment: 'Unable to communicate with docker'}
20
20
  end
21
21
 
22
- true
22
+ { healthy: true, comment: '' }
23
23
  end
24
24
  end
25
25
  end
@@ -19,12 +19,11 @@ module Philae
19
19
  resp = Net::HTTP.start(uri.hostname, uri.port) do |http|
20
20
  http.request(req)
21
21
  end
22
-
23
- return false if resp.code.to_s[0] != '2' && resp.code.to_s[0] != '3'
22
+ return { healthy: false, comment: 'Invalid response code' } if resp.code.to_s[0] != '2' && resp.code.to_s[0] != '3'
24
23
  rescue
25
- return false
24
+ return { healthy: false, comment: 'Unable to contact server' }
26
25
  end
27
- true
26
+ { healthy: true, comment: '' }
28
27
  end
29
28
  end
30
29
  end
@@ -11,13 +11,13 @@ module Philae
11
11
 
12
12
  def check
13
13
  begin
14
- client = Mongo::Client.new(@uri)
15
- db = client.datbase
14
+ client = Mongo::Client.new(@uri, max_read_retries: 1)
15
+ db = client.database
16
16
  db.collection_names
17
17
  rescue
18
- return false
18
+ return { healthy: false, comment: 'Unable to conctact mongo' }
19
19
  end
20
- true
20
+ { healthy: true, comment: '' }
21
21
  end
22
22
  end
23
23
  end
@@ -21,12 +21,18 @@ module Philae
21
21
  http.request(req)
22
22
  end
23
23
 
24
- return false if resp.code.to_s[0] != '2' && resp.code.to_s[0] != '3'
24
+ if resp.code.to_s[0] != '2' && resp.code.to_s[0] != '3'
25
+ return { healthy: false, comment: 'Invalid return code' }
26
+ end
25
27
 
26
28
  status = JSON.parse(resp.body)
27
- return status['healthy']
29
+ if status['healthy']
30
+ return { healthy: true, comment: '' }
31
+ else
32
+ return { healthy: false, comment: 'node not healthy' }
33
+ end
28
34
  rescue
29
- return false
35
+ return { healthy: false, comment: 'Unable to contact server' }
30
36
  end
31
37
  end
32
38
  end
data/lib/philae/prober.rb CHANGED
@@ -10,7 +10,8 @@ module Philae
10
10
 
11
11
  def check
12
12
  probes_status = @probes.map do |probe|
13
- { name: probe.name, healthy: probe.check }
13
+ status = probe.check
14
+ { name: probe.name, healthy: status[:healthy], comment: status[:comment] }
14
15
  end
15
16
 
16
17
  global = probes_status.all? do |probe|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - leo@scalingo.com