hako 2.3.0 → 2.3.1
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/docs/ecs-task-notification.md +8 -5
- data/lib/hako/application.rb +2 -2
- data/lib/hako/cli.rb +20 -19
- data/lib/hako/commander.rb +6 -6
- data/lib/hako/container.rb +2 -2
- data/lib/hako/env_expander.rb +5 -0
- data/lib/hako/env_providers/file.rb +1 -0
- data/lib/hako/schedulers/ecs.rb +13 -4
- data/lib/hako/schedulers/ecs_autoscaling.rb +2 -0
- data/lib/hako/schedulers/ecs_elb_v2.rb +1 -0
- data/lib/hako/schema/structure.rb +1 -0
- data/lib/hako/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 126110ac130316221e7ac640144170031d9efceb2cf81f89c1c22525d2be6275
|
4
|
+
data.tar.gz: dd1934716a185d3e653b6d0343424b72a3afd62207ad566568b7ea19218d997d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce6f9bba7385b6cdba908d70e268a299e24db76a63276cc96ae774f7d699ac830acce6224eaabf08caae2dc7d50d7df9a76b2dbcb206438e3920b97d6f84a182
|
7
|
+
data.tar.gz: 6954189052e21677c5cda4dab43b438b88287ae6975160a82bdd8c7350d2a3eb5630411f6e798a756cb9f53bd46b91ade81e04cd9e7e5eabcb81034972183bb2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 2.3.1 (2018-09-26)
|
2
|
+
## Changes
|
3
|
+
- Change show-definition output from YAML to JSON
|
4
|
+
- The show-definition output is still persable as YAML
|
5
|
+
|
6
|
+
## Bug fixes
|
7
|
+
- Set `deployment_configuration` to nil when absent
|
8
|
+
|
1
9
|
# 2.3.0 (2018-08-30)
|
2
10
|
## New features
|
3
11
|
- Support `health_check` parameter
|
@@ -13,12 +13,15 @@ Amazon S3 is a good storage for polling, so connecting CloudWatch Events to AWS
|
|
13
13
|
|
14
14
|
The example implementation of AWS Lambda can be found in [../examples/put-ecs-container-status-to-s3](../examples/put-ecs-container-status-to-s3) directory.
|
15
15
|
|
16
|
-
To enable task notification with S3, you have to configure scheduler in
|
16
|
+
To enable task notification with S3, you have to configure scheduler in definition file.
|
17
17
|
|
18
|
-
```
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
```js
|
19
|
+
{
|
20
|
+
scheduler: {
|
21
|
+
type: 'ecs',
|
22
|
+
oneshot_notification_prefix: 's3://ecs-task-notifications/task_statuses?region=ap-northeast-1',
|
23
|
+
},
|
24
|
+
}
|
22
25
|
```
|
23
26
|
|
24
27
|
It uses ecs-task-notifications bucket in ap-northeast-1 region.
|
data/lib/hako/application.rb
CHANGED
@@ -15,8 +15,8 @@ module Hako
|
|
15
15
|
# @return [Hash]
|
16
16
|
attr_reader :id, :root_path, :definition
|
17
17
|
|
18
|
-
def initialize(
|
19
|
-
path = Pathname.new(
|
18
|
+
def initialize(definition_path, expand_variables: true, ask_keys: false)
|
19
|
+
path = Pathname.new(definition_path)
|
20
20
|
@id = path.basename.sub_ext('').to_s
|
21
21
|
@root_path = path.parent
|
22
22
|
@definition =
|
data/lib/hako/cli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'hako'
|
4
|
+
require 'json'
|
4
5
|
require 'optparse'
|
5
6
|
require 'pathname'
|
6
7
|
|
@@ -72,7 +73,7 @@ module Hako
|
|
72
73
|
else
|
73
74
|
{}
|
74
75
|
end
|
75
|
-
Commander.new(Application.new(@
|
76
|
+
Commander.new(Application.new(@definition_path, options)).deploy(force: @force, tag: @tag, dry_run: @dry_run, timeout: @timeout)
|
76
77
|
end
|
77
78
|
|
78
79
|
DEFAULT_TIMEOUT = 1200 # 20 minutes
|
@@ -84,9 +85,9 @@ module Hako
|
|
84
85
|
@verbose = false
|
85
86
|
@timeout = DEFAULT_TIMEOUT
|
86
87
|
parser.parse!(argv)
|
87
|
-
@
|
88
|
+
@definition_path = argv.first
|
88
89
|
|
89
|
-
if @
|
90
|
+
if @definition_path.nil?
|
90
91
|
puts parser.help
|
91
92
|
exit 1
|
92
93
|
end
|
@@ -121,16 +122,16 @@ module Hako
|
|
121
122
|
else
|
122
123
|
{}
|
123
124
|
end
|
124
|
-
Commander.new(Application.new(@
|
125
|
+
Commander.new(Application.new(@definition_path, options)).rollback(dry_run: @dry_run)
|
125
126
|
end
|
126
127
|
|
127
128
|
def parse!(argv)
|
128
129
|
@dry_run = false
|
129
130
|
@verbose = false
|
130
131
|
parser.parse!(argv)
|
131
|
-
@
|
132
|
+
@definition_path = argv.first
|
132
133
|
|
133
|
-
if @
|
134
|
+
if @definition_path.nil?
|
134
135
|
puts parser.help
|
135
136
|
exit 1
|
136
137
|
end
|
@@ -162,7 +163,7 @@ module Hako
|
|
162
163
|
else
|
163
164
|
{}
|
164
165
|
end
|
165
|
-
Commander.new(Application.new(@
|
166
|
+
Commander.new(Application.new(@definition_path, options)).oneshot(@argv, tag: @tag, containers: @containers, env: @env, dry_run: @dry_run, no_wait: @no_wait)
|
166
167
|
end
|
167
168
|
|
168
169
|
def parse!(argv)
|
@@ -173,10 +174,10 @@ module Hako
|
|
173
174
|
@verbose = false
|
174
175
|
@no_wait = false
|
175
176
|
parser.parse!(argv)
|
176
|
-
@
|
177
|
+
@definition_path = argv.shift
|
177
178
|
@argv = argv
|
178
179
|
|
179
|
-
if @
|
180
|
+
if @definition_path.nil? || @argv.empty?
|
180
181
|
puts parser.help
|
181
182
|
exit 1
|
182
183
|
end
|
@@ -204,7 +205,7 @@ module Hako
|
|
204
205
|
parse!(argv)
|
205
206
|
require 'hako/application'
|
206
207
|
app = Application.new(@path, expand_variables: @expand_variables)
|
207
|
-
puts app.definition
|
208
|
+
puts JSON.pretty_generate(app.definition)
|
208
209
|
end
|
209
210
|
|
210
211
|
def parse!(argv)
|
@@ -231,14 +232,14 @@ module Hako
|
|
231
232
|
parse!(argv)
|
232
233
|
require 'hako/application'
|
233
234
|
require 'hako/commander'
|
234
|
-
Commander.new(Application.new(@
|
235
|
+
Commander.new(Application.new(@definition_path, expand_variables: false)).status
|
235
236
|
end
|
236
237
|
|
237
238
|
def parse!(argv)
|
238
239
|
parser.parse!(argv)
|
239
|
-
@
|
240
|
+
@definition_path = argv.first
|
240
241
|
|
241
|
-
if @
|
242
|
+
if @definition_path.nil?
|
242
243
|
puts parser.help
|
243
244
|
exit 1
|
244
245
|
end
|
@@ -258,15 +259,15 @@ module Hako
|
|
258
259
|
require 'hako/application'
|
259
260
|
require 'hako/commander'
|
260
261
|
|
261
|
-
Commander.new(Application.new(@
|
262
|
+
Commander.new(Application.new(@definition_path, expand_variables: false)).remove(dry_run: @dry_run)
|
262
263
|
end
|
263
264
|
|
264
265
|
def parse!(argv)
|
265
266
|
@dry_run = false
|
266
267
|
parser.parse!(argv)
|
267
|
-
@
|
268
|
+
@definition_path = argv.first
|
268
269
|
|
269
|
-
if @
|
270
|
+
if @definition_path.nil?
|
270
271
|
puts parser.help
|
271
272
|
exit 1
|
272
273
|
end
|
@@ -287,15 +288,15 @@ module Hako
|
|
287
288
|
require 'hako/application'
|
288
289
|
require 'hako/commander'
|
289
290
|
|
290
|
-
Commander.new(Application.new(@
|
291
|
+
Commander.new(Application.new(@definition_path, expand_variables: false)).stop(dry_run: @dry_run)
|
291
292
|
end
|
292
293
|
|
293
294
|
def parse!(argv)
|
294
295
|
@dry_run = false
|
295
296
|
parser.parse!(argv)
|
296
|
-
@
|
297
|
+
@definition_path = argv.first
|
297
298
|
|
298
|
-
if @
|
299
|
+
if @definition_path.nil?
|
299
300
|
puts parser.help
|
300
301
|
exit 1
|
301
302
|
end
|
data/lib/hako/commander.rb
CHANGED
@@ -118,21 +118,21 @@ module Hako
|
|
118
118
|
DefinitionLoader.new(@app, dry_run: dry_run).load(tag, with: with)
|
119
119
|
end
|
120
120
|
|
121
|
-
# @param [Hash]
|
121
|
+
# @param [Hash] scheduler_definition
|
122
122
|
# @param [Hash] volumes
|
123
123
|
# @param [Boolean] force
|
124
124
|
# @param [Boolean] dry_run
|
125
125
|
# @param [Integer] timeout
|
126
126
|
# @return [Scheduler]
|
127
|
-
def load_scheduler(
|
128
|
-
Loader.new(Hako::Schedulers, 'hako/schedulers').load(
|
127
|
+
def load_scheduler(scheduler_definition, scripts, volumes: {}, force: false, dry_run:, timeout: nil)
|
128
|
+
Loader.new(Hako::Schedulers, 'hako/schedulers').load(scheduler_definition.fetch('type')).new(@app.id, scheduler_definition, volumes: volumes, scripts: scripts, force: force, dry_run: dry_run, timeout: timeout)
|
129
129
|
end
|
130
130
|
|
131
|
-
# @param [Hash]
|
131
|
+
# @param [Hash] script_definition
|
132
132
|
# @param [Boolean] dry_run
|
133
133
|
# @return [Script]
|
134
|
-
def load_script(
|
135
|
-
Loader.new(Hako::Scripts, 'hako/scripts').load(
|
134
|
+
def load_script(script_definition, dry_run:)
|
135
|
+
Loader.new(Hako::Scripts, 'hako/scripts').load(script_definition.fetch('type')).new(@app, script_definition, dry_run: dry_run)
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
data/lib/hako/container.rb
CHANGED
@@ -195,8 +195,8 @@ module Hako
|
|
195
195
|
# @param [Array<Hash>] provider_configs
|
196
196
|
# @return [Array<EnvProvider>]
|
197
197
|
def load_providers(provider_configs)
|
198
|
-
provider_configs.map do |
|
199
|
-
Loader.new(Hako::EnvProviders, 'hako/env_providers').load(
|
198
|
+
provider_configs.map do |provider_config|
|
199
|
+
Loader.new(Hako::EnvProviders, 'hako/env_providers').load(provider_config.fetch('type')).new(@app.root_path, provider_config)
|
200
200
|
end
|
201
201
|
end
|
202
202
|
|
data/lib/hako/env_expander.rb
CHANGED
@@ -36,6 +36,7 @@ module Hako
|
|
36
36
|
if variables.empty?
|
37
37
|
break
|
38
38
|
end
|
39
|
+
|
39
40
|
provider.ask(variables.to_a).each do |var, val|
|
40
41
|
values[var] = val
|
41
42
|
variables.delete(var)
|
@@ -69,6 +70,7 @@ module Hako
|
|
69
70
|
if variables.empty?
|
70
71
|
break
|
71
72
|
end
|
73
|
+
|
72
74
|
if provider.can_ask_keys?
|
73
75
|
provider.ask_keys(variables.to_a).each do |var|
|
74
76
|
variables.delete(var)
|
@@ -81,6 +83,7 @@ module Hako
|
|
81
83
|
unless variables.empty?
|
82
84
|
raise ExpansionError.new("Could not find embedded variables from $providers=#{@providers}: #{variables.to_a}")
|
83
85
|
end
|
86
|
+
|
84
87
|
true
|
85
88
|
end
|
86
89
|
|
@@ -94,6 +97,7 @@ module Hako
|
|
94
97
|
unless val.is_a?(String)
|
95
98
|
raise ExpansionError.new("#{key} must be a String but got #{val.class}: #{val.inspect}")
|
96
99
|
end
|
100
|
+
|
97
101
|
parsed_env[key] = parse(val)
|
98
102
|
end
|
99
103
|
parsed_env
|
@@ -116,6 +120,7 @@ module Hako
|
|
116
120
|
else
|
117
121
|
tokens << Variable.new(var)
|
118
122
|
end
|
123
|
+
|
119
124
|
pos = s.pos
|
120
125
|
end
|
121
126
|
unless s.rest.empty?
|
data/lib/hako/schedulers/ecs.rb
CHANGED
@@ -54,9 +54,13 @@ module Hako
|
|
54
54
|
validation_error!('autoscaling_group_for_oneshot must be set when autoscaling_topic_for_oneshot is set')
|
55
55
|
end
|
56
56
|
@oneshot_notification_prefix = options.fetch('oneshot_notification_prefix', nil)
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
if options.key?('deployment_configuration')
|
58
|
+
@deployment_configuration = {}
|
59
|
+
%i[maximum_percent minimum_healthy_percent].each do |key|
|
60
|
+
@deployment_configuration[key] = options.fetch('deployment_configuration')[key.to_s]
|
61
|
+
end
|
62
|
+
else
|
63
|
+
@deployment_configuration = nil
|
60
64
|
end
|
61
65
|
@placement_constraints = options.fetch('placement_constraints', [])
|
62
66
|
@placement_strategy = options.fetch('placement_strategy', [])
|
@@ -358,6 +362,7 @@ module Hako
|
|
358
362
|
if @dry_run
|
359
363
|
return DEFAULT_FRONT_PORT
|
360
364
|
end
|
365
|
+
|
361
366
|
service = describe_service
|
362
367
|
if service
|
363
368
|
find_front_port(service)
|
@@ -412,6 +417,7 @@ module Hako
|
|
412
417
|
# Initial deployment
|
413
418
|
return true
|
414
419
|
end
|
420
|
+
|
415
421
|
actual_volume_definitions = {}
|
416
422
|
actual_definition.volumes.each do |v|
|
417
423
|
actual_volume_definitions[v.name] = v
|
@@ -628,6 +634,7 @@ module Hako
|
|
628
634
|
if result.tasks.empty?
|
629
635
|
raise NoTasksStarted.new('No tasks started')
|
630
636
|
end
|
637
|
+
|
631
638
|
result.tasks[0]
|
632
639
|
rescue Aws::ECS::Errors::InvalidParameterException => e
|
633
640
|
if e.message == 'No Container Instances were found in your cluster.' && on_no_tasks_started(task_definition)
|
@@ -874,6 +881,7 @@ module Hako
|
|
874
881
|
if e.id == latest_event_id
|
875
882
|
break
|
876
883
|
end
|
884
|
+
|
877
885
|
Hako.logger.info "#{e.created_at}: #{e.message}"
|
878
886
|
task_id = extract_task_id(e.message)
|
879
887
|
if task_id && e.message.include?(' has started ')
|
@@ -1114,6 +1122,7 @@ module Hako
|
|
1114
1122
|
source_volume = mount_point.fetch(:source_volume)
|
1115
1123
|
v = volumes_definition.find { |d| d[:name] == source_volume }
|
1116
1124
|
raise "Could not find volume #{source_volume}" unless v
|
1125
|
+
|
1117
1126
|
source = v.dig(:host, :source_path) || source_volume
|
1118
1127
|
cmd << '--volume' << "#{source}:#{mount_point.fetch(:container_path)}#{mount_point[:read_only] ? ':ro' : ''}"
|
1119
1128
|
end
|
@@ -1171,7 +1180,7 @@ module Hako
|
|
1171
1180
|
definition.fetch(:environment).each do |env|
|
1172
1181
|
name = env.fetch(:name)
|
1173
1182
|
value = env.fetch(:value)
|
1174
|
-
# additional_env (given in command line) has priority over env (declared in
|
1183
|
+
# additional_env (given in command line) has priority over env (declared in definition file)
|
1175
1184
|
unless additional_env.key?(name)
|
1176
1185
|
cmd << '--env' << "#{name}=#{value}"
|
1177
1186
|
cmd << "\\\n "
|
@@ -80,10 +80,12 @@ module Hako
|
|
80
80
|
if service.load_balancers.empty? || service.load_balancers[0].target_group_arn.nil?
|
81
81
|
raise Error.new('Target group must be attached to the ECS service for predefined metric type ALBRequestCountPerTarget')
|
82
82
|
end
|
83
|
+
|
83
84
|
resource_label = target_group_resource_label
|
84
85
|
unless resource_label.start_with?('app/')
|
85
86
|
raise Error.new("Load balancer type must be 'application' for predefined metric type ALBRequestCountPerTarget")
|
86
87
|
end
|
88
|
+
|
87
89
|
predefined_metric_specification[:resource_label] = resource_label
|
88
90
|
end
|
89
91
|
policy_params[:target_tracking_scaling_policy_configuration] = {
|
data/lib/hako/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hako
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kohei Suzuki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-applicationautoscaling
|