hako 2.0.3 → 2.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3defba0a6b4f94fe0288e2adddf94e7ed3fa0f747ed5af52923e191ac6980b8f
4
- data.tar.gz: 2e8d3ebca2cc2193106e9b2daa1619e71d455d3feacc6a539330652db436f5a7
3
+ metadata.gz: 2de7cfe5e38e22aaf20d4bca43d9a3b579eafd5eb68173a260c448df063864cc
4
+ data.tar.gz: 9ff76702eb2e6be3ffff566cd897cf670e84fe8fd3addd45cba17d5b025426d3
5
5
  SHA512:
6
- metadata.gz: ce6babefafe1cc36fe1846f55d9be70ec0e1b1afad8f6a6887aaf3df2669650c57a7c0474b484cd941627160bf0bc247c1f44533560e09e16073e58139cdc8a8
7
- data.tar.gz: 3103640c9dd528a861dec9ea902e124cf5bb7b8657ed19aed74e53460fc63d04ce54e5c9dd66931c8a0b8948419760b85923b3d3e4260ca1b49c0dfcfc90d3e5
6
+ metadata.gz: 299bb255b8e7f1e7a768c298b303a1a1ef9366959cbaf3c29560a121a2100e72f9b07b0ae8e8af1c52f1e12f8d659bf112ed32cda636590ba088b8933b423332
7
+ data.tar.gz: c9937025cda397635911b79e8fafca65cfdaa423eb26386c62e14cbe5aaed7d10bc3ad8f1cdaadbed09a4025617282ca75531c126e5249a3a3ccc3c9f45bb6c5
@@ -1,3 +1,10 @@
1
+ # 2.0.4 (2018-02-26)
2
+ ## Bug fixes
3
+ - Pass AWS region of ECS scheduler to other AWS clients (CloudWatch, ApplicationAutoScaling)
4
+ - Eliminate `--memory` parameter from dry-run output if it's not given
5
+ - Give missing unit to the value of `--memory` parameter in dry-run output
6
+ - Take `memory_reservation` into account when calculating required memory
7
+
1
8
  # 2.0.3 (2018-02-16)
2
9
  ## Bug fixes
3
10
  - create_aws_cloud_watch_logs_log_group script: Skip creating CloudWatch log group on dry-run
@@ -44,7 +44,7 @@ module Hako
44
44
  end
45
45
  @dynamic_port_mapping = options.fetch('dynamic_port_mapping', @ecs_elb_options.nil?)
46
46
  if options.key?('autoscaling')
47
- @autoscaling = EcsAutoscaling.new(options.fetch('autoscaling'), dry_run: @dry_run)
47
+ @autoscaling = EcsAutoscaling.new(options.fetch('autoscaling'), @region, dry_run: @dry_run)
48
48
  end
49
49
  @autoscaling_group_for_oneshot = options.fetch('autoscaling_group_for_oneshot', nil)
50
50
  @autoscaling_topic_for_oneshot = options.fetch('autoscaling_topic_for_oneshot', nil)
@@ -939,7 +939,7 @@ module Hako
939
939
 
940
940
  RUN_TASK_INTERVAL = 10
941
941
  def try_scale_out_with_sns(task_definition)
942
- required_cpu, required_memory = task_definition.container_definitions.inject([0, 0]) { |(cpu, memory), d| [cpu + d.cpu, memory + d.memory] }
942
+ required_cpu, required_memory = task_definition.container_definitions.inject([0, 0]) { |(cpu, memory), d| [cpu + d.cpu, memory + (d.memory_reservation || d.memory)] }
943
943
  @hako_task_id ||= SecureRandom.uuid
944
944
  message = JSON.dump(
945
945
  group_name: @autoscaling_group_for_oneshot,
@@ -1022,7 +1022,7 @@ module Hako
1022
1022
  # @param [Array<Aws::ECS::Types::ContainerInstance>] container_instances
1023
1023
  # @return [Boolean]
1024
1024
  def has_capacity?(task_definition, container_instances)
1025
- required_cpu, required_memory = task_definition.container_definitions.inject([0, 0]) { |(cpu, memory), d| [cpu + d.cpu, memory + d.memory] }
1025
+ required_cpu, required_memory = task_definition.container_definitions.inject([0, 0]) { |(cpu, memory), d| [cpu + d.cpu, memory + (d.memory_reservation || d.memory)] }
1026
1026
  container_instances.any? do |ci|
1027
1027
  cpu = ci.remaining_resources.find { |r| r.name == 'CPU' }.integer_value
1028
1028
  memory = ci.remaining_resources.find { |r| r.name == 'MEMORY' }.integer_value
@@ -1037,7 +1037,9 @@ module Hako
1037
1037
  cmd = %w[docker run]
1038
1038
  cmd << '--name' << definition.fetch(:name)
1039
1039
  cmd << '--cpu-shares' << definition.fetch(:cpu)
1040
- cmd << '--memory' << definition.fetch(:memory)
1040
+ if definition[:memory]
1041
+ cmd << '--memory' << "#{definition[:memory]}M"
1042
+ end
1041
1043
  definition.fetch(:links).each do |link|
1042
1044
  cmd << '--link' << link
1043
1045
  end
@@ -8,7 +8,8 @@ require 'hako/error'
8
8
  module Hako
9
9
  module Schedulers
10
10
  class EcsAutoscaling
11
- def initialize(options, dry_run:)
11
+ def initialize(options, region, dry_run:)
12
+ @region = region
12
13
  @dry_run = dry_run
13
14
  @role_arn = required_option(options, 'role_arn')
14
15
  @min_capacity = required_option(options, 'min_capacity')
@@ -124,12 +125,12 @@ module Hako
124
125
 
125
126
  # @return [Aws::ApplicationAutoScaling]
126
127
  def autoscaling_client
127
- @autoscaling_client ||= Aws::ApplicationAutoScaling::Client.new
128
+ @autoscaling_client ||= Aws::ApplicationAutoScaling::Client.new(region: @region)
128
129
  end
129
130
 
130
131
  # @return [Aws::CloudWatch::Client]
131
132
  def cw_client
132
- @cw_client ||= Aws::CloudWatch::Client.new
133
+ @cw_client ||= Aws::CloudWatch::Client.new(region: @region)
133
134
  end
134
135
 
135
136
  # @param [Aws::ECS::Types::Service] service
@@ -23,7 +23,7 @@ module Hako
23
23
  Schema::Structure.new.tap do |struct|
24
24
  struct.member(:image, Schema::String.new)
25
25
  struct.member(:cpu, Schema::Integer.new)
26
- struct.member(:memory, Schema::Integer.new)
26
+ struct.member(:memory, Schema::Nullable.new(Schema::Integer.new))
27
27
  struct.member(:memory_reservation, Schema::Nullable.new(Schema::Integer.new))
28
28
  struct.member(:links, Schema::UnorderedArray.new(Schema::String.new))
29
29
  struct.member(:port_mappings, Schema::UnorderedArray.new(port_mapping_schema))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hako
4
- VERSION = '2.0.3'
4
+ VERSION = '2.0.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: 2.0.3
4
+ version: 2.0.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: 2018-02-16 00:00:00.000000000 Z
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-applicationautoscaling
@@ -367,7 +367,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
367
367
  version: '0'
368
368
  requirements: []
369
369
  rubyforge_project:
370
- rubygems_version: 2.7.3
370
+ rubygems_version: 2.7.6
371
371
  signing_key:
372
372
  specification_version: 4
373
373
  summary: Deploy Docker container