etcd-tools 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDEyMzBmODFkNmM1ZjA1ZDEyOGUxNzNiNzQ0OWU0OGQ3MGE4ZGEyNw==
4
+ ZjQ3OTQ5ZDg5MmM1MzgxY2E3MTE4YzhjNDI5NzRmZmZkMDQxMWUwYw==
5
5
  data.tar.gz: !binary |-
6
- ODk5YzYxMWM4ZTE3ODUwMWFmMWIyMTRhNTg5YzE4ZDczNmRhZjY5ZA==
6
+ ZDNmZjQyMWE1NjcwOGYxMjNmMTBkMzcxMjU1OWIyODVlZWVkY2FhZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWM0ZDFjMGZlNDM0NmVlOTQ4ZmFjOTE3Y2Q2MDU2YWNhNTE4ZmVkMWY2MGUy
10
- MWNhNDkwMzEwYzc4MjEyNzkyZTQ0MjkxYTMwMTBhOTI4MmY0OTNhMjQ4YjUx
11
- OTY0Y2UxYTMwYzNiZjA0NWViZWQ5OTQ2MGQ1MmRiZmY3YWQ5MDc=
9
+ ZjFkOWRmZmFjYmQ3MDI1ZjVmY2NlZWQyOWY3NWI1NTU1MjY4M2E3ODYyOGY2
10
+ YTA4OTI5YmIxMTFiNjMxNGUzMWQyYjQ2ZmRkMThlMTI3YzlmYjljYjI4MmQ3
11
+ ODY1Y2UwYTc0YmNhZjNkODk4MTkyYmE0ODIyODkwNjBkN2QxODM=
12
12
  data.tar.gz: !binary |-
13
- NDAzMWMwOGVmMDA4MmQ1ZjNhYjVmMjVmYzE2MzhjODM5YzU1Mjg5ZGUyYjQy
14
- OTQ0M2U3ZmM2ZmI5MTMzNTdiNTQ1ZTg3MzZjNjhhOTVhN2FmOTI5MDcyZDE5
15
- MTlhMTAxZmZlZTdkMjlmZDE4YTcwN2RmZDJmZTQ0NTNhNjdlOGY=
13
+ NmFmNzYwZDVhNjljNTViZTRiOGYxZGRhOTk5MjhlNDA1YzM5MmUyZWRlNmJm
14
+ YmU5NDgxZDM2MGUwNzc1MDFlY2RmYzc0NDhjZWY4ODFjYTIzZTRjYmZkOWMw
15
+ MTU1NjI1NjQ1Y2YxN2RiMTE0NWFiYzA5MTc5ODMyMDdiY2NmNDQ=
@@ -38,7 +38,7 @@ module EtcdTools
38
38
 
39
39
  begin
40
40
  @etcd = etcd_connect @options[:url]
41
- rescue EtcdTools::ClusterConnectError
41
+ rescue Etcd::ClusterConnectError
42
42
  $stderr.puts "Failed to connect to ETCD cluster"
43
43
  exit! 1
44
44
  end
@@ -34,7 +34,7 @@ module EtcdTools
34
34
 
35
35
  begin
36
36
  @etcd = etcd_connect @options[:url]
37
- rescue EtcdTools::ClusterConnectError
37
+ rescue Etcd::ClusterConnectError
38
38
  $stderr.puts "Failed to connect to ETCD cluster"
39
39
  exit! 1
40
40
  end
@@ -46,7 +46,7 @@ module EtcdTools
46
46
 
47
47
  begin
48
48
  @etcd = etcd_connect @options[:url]
49
- rescue EtcdTools::ClusterConnectError
49
+ rescue Etcd::ClusterConnectError
50
50
  $stderr.puts "Failed to connect to ETCD cluster"
51
51
  exit! 1
52
52
  end
@@ -2,8 +2,6 @@ require 'etcd'
2
2
  require 'etcd-tools/mixins'
3
3
 
4
4
  module EtcdTools
5
- class ClusterConnectError < Exception
6
- end
7
5
 
8
6
  module Etcd
9
7
  def etcd_connect(url, timeout = 2)
@@ -14,7 +12,7 @@ module EtcdTools
14
12
  next unless etcd.healthy?
15
13
  return etcd
16
14
  end
17
- raise EtcdTools::ClusterConnectError
15
+ raise Etcd::ClusterConnectError
18
16
  end
19
17
  end
20
18
  end
@@ -2,6 +2,9 @@ require 'etcd'
2
2
  require 'etcd/client'
3
3
 
4
4
  module Etcd
5
+ class ClusterConnectError < RuntimeError
6
+ end
7
+
5
8
  class Client
6
9
 
7
10
  attr_reader :cluster
@@ -42,6 +45,7 @@ module Etcd
42
45
  end
43
46
 
44
47
  def cluster_http_request(req, options={})
48
+ errs = []
45
49
  cluster.each do |member|
46
50
  http = build_http_object(member[:host], member[:port], options)
47
51
  begin
@@ -50,18 +54,21 @@ module Etcd
50
54
  Log.debug("Response code: #{res.code}")
51
55
  Log.debug("Response body: #{res.body}")
52
56
  return process_http_request(res)
53
- rescue Timeout::Error
57
+ rescue Timeout::Error => e
54
58
  Log.debug("Connection timed out on #{member[:host]}:#{member[:host]}")
59
+ errs << e
55
60
  next
56
- rescue Errno::ECONNRESET
61
+ rescue Errno::ECONNRESET => e
57
62
  Log.debug("Connection reset on #{member[:host]}:#{member[:host]}")
63
+ errs << e
58
64
  next
59
- rescue Errno::ECONNREFUSED
65
+ rescue Errno::ECONNREFUSED => e
60
66
  Log.debug("Connection refused on #{member[:host]}:#{member[:host]}")
67
+ errs << e
61
68
  next
62
69
  end
63
70
  end
64
- fail "Couldn't connect to the ETCDcluster"
71
+ fail(Etcd::ClusterConnectError, "Couldn't connect to the ETCD cluster: #{errs.map(&:class).map(&:to_s)}")
65
72
  end
66
73
 
67
74
  def build_http_object(host, port, options={})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etcd-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radek 'blufor' Slavicinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-30 00:00:00.000000000 Z
11
+ date: 2016-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: etcd