port-authority 0.3.1 → 0.3.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
- OGQyMDZkOGNmMTM1ZTEyYTI4ZDA5YWYxZDc2M2ZhYjY5NDIwZGJmOA==
4
+ Zjg2OGZmZTA1OWEwOTIzZGY5MDgwZmVhMWIxODEwNWE1NGVmOTgyMw==
5
5
  data.tar.gz: !binary |-
6
- ZjMwNDUxNWY0MzllNTc2ZjZhNWEyZWQyYWNlYWY2NTQ4ZjhhM2NhOQ==
6
+ NDAwY2M3N2I1ZjBlM2MyZjM5M2U5MGRmNWI4MGQzZGM3MTc5OTc0NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDcxNWMxYTVhODE1MjMwM2U1ODk0OGUxOWQ0MDAyYWIzZTMwYTE4NGU3YWU4
10
- OGViYzJmODc4NmM4NjMwZmM3MTVkYTg1YWQ4Y2Y4NDdiMTFmODc3NDE1NzRm
11
- M2IzYWM2NDFhY2I1MTQzMjUwMmExNTFhMmRlMDhlOGY2Y2E3NWI=
9
+ NmE5NGY5NzFmOGZkMjRjZjViMDUxZWY2MGQxM2M2M2Q4ZWJjM2ZhNjc0OGYy
10
+ M2ZhYWQwNTg1NTE5ZjU0MjJhMDI0MTY5OThkYWUxZTA3NTQwNGViZjljYjgx
11
+ MDcwZGZlYzQ2M2I4MGZhNzE5YTYxM2Q3MzY4NGYyYjg3MjVlZTA=
12
12
  data.tar.gz: !binary |-
13
- YjM3ZDEzOGNmZmM4MDU2ZGY2ZDc0NDc1ZjE1OWZlYTI3NzkxN2E2MGE3MGZj
14
- NWI3MmQ4ZjBmNWRjMzBhYzQxZDc5Mjk0M2M3ZThhYWVkYjA3MjE0NGExYjE3
15
- ZjI2ZjhhZGRhMjc3MTdkYzI2YWNmNzdjMTJkOGI5ODQ2ZWJkZDk=
13
+ ZDc3NzIzZGQxMGE3NWYxZDUwZTM2M2Q0MWU0YzY2NTI5ODJlMzExZmE2YWRm
14
+ MWI3MzZhZTI5MjEyMTRhZWM3YTJkZTYwMjIyNTAxOTNlZjM1NTNkNDQ1MDAz
15
+ YTAxZmE2NGY4ZTdjMTdhOWE1NzQ3NjQ2OTg3Yzg3YTY0YzA3ZWE=
data/bin/pa-manager ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'port-authority/manager/app'
3
+ PortAuthority::Manager::App.new.run
@@ -2,18 +2,18 @@ require 'ipaddr'
2
2
  require 'port-authority/util/vip'
3
3
  require 'port-authority/util/etcd'
4
4
  require 'port-authority/util/loadbalancer'
5
- require 'port-authority/watchdog/init'
6
- require 'port-authority/watchdog/threads/icmp'
7
- require 'port-authority/watchdog/threads/swarm'
5
+ require 'port-authority/manager/init'
6
+ require 'port-authority/manager/threads/icmp'
7
+ require 'port-authority/manager/threads/swarm'
8
8
 
9
9
  module PortAuthority
10
- module Watchdog
11
- class Manager < PortAuthority::Watchdog::Init
10
+ module Manager
11
+ class App < PortAuthority::Manager::Init
12
12
 
13
13
  include PortAuthority::Util::Etcd
14
14
  include PortAuthority::Util::Vip
15
15
  include PortAuthority::Util::LoadBalancer
16
- include PortAuthority::Watchdog::Threads
16
+ include PortAuthority::Manager::Threads
17
17
 
18
18
  def run
19
19
  # exit if not root
@@ -23,7 +23,7 @@ module PortAuthority
23
23
  end
24
24
 
25
25
  # set process name and nice level (default: -20)
26
- setup 'pa-master-watchdog'
26
+ setup 'pa-manager'
27
27
 
28
28
  # prepare semaphores
