hako 2.1.0 → 2.2.0

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
  SHA256:
3
- metadata.gz: 1a314c9baebed4e29a7f3650abec5d8f988f57a54db5ba979957040a15b01ba0
4
- data.tar.gz: f7221e593ed0ded7fb3b8f3f312d289da9efacb7fae79408e935d20f3badfeb9
3
+ metadata.gz: ff65e26d2cf4eae4e30db26a06c20b805691df1ef69b6b3f13978d556621c39b
4
+ data.tar.gz: f7e69c8ba3e9de134ed0392a051d58d88ee70d6876751dfb2c7e8077672587e9
5
5
  SHA512:
6
- metadata.gz: 4f2507875d79feae5c66f61c9cabe735dafadf80c0395217363772c812663a8a93b73ad52219e6b19364b335ebdbfd3b6ebfe4bd86df68dd68b898b9fce774bc
7
- data.tar.gz: 29d24a5c810a615d9bfff1d553d8a84ccf6bfdad33fbf24b9900841f41cb1de3afd558bda73d45c0b3fe47f6ded8e8e21a4beb22ca86f685a89d9f82a7becbd1
6
+ metadata.gz: f3db0f686407d5c0c5a7905b6773b642eaa60ba7ad5eef714b8047750ae31c588adc7ddd000ed80ea5c707cbd8e2380fc9ebcaedd825a341a1eb2836c1ad65e2
7
+ data.tar.gz: 93159fa006ba102e18b3053b9f26efa372fd04052afc2a06cf935bede3cc13c6cae569d3b197740b9c71db4d4890970a8ff88dbc2cacfc62d84f2bea2cd921eb
@@ -1,3 +1,11 @@
1
+ # 2.2.0 (2018-06-29)
2
+ ## New features
3
+ - Add support for `scheduling_strategy` on service
4
+ - Change existing ELB's subnets when different from definition
5
+ ## Bug fixes
6
+ - Take task-level cpu/memory into account on scale out
7
+ - Show `--memory-reservation` in the dry-run output
8
+
1
9
  # 2.1.0 (2018-04-18)
2
10
  ## New features
3
11
  - Support Network Load Balancer
@@ -59,6 +59,7 @@ module Hako
59
59
  end
60
60
  @placement_constraints = options.fetch('placement_constraints', [])
61
61
  @placement_strategy = options.fetch('placement_strategy', [])
62
+ @scheduling_strategy = options.fetch('scheduling_strategy', nil)
62
63
  @execution_role_arn = options.fetch('execution_role_arn', nil)
63
64
  @cpu = options.fetch('cpu', nil)
64
65
  @memory = options.fetch('memory', nil)
@@ -85,7 +86,7 @@ module Hako
85
86
  # @param [Hash<String, Container>] containers
86
87
  # @return [nil]
87
88
  def deploy(containers)
88
- unless @desired_count
89
+ if @desired_count.nil? && @scheduling_strategy != 'DAEMON'
89
90
  validation_error!('desired_count must be set')
90
91
  end
91
92
  front_port = determine_front_port
@@ -798,16 +799,19 @@ module Hako
798
799
  cluster: @cluster,
799
800
  service_name: @app_id,
800
801
  task_definition: task_definition_arn,
801
- desired_count: 0,
802
802
  role: @role,
803
803
  deployment_configuration: @deployment_configuration,
804
804
  placement_constraints: @placement_constraints,
805
805
  placement_strategy: @placement_strategy,
806
+ scheduling_strategy: @scheduling_strategy,
806
807
  launch_type: @launch_type,
807
808
  platform_version: @platform_version,
808
809
  network_configuration: @network_configuration,
809
810
  health_check_grace_period_seconds: @health_check_grace_period_seconds,
810
811
  }
812
+ if @scheduling_strategy != 'DAEMON'
813
+ params[:desired_count] = 0
814
+ end
811
815
  if ecs_elb_client.find_or_create_load_balancer(front_port)
812
816
  ecs_elb_client.modify_attributes
