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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7c0c22449d4bbfeb7fd6f6e54e0696b3545047a
4
- data.tar.gz: 2dbc3ea5ff6a88ff2fa993e17e355dabce67d804
3
+ metadata.gz: 70c493530e6b2a7355d402ae08d9305cbcdc5c89
4
+ data.tar.gz: fce07c67ce4a4d0c438b4ea341ae29ac72ccae7d
5
5
  SHA512:
6
- metadata.gz: a01ec75ccaa500548a170b57d888d10655efc317f88b660e7fec545f4afd7cef6475e34d3643f478c42f6f98333b9b5b1e2322c979bf48f74de7695168bf7fa3
7
- data.tar.gz: 98a23ca8ade1ce65ae0c81ef9bbc7daa2d01968c2c9ab9c4bb814b756086ab0379f7de2fa47e8dbfe33991a679f001cb37690ede379b2b1d1c2ccdaf0b5f2104
6
+ metadata.gz: 2d175b26ce5af0c9bb6b23a1a7c91d61cc44794ee9add9a8efd6a8e9a2a0ee8f8ab21a2572a184632437b1e78e6f2962532628e06af8d9a9778fdb17ddf5784b
7
+ data.tar.gz: 0fbfb30c8c28f6e42564765e8b49c81462729399706ba70fe8c60aaa7ac4202ae17703fad572712632f8f0842bc5e06561db50c42c04f4a52c5fb76125659c8a
data/.rubocop.yml CHANGED
@@ -31,6 +31,8 @@ Style/RaiseArgs:
31
31
  EnforcedStyle: compact
32
32
  Style/SignalException:
33
33
  Enabled: false
34
+ Style/StderrPuts:
35
+ Enabled: false
34
36
  Style/TrailingCommaInArguments:
35
37
  Enabled: false
36
38
  Style/TrailingCommaInLiteral:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 1.8.4 (2017-11-24)
2
+ ## Improvements
3
+ - Support `linux_parameters` option
4
+ - S3 and SNS client now uses the same region with ECS
5
+
1
6
  # 1.8.3 (2017-09-25)
2
7
  ## Improvements
3
8
  - Support `extra_hosts` option
@@ -0,0 +1,13 @@
1
+ scheduler:
2
+ type: ecs
3
+ region: ap-northeast-1
4
+ cluster: eagletmt
5
+ desired_count: 1
6
+ app:
7
+ image: busybox
8
+ memory: 128
9
+ cpu: 256
10
+ command: ['echo', 'hello with SYS_RAWIO']
11
+ linux_parameters:
12
+ capabilities:
13
+ add: ['SYS_RAWIO']
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'
@@ -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'
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hako
4
- VERSION = '1.8.3'
4
+ VERSION = '1.8.4'
5
5
  end
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.3
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-09-25 00:00:00.000000000 Z
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: '0'
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: '0'
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