philae 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/philae/etcd_probe.rb +22 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 364566be0ba5f86c671be8dfc919961eb333675c
|
4
|
+
data.tar.gz: 861a74eea37e7b5a4dd39f18f04165028df0727d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a75abb6a2a71b648d25386e1e269c77326589084211b32d2fdf2d8bfa1228c9947ea4467cda1b3b5a4f4b03a452385d9c3c28764c6a2260338cfeacb032d73b
|
7
|
+
data.tar.gz: fd7c6875ef6784f9654f79b3c692eedcdfee804f73bcc4043564a65f68601ea98f43448dadf463bf75186548c456b453c284449e0d7e0777f1c31f77d0997a93
|
data/lib/philae/etcd_probe.rb
CHANGED
@@ -6,13 +6,22 @@ require 'etcd'
|
|
6
6
|
# If you need to connect to etcd using a custom CA cert, you can give it along with the SSL cert and
|
7
7
|
# key to the constructor.
|
8
8
|
module Philae
|
9
|
+
class InvalidSSLConfig < RuntimeError
|
10
|
+
end
|
11
|
+
|
9
12
|
class EtcdProbe
|
10
13
|
attr_reader :name
|
11
14
|
|
12
15
|
# @param [Integer] read_timeout Timeout in second for the HTTP request
|
13
|
-
def initialize(name, host, port, read_timeout
|
14
|
-
if not cacert.nil?
|
15
|
-
|
16
|
+
def initialize(name, host, port, read_timeout: 1, cacert: nil, ssl_cert: nil, ssl_key: nil)
|
17
|
+
if not cacert.nil?
|
18
|
+
if !File.exists? cacert
|
19
|
+
raise InvalidSSLConfig, "cacert"
|
20
|
+
elsif ssl_cert.nil? or !File.exists? ssl_cert
|
21
|
+
raise InvalidSSLConfig, "ssl_cert"
|
22
|
+
elsif ssl_key.nil? or !File.exists? ssl_key
|
23
|
+
raise InvalidSSLConfig, "ssl_key"
|
24
|
+
end
|
16
25
|
end
|
17
26
|
@name = name
|
18
27
|
@host = host
|
@@ -25,20 +34,19 @@ module Philae
|
|
25
34
|
|
26
35
|
def check
|
27
36
|
begin
|
28
|
-
opts = {
|
29
|
-
host: @host,
|
30
|
-
port: @port,
|
31
|
-
read_timeout: @read_timeout,
|
32
|
-
}
|
33
37
|
if not @cacert.nil?
|
34
|
-
|
35
|
-
|
36
|
-
|
38
|
+
client = Etcd.client host: @host, port: @port, read_timeout: @read_timeout do |c|
|
39
|
+
c.use_ssl = true
|
40
|
+
c.ca_file = @cacert
|
41
|
+
c.ssl_cert = OpenSSL::X509::Certificate.new(File.read(@ssl_cert))
|
42
|
+
c.ssl_key = OpenSSL::PKey::RSA.new(File.read(@ssl_key))
|
43
|
+
end
|
44
|
+
else
|
45
|
+
client = Etcd.client host: @host, port: @port, read_timeout: @read_timeout
|
37
46
|
end
|
38
|
-
client = Etcd.client(opts)
|
39
47
|
client.get '/'
|
40
|
-
rescue
|
41
|
-
return { healthy: false, comment:
|
48
|
+
rescue Exception => e
|
49
|
+
return { healthy: false, comment: "Unable to contact etcd (#{e.message})" }
|
42
50
|
end
|
43
51
|
{ healthy: true, comment: '' }
|
44
52
|
end
|
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.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- leo@scalingo.com
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-06
|
13
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: docker-api
|