lib/hako/schedulers/ecs.rb in hako-0.20.1 vs lib/hako/schedulers/ecs.rb in hako-0.20.2

- old
+ new

@@ -33,13 +33,18 @@ end @dynamic_port_mapping = options.fetch('dynamic_port_mapping', @ecs_elb_options.nil?) if options.key?('autoscaling') @autoscaling = EcsAutoscaling.new(options.fetch('autoscaling'), dry_run: @dry_run) end + @autoscaling_group_for_oneshot = options.fetch('autoscaling_group_for_oneshot', nil) + @deployment_configuration = {} + %i[maximum_percent minimum_healthy_percent].each do |key| + @deployment_configuration[key] = options.dig('deployment_configuration', key.to_s) + end + @started_at = nil @container_instance_arn = nil - @autoscaling_group_for_oneshot = options.fetch('autoscaling_group_for_oneshot', nil) end # @param [Hash<String, Container>] containers # @return [nil] def deploy(containers) @@ -237,13 +242,13 @@ # @return [nil] def stop service = describe_service if service if @dry_run - Hako.logger.info("ecs_client.update_service(cluster: #{@cluster}, service: #{@app_id}, desired_count: 0)") + Hako.logger.info("ecs_client.update_service(cluster: #{service.cluster_arn}, service: #{service.service_arn}, desired_count: 0)") else - ecs_client.update_service(cluster: @cluster, service: @app_id, desired_count: 0) + ecs_client.update_service(cluster: service.cluster_arn, service: service.service_arn, desired_count: 0) Hako.logger.info("#{service.service_arn} is stopped") end else puts "Service #{@app_id} doesn't exist" end @@ -451,10 +456,11 @@ docker_labels: container.docker_labels, mount_points: container.mount_points, command: container.command, volumes_from: container.volumes_from, user: container.user, + log_configuration: container.log_configuration, } end # @param [Aws::ECS::Types::TaskDefinition] task_definition # @param [Array<String>] commands @@ -578,10 +584,11 @@ cluster: @cluster, service_name: @app_id, task_definition: task_definition_arn, desired_count: @desired_count, role: @role, + deployment_configuration: @deployment_configuration, } if ecs_elb_client.find_or_create_load_balancer(front_port) params[:load_balancers] = [ @ecs_elb_client.load_balancer_params_for_service.merge(container_name: 'front', container_port: 80), ] @@ -591,10 +598,11 @@ params = { cluster: @cluster, service: @app_id, desired_count: @desired_count, task_definition: task_definition_arn, + deployment_configuration: @deployment_configuration, } if @autoscaling # Keep current desired_count if autoscaling is enabled params[:desired_count] = service.desired_count end @@ -612,9 +620,14 @@ # @param [Hash] params # @return [Boolean] def service_changed?(service, params) SERVICE_KEYS.each do |key| if service.public_send(key) != params[key] + return true + end + end + params[:deployment_configuration].each do |key, val| + if val && val != service.deployment_configuration.public_send(key) return true end end false end