hako 1.8.3 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +5 -0
- data/examples/hello-cap-add-app.yml +13 -0
- data/hako.gemspec +1 -1
- data/lib/hako/container.rb +30 -0
- data/lib/hako/schedulers/ecs.rb +32 -3
- data/lib/hako/schedulers/ecs_definition_comparator.rb +28 -0
- data/lib/hako/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70c493530e6b2a7355d402ae08d9305cbcdc5c89
|
4
|
+
data.tar.gz: fce07c67ce4a4d0c438b4ea341ae29ac72ccae7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d175b26ce5af0c9bb6b23a1a7c91d61cc44794ee9add9a8efd6a8e9a2a0ee8f8ab21a2572a184632437b1e78e6f2962532628e06af8d9a9778fdb17ddf5784b
|
7
|
+
data.tar.gz: 0fbfb30c8c28f6e42564765e8b49c81462729399706ba70fe8c60aaa7ac4202ae17703fad572712632f8f0842bc5e06561db50c42c04f4a52c5fb76125659c8a
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/hako.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_dependency 'aws-sdk-cloudwatch'
|
27
27
|
spec.add_dependency 'aws-sdk-cloudwatchlogs'
|
28
28
|
spec.add_dependency 'aws-sdk-ec2'
|
29
|
-
spec.add_dependency 'aws-sdk-ecs'
|
29
|
+
spec.add_dependency 'aws-sdk-ecs', '>= 1.4.0'
|
30
30
|
spec.add_dependency 'aws-sdk-elasticloadbalancing'
|
31
31
|
spec.add_dependency 'aws-sdk-elasticloadbalancingv2'
|
32
32
|
spec.add_dependency 'aws-sdk-s3'
|
data/lib/hako/container.rb
CHANGED
@@ -112,6 +112,36 @@ module Hako
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
+
# @return [Hash, nil]
|
116
|
+
def linux_parameters
|
117
|
+
if @definition.key?('linux_parameters')
|
118
|
+
ret = {}
|
119
|
+
conf = @definition['linux_parameters']
|
120
|
+
|
121
|
+
if conf.key?('capabilities')
|
122
|
+
cap = conf['capabilities']
|
123
|
+
ret[:capabilities] = {
|
124
|
+
add: cap.fetch('add', []),
|
125
|
+
drop: cap.fetch('drop', [])
|
126
|
+
}
|
127
|
+
end
|
128
|
+
|
129
|
+
if conf.key?('devices')
|
130
|
+
ret[:devices] = conf['devices'].map do |d|
|
131
|
+
{
|
132
|
+
host_path: d.fetch('host_path'),
|
133
|
+
container_path: d.fetch('container_path', nil),
|
134
|
+
permissions: d.fetch('permissions', [])
|
135
|
+
}
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
ret[:init_process_enabled] = conf.fetch('init_process_enabled', nil)
|
140
|
+
|
141
|
+
ret
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
115
145
|
private
|
116
146
|
|
117
147
|
PROVIDERS_KEY = '$providers'
|
data/lib/hako/schedulers/ecs.rb
CHANGED
@@ -513,6 +513,7 @@ module Hako
|
|
513
513
|
mount_points: container.mount_points,
|
514
514
|
command: container.command,
|
515
515
|
privileged: container.privileged,
|
516
|
+
linux_parameters: container.linux_parameters,
|
516
517
|
volumes_from: container.volumes_from,
|
517
518
|
user: container.user,
|
518
519
|
log_configuration: container.log_configuration,
|
@@ -651,7 +652,7 @@ module Hako
|
|
651
652
|
# The JSON is supposed to be stored from Amazon ECS Event Stream.
|
652
653
|
# http://docs.aws.amazon.com/AmazonECS/latest/developerguide/cloudwatch_event_stream.html
|
653
654
|
def poll_task_status_from_s3(task)
|
654
|
-
s3 = Aws::S3::Client.new
|
655
|
+
s3 = Aws::S3::Client.new(region: @region)
|
655
656
|
task_arn = task.task_arn
|
656
657
|
uri = URI.parse(@oneshot_notification_prefix)
|
657
658
|
prefix = uri.path.sub(%r{\A/}, '')
|
@@ -885,7 +886,7 @@ module Hako
|
|
885
886
|
hako_task_id: @hako_task_id,
|
886
887
|
)
|
887
888
|
Hako.logger.info("Unable to start tasks. Publish message to #{@autoscaling_topic_for_oneshot}: #{message}")
|
888
|
-
sns_client = Aws::SNS::Client.new
|
889
|
+
sns_client = Aws::SNS::Client.new(region: @region)
|
889
890
|
resp = sns_client.publish(topic_arn: @autoscaling_topic_for_oneshot, message: message)
|
890
891
|
Hako.logger.info("Sent message_id=#{resp.message_id}")
|
891
892
|
sleep(RUN_TASK_INTERVAL)
|
@@ -895,7 +896,7 @@ module Hako
|
|
895
896
|
MIN_ASG_INTERVAL = 1
|
896
897
|
MAX_ASG_INTERVAL = 120
|
897
898
|
def try_scale_out_with_as(task_definition)
|
898
|
-
autoscaling = Aws::AutoScaling::Client.new
|
899
|
+
autoscaling = Aws::AutoScaling::Client.new(region: @region)
|
899
900
|
interval = MIN_ASG_INTERVAL
|
900
901
|
Hako.logger.info("Unable to start tasks. Start trying scaling out '#{@autoscaling_group_for_oneshot}'")
|
901
902
|
loop do
|
@@ -997,6 +998,34 @@ module Hako
|
|
997
998
|
if definition[:privileged]
|
998
999
|
cmd << '--privileged'
|
999
1000
|
end
|
1001
|
+
if definition[:linux_parameters]
|
1002
|
+
if definition[:linux_parameters][:capabilities]
|
1003
|
+
cp = definition[:linux_parameters][:capabilities]
|
1004
|
+
%i[add drop].each do |a_or_d|
|
1005
|
+
cp[a_or_d]&.each do |c|
|
1006
|
+
cmd << "--cap-#{a_or_d}=#{c}"
|
1007
|
+
end
|
1008
|
+
end
|
1009
|
+
end
|
1010
|
+
|
1011
|
+
if definition[:linux_parameters][:devices]
|
1012
|
+
devs = definition[:linux_parameters][:devices]
|
1013
|
+
devs.each do |dev|
|
1014
|
+
opts = dev[:host_path]
|
1015
|
+
opts += ":#{dev[:container_path]}" if dev[:container_path]
|
1016
|
+
if dev[:permissions]
|
1017
|
+
dev[:permissions].each do |permission|
|
1018
|
+
opts += permission[0] if %w[read write mknod].include?(permission)
|
1019
|
+
end
|
1020
|
+
end
|
1021
|
+
cmd << "--device=#{opts}"
|
1022
|
+
end
|
1023
|
+
end
|
1024
|
+
|
1025
|
+
if definition[:init_process_enabled]
|
1026
|
+
cmd << '--init'
|
1027
|
+
end
|
1028
|
+
end
|
1000
1029
|
definition.fetch(:volumes_from).each do |volumes_from|
|
1001
1030
|
p volumes_from
|
1002
1031
|
end
|
@@ -37,6 +37,7 @@ module Hako
|
|
37
37
|
struct.member(:log_configuration, Schema::Nullable.new(log_configuration_schema))
|
38
38
|
struct.member(:ulimits, Schema::Nullable.new(ulimits_schema))
|
39
39
|
struct.member(:extra_hosts, Schema::Nullable.new(extra_hosts_schema))
|
40
|
+
struct.member(:linux_parameters, Schema::Nullable.new(linux_parameters_schema))
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -89,6 +90,33 @@ module Hako
|
|
89
90
|
end
|
90
91
|
end
|
91
92
|
|
93
|
+
def linux_parameters_schema
|
94
|
+
Schema::Structure.new.tap do |struct|
|
95
|
+
struct.member(:capabilities, Schema::Nullable.new(capabilities_schema))
|
96
|
+
struct.member(:devices, Schema::Nullable.new(devices_schema))
|
97
|
+
struct.member(:init_process_enabled, Schema::Nullable.new(Schema::Boolean.new))
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def capabilities_schema
|
102
|
+
Schema::Structure.new.tap do |struct|
|
103
|
+
struct.member(:add, Schema::UnorderedArray.new(Schema::String.new))
|
104
|
+
struct.member(:drop, Schema::UnorderedArray.new(Schema::String.new))
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def devices_schema
|
109
|
+
Schema::UnorderedArray.new(device_schema)
|
110
|
+
end
|
111
|
+
|
112
|
+
def device_schema
|
113
|
+
Schema::Structure.new.tap do |struct|
|
114
|
+
struct.member(:host_path, Schema::String.new)
|
115
|
+
struct.member(:container_path, Schema::Nullable.new(Schema::String.new))
|
116
|
+
struct.member(:permissions, Schema::UnorderedArray.new(Schema::String.new))
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
92
120
|
def extra_hosts_schema
|
93
121
|
Schema::UnorderedArray.new(extra_host_schema)
|
94
122
|
end
|
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: 1.8.
|
4
|
+
version: 1.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kohei Suzuki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-applicationautoscaling
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.4.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 1.4.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: aws-sdk-elasticloadbalancing
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -275,6 +275,7 @@ files:
|
|
275
275
|
- examples/hello-autoscaling-group.yml
|
276
276
|
- examples/hello-autoscaling.yml
|
277
277
|
- examples/hello-awslogs-driver.yml
|
278
|
+
- examples/hello-cap-add-app.yml
|
278
279
|
- examples/hello-lb-v2.yml
|
279
280
|
- examples/hello-lb.yml
|
280
281
|
- examples/hello-nofront.yml
|