813
817
  params[:load_balancers] = [ecs_elb_client.load_balancer_params_for_service]
@@ -942,7 +946,10 @@ module Hako
942
946
 
943
947
  RUN_TASK_INTERVAL = 10
944
948
  def try_scale_out_with_sns(task_definition)
945
- required_cpu, required_memory = task_definition.container_definitions.inject([0, 0]) { |(cpu, memory), d| [cpu + d.cpu, memory + (d.memory_reservation || d.memory)] }
949
+ required_cpu = task_definition.cpu && task_definition.cpu.to_i
950
+ required_cpu ||= task_definition.container_definitions.inject(0) { |cpu, d| cpu + d.cpu }
951
+ required_memory = task_definition.memory && task_definition.memory.to_i
952
+ required_memory ||= task_definition.container_definitions.inject(0) { |memory, d| memory + (d.memory_reservation || d.memory) }
946
953
  @hako_task_id ||= SecureRandom.uuid
947
954
  message = JSON.dump(
948
955
  group_name: @autoscaling_group_for_oneshot,
@@ -1025,7 +1032,10 @@ module Hako
1025
1032
  # @param [Array<Aws::ECS::Types::ContainerInstance>] container_instances
1026
1033
  # @return [Boolean]
1027
1034
  def has_capacity?(task_definition, container_instances)
1028
- required_cpu, required_memory = task_definition.container_definitions.inject([0, 0]) { |(cpu, memory), d| [cpu + d.cpu, memory + (d.memory_reservation || d.memory)] }
1035
+ required_cpu = task_definition.cpu && task_definition.cpu.to_i
1036
+ required_cpu ||= task_definition.container_definitions.inject(0) { |cpu, d| cpu + d.cpu }
1037
+ required_memory = task_definition.memory && task_definition.memory.to_i
1038
+ required_memory ||= task_definition.container_definitions.inject(0) { |memory, d| memory + (d.memory_reservation || d.memory) }
1029
1039
  container_instances.any? do |ci|
1030
1040
  cpu = ci.remaining_resources.find { |r| r.name == 'CPU' }.integer_value
1031
1041
  memory = ci.remaining_resources.find { |r| r.name == 'MEMORY' }.integer_value
@@ -1043,6 +1053,9 @@ module Hako
1043
1053
  if definition[:memory]
1044
1054
  cmd << '--memory' << "#{definition[:memory]}M"
1045
1055
  end
1056
+ if definition[:memory_reservation]
1057
+ cmd << '--memory-reservation' << "#{definition[:memory_reservation]}M"
1058
+ end
1046
1059
  definition.fetch(:links).each do |link|
1047
1060
  cmd << '--link' << link
1048
1061
  end
@@ -130,8 +130,18 @@ module Hako
130
130
  return nil
131
131
  end
132
132
 
133
+ load_balancer = describe_load_balancer
134
+ subnets = @elb_v2_config.fetch('subnets').sort
135
+ if load_balancer && subnets != load_balancer.availability_zones.map(&:subnet_id).sort
136
+ if @dry_run
137
+ Hako.logger.info("elb_client.set_subnets(load_balancer_arn: #{load_balancer.load_balancer_arn}, subnets: #{subnets}) (dry-run)")
138
+ else
139
+ Hako.logger.info("Updating ELBv2 subnets to #{subnets}")
140
+ elb_client.set_subnets(load_balancer_arn: load_balancer.load_balancer_arn, subnets: subnets)
141
+ end
142
+ end
143
+
133
144
  if @elb_v2_config.key?('load_balancer_attributes')
134
- load_balancer = describe_load_balancer
135
145
  attributes = @elb_v2_config.fetch('load_balancer_attributes').map { |key, value| { key: key, value: value } }
136
146
  if @dry_run
137
147
  if load_balancer
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hako
4
- VERSION = '2.1.0'
4
+ VERSION = '2.2.0'
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.1.0
4
+ version: 2.2.0
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-04-18 00:00:00.000000000 Z
11
+ date: 2018-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-applicationautoscaling