29
29
  @semaphore = {
@@ -35,7 +35,7 @@ module PortAuthority
35
35
  # prepare threads
36
36
  @thread = {
37
37
  icmp: thread_icmp,
38
- etcd: thread_swarm,
38
+ swarm: thread_swarm
39
39
  }
40
40
 
41
41
  # prepare status vars
@@ -45,13 +45,19 @@ module PortAuthority
45
45
  # start threads
46
46
  @thread.each_value(&:run)
47
47
 
48
+ # setup docker client
49
+ lb_docker_setup! || @exit = true
50
+
51
+ # prepare container with load-balancer
52
+ lb_create || @exit = true
53
+
48
54
  # wait for threads to make sure they gather something
49
55
  debug 'waiting for threads to gather something...'
50
56
  sleep @config[:vip][:interval]
51
57
  first_cycle = true
52
58
 
53
59
  # main loop
54
- while !@exit do
60
+ until @exit
55
61
  # initialize local state vars on first iteration
56
62
  status_swarm = status_icmp = false if first_cycle
57
63
 
@@ -107,14 +113,14 @@ module PortAuthority
107
113
  end
108
114
  end
109
115
 
116
+ next unless first_cycle
117
+
110
118
  # short report on first cycle
111
- if first_cycle
112
- info "i #{status_swarm ? 'AM' : 'am NOT'} the leader"
113
- info "i #{got_vip? ? 'DO' : 'do NOT'} have the VIP"
114
- info "i #{status_icmp ? 'CAN' : 'CANNOT'} see the VIP"
115
- info "i #{status_haproxy ? 'CAN' : 'CANNOT'} see the VIP"
116
- first_cycle = false
117
- end
119
+ info "i #{status_swarm ? 'AM' : 'am NOT'} the leader"
120
+ info "i #{got_vip? ? 'DO' : 'do NOT'} have the VIP"
121
+ info "i #{status_icmp ? 'CAN' : 'CANNOT'} see the VIP"
122
+ info "i #{status_haproxy ? 'CAN' : 'CANNOT'} see the VIP"
123
+ first_cycle = false
118
124
  end
119
125
 
120
126
  # this is triggerred on exit
@@ -6,7 +6,7 @@ require 'port-authority/util/logger'
6
6
  require 'port-authority/util/helpers'
7
7
 
8
8
  module PortAuthority
9
- module Watchdog
9
+ module Manager
10
10
  class Init
11
11
 
12
12
  include PortAuthority::Util::Config
@@ -1,13 +1,13 @@
1
1
  require 'net/ping'
2
2
 
3
3
  module PortAuthority
4
- module Watchdog
4
+ module Manager
5
5
  module Threads
6
6
  def thread_icmp
7
7
  Thread.new do
8
8
  debug 'starting ICMP thread...'
9
9
  icmp = Net::Ping::ICMP.new(@config[:vip][:ip])
10
- while !@exit do
10
+ until @exit
11
11
  debug 'checking state by ICMP echo'
12
12
  status = vip_alive? icmp
13
13
  @semaphore[:icmp].synchronize { @status_icmp = status }
@@ -1,18 +1,18 @@
1
1
  module PortAuthority
2
- module Watchdog
2
+ module Manager
3
3
  module Threads
4
4
  def thread_swarm
5
5
  Thread.new do
6
- debug '<swarm> starting thread...'
6
+ debug 'starting swarm thread...'
7
7
  etcd = etcd_connect!
8
- while !@exit do
9
- debug '<swarm> checking etcd state'
8
+ until @exit
9
+ debug 'checking swarm state'
10
10
  status = am_i_leader? etcd
11
11
  @semaphore[:swarm].synchronize { @status_swarm = status }
12
- debug "<swarm> i am #{status ? 'the leader' : 'not the leader' }"
12
+ debug "i am #{status ? 'the leader' : 'not the leader' }"
13
13
  sleep @config[:etcd][:interval]
14
14
  end
15
- info '<swarm> ending thread...'
15
+ info 'ending swarm thread...'
16
16
  end
17
17
  end
18
18
  end
@@ -1,5 +1,5 @@
1
1
  module PortAuthority
2
- module Watchdog
2
+ module Manager
3
3
  end
4
4
 
5
5
  module Util
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: port-authority
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radek 'blufor' Slavicinsky
@@ -93,22 +93,22 @@ dependencies:
93
93
  description: Tools for PortAuthority
94
94
  email: radek.slavicinsky@gmail.com
95
95
  executables:
96
- - pa-master-watchdog
96
+ - pa-manager
97
97
  extensions: []
98
98
  extra_rdoc_files: []
99
99
  files:
100
- - bin/pa-master-watchdog
100
+ - bin/pa-manager
101
101
  - lib/port-authority.rb
102
+ - lib/port-authority/manager/app.rb
103
+ - lib/port-authority/manager/init.rb
104
+ - lib/port-authority/manager/threads/icmp.rb
105
+ - lib/port-authority/manager/threads/swarm.rb
102
106
  - lib/port-authority/util/config.rb
103
107
  - lib/port-authority/util/etcd.rb
104
108
  - lib/port-authority/util/helpers.rb
105
109
  - lib/port-authority/util/loadbalancer.rb
106
110
  - lib/port-authority/util/logger.rb
107
111
  - lib/port-authority/util/vip.rb
108
- - lib/port-authority/watchdog/init.rb
109
- - lib/port-authority/watchdog/master.rb
110
- - lib/port-authority/watchdog/threads/icmp.rb
111
- - lib/port-authority/watchdog/threads/swarm.rb
112
112
  homepage: https://github.com/blufor/etcd-tools
113
113
  licenses:
114
114
  - GPLv2
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'port-authority/watchdog/master'
3
- PortAuthority::Watchdog::Master.new.run