dnsync 1.0.4 → 1.0.5
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.
- data/dnsync.gemspec +2 -2
- data/lib/dnsync.rb +1 -1
- data/lib/dnsync/cli.rb +5 -1
- data/lib/dnsync/recurring_zone_updater.rb +11 -6
- metadata +2 -2
data/dnsync.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'dnsync'
|
16
|
-
s.version = '1.0.
|
17
|
-
s.date = '2015-03
|
16
|
+
s.version = '1.0.5'
|
17
|
+
s.date = '2015-06-03'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|
20
20
|
## as you like.
|
data/lib/dnsync.rb
CHANGED
data/lib/dnsync/cli.rb
CHANGED
@@ -57,6 +57,9 @@ module Dnsync
|
|
57
57
|
opts.on("--status-port=PORT", "Port to run status HTTP server on") do |v|
|
58
58
|
Configlet[:status_port] = v
|
59
59
|
end
|
60
|
+
opts.on("--status-grace-period=PERIOD", "Number of failed updates before reporting an error") do |v|
|
61
|
+
Configlet[:status_grace_period] = v
|
62
|
+
end
|
60
63
|
opts.on("--noop", "Don't do any write operations") do |v|
|
61
64
|
Configlet[:noop] = v.to_s
|
62
65
|
end
|
@@ -162,7 +165,8 @@ module Dnsync
|
|
162
165
|
Configlet[:dnsimple_token], Configlet[:domain])
|
163
166
|
|
164
167
|
updater = RecurringZoneUpdater.new(dnsimple, nsone,
|
165
|
-
Configlet[:monitor_frequency] || 10
|
168
|
+
Configlet[:monitor_frequency] || 10,
|
169
|
+
Configlet[:status_grace_period] || 5)
|
166
170
|
updater.start
|
167
171
|
|
168
172
|
if status_port = Configlet[:status_port]
|
@@ -3,15 +3,17 @@ require 'atomic'
|
|
3
3
|
|
4
4
|
module Dnsync
|
5
5
|
class RecurringZoneUpdater
|
6
|
-
def initialize(source, destination, frequency)
|
7
|
-
@source
|
8
|
-
@destination
|
9
|
-
@frequency
|
6
|
+
def initialize(source, destination, frequency, grace_period)
|
7
|
+
@source = source
|
8
|
+
@destination = destination
|
9
|
+
@frequency = frequency.to_i
|
10
|
+
@grace_period = grace_period.to_i
|
10
11
|
|
11
12
|
@thread = Atomic.new(nil)
|
12
13
|
@running = Atomic.new(false)
|
13
14
|
@last_updated_at = Atomic.new(nil)
|
14
15
|
@last_exception = Atomic.new(nil)
|
16
|
+
@failures = Atomic.new(0)
|
15
17
|
end
|
16
18
|
|
17
19
|
def start
|
@@ -50,6 +52,7 @@ module Dnsync
|
|
50
52
|
running = @running.value
|
51
53
|
updated = last_updated
|
52
54
|
exception = @last_exception.value
|
55
|
+
failures = @failures.value
|
53
56
|
|
54
57
|
problems = []
|
55
58
|
|
@@ -71,7 +74,7 @@ module Dnsync
|
|
71
74
|
problems << "Successful update hasn't occured #{time_description}"
|
72
75
|
end
|
73
76
|
|
74
|
-
if exception
|
77
|
+
if exception && failures > @grace_period
|
75
78
|
problems << "Last update failed with #{exception.class}: #{exception.message}"
|
76
79
|
end
|
77
80
|
|
@@ -82,7 +85,7 @@ module Dnsync
|
|
82
85
|
|
83
86
|
def recently_updated?(updated = nil)
|
84
87
|
updated ||= last_updated
|
85
|
-
updated && updated < (@frequency *
|
88
|
+
updated && updated < (@frequency * @grace_period)
|
86
89
|
end
|
87
90
|
|
88
91
|
def last_updated
|
@@ -122,9 +125,11 @@ module Dnsync
|
|
122
125
|
active_zone = source_zone
|
123
126
|
@last_updated_at.value = Time.now
|
124
127
|
@last_exception.value = nil
|
128
|
+
@failures.value = 0
|
125
129
|
rescue => e
|
126
130
|
Scrolls.log_exception({ :from => :recurring_zone_updater, :zone => @source.domain }, e)
|
127
131
|
@last_exception.value = e
|
132
|
+
@failures.update { |v| v + 1 }
|
128
133
|
end
|
129
134
|
|
130
135
|
if @running.value
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03
|
12
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|