roadworker 0.5.5 → 0.5.6.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 020301db639766ed6efa723d241627914add396b
4
- data.tar.gz: 8c8242e53aeb94c4f2f61ce182b673aaaaa7f094
3
+ metadata.gz: 40f0aef1281b27f381e6b60cda6e47ffa0e07026
4
+ data.tar.gz: 2ab08cb9125e4dd16107e6b55b8a084ddfc633fb
5
5
  SHA512:
6
- metadata.gz: 456805190817cb751f87a3f8e8628ad8dc553c447bd68ef5fb7aaa0d1b7e7def8b0d188bba8dad2bd830cc6441335995d4b0ae6e917c7d196a5f54975fe3b06f
7
- data.tar.gz: ea121962bf0a34c2b8b766e63441e375cb1aa1877cf6994863457613b6eb8ce4e511e3d747b972cf59788b061c02fc4d9bfd1ab3b728416cae29db8fd05a843f
6
+ metadata.gz: 13bdec92a634305574206353c211b92f9ea88d889820b6456cf21c3c22a8a1d1bb4f04795fd587eb9cae30d9a9363e878bd70fa3b44c2b4f1aa13d644eb4ba6d
7
+ data.tar.gz: abfd581e1f6335183053bd67a410f25dd41f17a67892cc780eae2ab5379341716c14907f3cfd7e3c87a26d72737e65af98daaf6331866e6cd9694916ad03333e
data/README.md CHANGED
@@ -16,6 +16,10 @@ It defines the state of Route53 using DSL, and updates Route53 according to DSL.
16
16
  * **Disable Divided HostedZone**
