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 +8 -8
- data/bin/pa-manager +3 -0
- data/lib/port-authority/{watchdog/master.rb → manager/app.rb} +22 -16
- data/lib/port-authority/{watchdog → manager}/init.rb +1 -1
- data/lib/port-authority/{watchdog → manager}/threads/icmp.rb +2 -2
- data/lib/port-authority/{watchdog → manager}/threads/swarm.rb +6 -6
- data/lib/port-authority.rb +1 -1
- metadata +7 -7
- data/bin/pa-master-watchdog +0 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Zjg2OGZmZTA1OWEwOTIzZGY5MDgwZmVhMWIxODEwNWE1NGVmOTgyMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDAwY2M3N2I1ZjBlM2MyZjM5M2U5MGRmNWI4MGQzZGM3MTc5OTc0NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmE5NGY5NzFmOGZkMjRjZjViMDUxZWY2MGQxM2M2M2Q4ZWJjM2ZhNjc0OGYy
|
10
|
+
M2ZhYWQwNTg1NTE5ZjU0MjJhMDI0MTY5OThkYWUxZTA3NTQwNGViZjljYjgx
|
11
|
+
MDcwZGZlYzQ2M2I4MGZhNzE5YTYxM2Q3MzY4NGYyYjg3MjVlZTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDc3NzIzZGQxMGE3NWYxZDUwZTM2M2Q0MWU0YzY2NTI5ODJlMzExZmE2YWRm
|
14
|
+
MWI3MzZhZTI5MjEyMTRhZWM3YTJkZTYwMjIyNTAxOTNlZjM1NTNkNDQ1MDAz
|
15
|
+
YTAxZmE2NGY4ZTdjMTdhOWE1NzQ3NjQ2OTg3Yzg3YTY0YzA3ZWE=
|
data/bin/pa-manager
ADDED
@@ -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/
|
6
|
-
require 'port-authority/
|
7
|
-
require 'port-authority/
|
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
|
11
|
-
class
|
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::
|
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-
|
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
|
-
|
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
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'net/ping'
|
2
2
|
|
3
3
|
module PortAuthority
|
4
|
-
module
|
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
|
-
|
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
|
2
|
+
module Manager
|
3
3
|
module Threads
|
4
4
|
def thread_swarm
|
5
5
|
Thread.new do
|
6
|
-
debug '
|
6
|
+
debug 'starting swarm thread...'
|
7
7
|
etcd = etcd_connect!
|
8
|
-
|
9
|
-
debug '
|
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 "
|
12
|
+
debug "i am #{status ? 'the leader' : 'not the leader' }"
|
13
13
|
sleep @config[:etcd][:interval]
|
14
14
|
end
|
15
|
-
info '
|
15
|
+
info 'ending swarm thread...'
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/port-authority.rb
CHANGED
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.
|
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-
|
96
|
+
- pa-manager
|
97
97
|
extensions: []
|
98
98
|
extra_rdoc_files: []
|
99
99
|
files:
|
100
|
-
- bin/pa-
|
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
|
data/bin/pa-master-watchdog
DELETED