17
17
  * **Use aws-sdk v2** [PR#20](https://github.com/winebarrel/roadworker/pull/20)
18
18
  * Support Cross Account ELB Alias [PR#21](https://github.com/winebarrel/roadworker/pull/21)
19
+ * `>= 0.5.6`
20
+ * Disable HealthCheck GC (pass `--health-check-gc` option if enable)
21
+ * Support Calculated Health Checks
22
+ * Support New Health Check attributes
19
23
 
20
24
  ## Installation
21
25
 
@@ -54,7 +58,7 @@ Usage: roadwork [options]
54
58
  -f, --file FILE
55
59
  --dry-run
56
60
  --force
57
- --no-health-check-gc
61
+ --health-check-gc
58
62
  -e, --export
59
63
  -o, --output FILE
60
64
  --split
@@ -140,6 +144,21 @@ hosted_zone "winebarrel.local." do
140
144
  end
141
145
  ```
142
146
 
147
+ ### Calculated Health Checks
148
+
149
+ ```ruby
150
+ rrset "zzz.info.winebarrel.jp", "A" do
151
+ set_identifier "Secondary"
152
+ failover "SECONDARY"
153
+ health_check :calculated => ["07c03a45-5b69-4044-9ec3-016cd8e5f74b", "bba4d1ea-27c2-4d0c-a249-c857a3e46d88"], :health_threshold => 1, :inverted => false
154
+ ttl 456
155
+ resource_records(
156
+ "127.0.0.3",
157
+ "127.0.0.4"
158
+ )
159
+ end
160
+ ```
161
+
143
162
  ### Dynamic private DNS example
144
163
 
145
164
  ```ruby
data/bin/roadwork CHANGED
@@ -49,7 +49,7 @@ ARGV.options do |opt|
49
49
  opt.on('-f', '--file FILE') {|v| file = v }
50
50
  opt.on('', '--dry-run') { options[:dry_run] = true }
51
51
  opt.on('' , '--force') { options[:force] = true }
52
- opt.on('', '--no-health-check-gc') { options[:no_health_check_gc] = true }
52
+ opt.on('', '--health-check-gc') { options[:health_check_gc] = true }
53
53
  opt.on('-e', '--export') { mode = :export }
54
54
  opt.on('-o', '--output FILE') {|v| output_file = v }
55
55
  opt.on('', '--split') { split = true }
@@ -72,7 +72,7 @@ ARGV.options do |opt|
72
72
  credentials_opts[:profile_name] = profile_name if profile_name
73
73
  credentials_opts[:path] = credentials_path if credentials_path
74
74
  provider = Aws::SharedCredentials.new(credentials_opts)
75
- aws_opts[:credential_provider] = provider
75
+ aws_opts[:credentials] = provider
76
76
  elsif (access_key and !secret_key) or (!access_key and secret_key) or mode.nil?
77
77
  puts opt.help
78
78
  exit 1
@@ -24,7 +24,7 @@ module Roadworker
24
24
  updated = @options.updated
25
25
  end
26
26
 
27
- if updated and not @options.no_health_check_gc
27
+ if updated and @options.health_check_gc
28
28
  HealthCheck.gc(@options.route53, :logger => @options.logger)
29
29
  end
30
30
 
@@ -33,10 +33,23 @@ module Roadworker
33
33
  end
34
34
  when :health_check_id
35
35
  config = HealthCheck.config_to_hash(@health_checks[value])
36
- hc_args = config[:url].sub(/\A(https?)_str_match:/) { $1 + ':' }.inspect
37
36
 
38
- [:host, :search_string, :request_interval, :failure_threshold].each do |key|
39
- if config[key]
37
+ if config[:calculated]
38
+ hc_args = ":calculated => #{config[:calculated].inspect}"
39
+ else
40
+ hc_args = config[:url].sub(/\A(https?)_str_match:/) { $1 + ':' }.inspect
41
+ end
42
+
43
+ [
44
+ :host,
45
+ :search_string,
46
+ :request_interval,
47
+ :health_threshold,
48
+ :failure_threshold,
49
+ :measure_latency,
50
+ :inverted,
51
+ ].each do |key|
52
+ unless config[key].nil?
40
53
  hc_args << ", :#{key} => #{config[key].inspect}"
41
54
  end
42
55
  end
@@ -132,39 +132,47 @@ module Roadworker
132
132
  @result.failover = value
133
133
  end
134
134
 
135
- def health_check(url, *options)
136
- config = HealthCheck.parse_url(url)
137
-
138
- if options.length == 1 and options.first.kind_of?(Hash)
139
- options = options.first
140
-
141
- {
142
- :host => :fully_qualified_domain_name,
143
- :search_string => :search_string,
144
- :request_interval => :request_interval,
145
- :failure_threshold => :failure_threshold,
146
- }.each do |option_key, config_key|
147
- config[config_key] = options[option_key] if options[option_key]
135
+ def health_check(url, options = {})
136
+ unless options.kind_of?(Hash)
137
+ raise TypeError, "wrong argument type #{options.inspect} (expected Hash)"
138
+ end
139
+
140
+ if url.kind_of?(Hash)
141
+ if url.include?(:calculated)
142
+ config = Aws::Route53::Types::HealthCheckConfig.new
143
+ config[:type] = 'CALCULATED'
144
+ config[:child_health_checks] = url.delete(:calculated)
145
+ options = url
146
+ else
147
+ raise ArgumentError, "wrong arguments: #{url.inspect}"
148
148
  end
149
149
  else
150
- options.each_with_index do |value, i|
151
- key = [
152
- :fully_qualified_domain_name,
153
- :search_string,
154
- :request_interval,
155
- :failure_threshold,
156
- ][i]
157
-
158
- config[key] = value
159
- end
150
+ config = HealthCheck.parse_url(url)
151
+ config[:child_health_checks] = []
152
+ end
153
+
154
+ {
155
+ :host => :fully_qualified_domain_name,
156
+ :search_string => :search_string,
157
+ :request_interval => :request_interval,
158
+ :health_threshold => :health_threshold,
159
+ :failure_threshold => :failure_threshold,
160
+ :measure_latency => :measure_latency,
161
+ :inverted => :inverted
162
+ }.each do |option_key, config_key|
163
+ config[config_key] = options[option_key] unless options[option_key].nil?
160
164
  end
161
165
 
162
166
  if config.search_string
163
167
  config.type += '_STR_MATCH'
164
168
  end
165
169
 
166
- config.request_interval ||= 30
167
- config.failure_threshold ||= 3
170
+ if config[:type] != 'CALCULATED'
171
+ config[:request_interval] ||= 30
172
+ config[:failure_threshold] ||= 3
173
+ config[:measure_latency] ||= false
174
+ config[:inverted] ||= false
175
+ end
168
176
 
169
177
  @result.health_check = config
170
178
  end
@@ -11,41 +11,56 @@ module Roadworker
11
11
  end
12
12
 
13
13
  def config_to_hash(config)
14
- ipaddr = config[:ip_address]
15
- port = config[:port]
16
- type = config[:type].downcase
17
- path = config[:resource_path]
18
- fqdn = config[:fully_qualified_domain_name]
19
- fqdn = fqdn.downcase if fqdn
20
- search_string = config[:search_string]
21
- request_interval = config[:request_interval]
22
- failure_threshold = config[:failure_threshold]
23
-
24
- ulr = nil
25
-
26
- if ipaddr
27
- url = "#{type}://#{ipaddr}:#{port}"
14
+ type = config[:type].downcase
15
+
16
+ if type == 'calculated'
17
+ hash = {:calculated => config[:child_health_checks]}
28
18
  else
29
- url = "#{type}://#{fqdn}:#{port}"
30
- fqdn = nil
19
+ ipaddr = config[:ip_address]
20
+ port = config[:port]
21
+ path = config[:resource_path]
22
+ fqdn = config[:fully_qualified_domain_name]
23
+ fqdn = fqdn.downcase if fqdn
24
+
25
+ if ipaddr
26
+ url = "#{type}://#{ipaddr}:#{port}"
27
+ else
28
+ url = "#{type}://#{fqdn}:#{port}"
29
+ fqdn = nil
30
+ end
31
+
32
+ url << path if path && path != '/'
33
+
34
+ hash = {
35
+ :url => url,
36
+ :host => fqdn,
37
+ }
31
38
  end
32
39
 
33
- url << path if path && path != '/'
40
+ [
41
+ :search_string,
42
+ :request_interval,
43
+ :health_threshold,
44
+ :failure_threshold,
45
+ :measure_latency,
46
+ :inverted,
47
+ ].each do |key|
48
+ hash[key] = config[key] unless config[key].nil?
49
+ end
34
50
 
35
- {
36
- :url => url,
37
- :host => fqdn,
38
- :search_string => search_string,
39
- :request_interval => request_interval,
40
- :failure_threshold => failure_threshold,
41
- }
51
+ hash
42
52
  end
43
53
 
44
54
  def parse_url(url)
45
55
  url = URI.parse(url)
56
+ type = url.scheme.upcase
46
57
  path = url.path
47
58
 
48
- if path.nil? or path.empty? or path == '/'
59
+ if type =~ /\AHTTP/
60
+ if path.nil? or path.empty?
61
+ path = '/'
62
+ end
63
+ else
49
64
  path = nil
50
65
  end
51
66
 
@@ -53,7 +68,7 @@ module Roadworker
53
68
 
54
69
  {
55
70
  :port => url.port,
56
- :type => url.scheme.upcase,
71
+ :type => type,
57
72
  :resource_path => path,
58
73
  }.each {|key, value|
59
74
  config[key] = value if value
@@ -98,8 +113,12 @@ module Roadworker
98
113
  health_check_id, config = self.find {|hcid, elems| elems == attrs }
99
114
 
100
115
  unless health_check_id
116
+ if attrs[:child_health_checks] and attrs[:child_health_checks].empty?
117
+ attrs[:child_health_checks] = nil
118
+ end
119
+
101
120
  response = @route53.create_health_check({
102
- :caller_reference => UUID.new.generate,
121
+ :caller_reference => "roadworker #{Roadworker::VERSION} #{UUID.new.generate}",
103
122
  :health_check_config => attrs,
104
123
  })
105
124
 
@@ -120,16 +139,22 @@ module Roadworker
120
139
  return if check_list.empty?
121
140
 
122
141
  if (logger = options[:logger])
123
- logger.info('Clean HealthChecks (pass `--no-health-check-gc` if you do not want to clean)')
142
+ logger.info('Clean HealthChecks')
124
143
  end
125
144
 
126
145
  Collection.batch(@route53.list_hosted_zones, :hosted_zones) do |zone|
127
146
  Collection.batch(@route53.list_resource_record_sets(hosted_zone_id: zone.id), :resource_record_sets) do |record|
128
- check_list.delete(record.health_check_id)
147
+ health_check = check_list.delete(record.health_check_id)
148
+
149
+ if health_check and health_check.type == 'CALCULATED'
150
+ health_check.child_health_checks.each do |child|
151
+ check_list.delete(child)
152
+ end
153
+ end
129
154
  end
130
155
  end
131
156
 
132
- check_list.each do |health_check_id, config|
157
+ check_list.sort_by {|hc_id, hc| hc.type == 'CALCULATED' ? 0 : 1 }.each do |health_check_id, config|
133
158
  @route53.delete_health_check(:health_check_id => health_check_id)
134
159
  end
135
160
  end
@@ -59,8 +59,8 @@ module Roadworker
59
59
  zone = OpenStruct.new({:name => name, :rrsets => [], :vpcs => vpcs}.merge(opts))
60
60
  else
61
61
  params = {
62
- name: name,
63
- caller_reference: "CreateHostedZone by roadworker #{Roadworker::VERSION}, #{name}, #{Time.now.httpdate}",
62
+ :name => name,
63
+ :caller_reference => "roadworker #{Roadworker::VERSION} #{UUID.new.generate}",
64
64
  }
65
65
  if vpc
66
66
  params[:vpc] = vpc
File without changes
@@ -1,3 +1,3 @@
1
1
  module Roadworker
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.6.beta"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roadworker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-12 00:00:00.000000000 Z
11
+ date: 2015-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 2.1.0
19
+ version: 2.1.23
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 2.1.0
26
+ version: 2.1.23
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: term-ansicolor
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -202,6 +202,7 @@ extra_rdoc_files: []
202
202
  files:
203
203
  - README.md
204
204
  - bin/roadwork
205
+ - lib/roadworker.rb
205
206
  - lib/roadworker/client.rb
206
207
  - lib/roadworker/collection.rb
207
208
  - lib/roadworker/dsl-converter.rb
@@ -214,9 +215,9 @@ files:
214
215
  - lib/roadworker/route53-wrapper.rb
215
216
  - lib/roadworker/string-ext.rb
216
217
  - lib/roadworker/struct-ext.rb
218
+ - lib/roadworker/template_helper.rb
217
219
  - lib/roadworker/utils.rb
218
220
  - lib/roadworker/version.rb
219
- - lib/roadworker.rb
220
221
  homepage: http://roadworker.codenize.tools/
221
222
  licenses:
222
223
  - MIT
@@ -232,12 +233,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
233
  version: '0'
233
234
  required_rubygems_version: !ruby/object:Gem::Requirement
234
235
  requirements:
235
- - - '>='
236
+ - - '>'
236
237
  - !ruby/object:Gem::Version
237
- version: '0'
238
+ version: 1.3.1
238
239
  requirements: []
239
240
  rubyforge_project:
240
- rubygems_version: 2.0.14
241
+ rubygems_version: 2.4.8
241
242
  signing_key:
242
243
  specification_version: 4
243
244
  summary: Roadworker is a tool to manage Route53.