lib/hako/schedulers/ecs.rb in hako-0.21.1 vs lib/hako/schedulers/ecs.rb in hako-0.22.0
- old
+ new
@@ -1,14 +1,15 @@
# frozen_string_literal: true
require 'aws-sdk'
require 'hako'
require 'hako/error'
require 'hako/scheduler'
+require 'hako/schedulers/ecs_autoscaling'
require 'hako/schedulers/ecs_definition_comparator'
require 'hako/schedulers/ecs_elb'
require 'hako/schedulers/ecs_elb_v2'
-require 'hako/schedulers/ecs_autoscaling'
+require 'hako/schedulers/ecs_service_comparator'
module Hako
module Schedulers
class Ecs < Scheduler
class NoTasksStarted < Error
@@ -563,18 +564,11 @@
# @param [String] container_instance_arn
# @return [nil]
def report_container_instance(container_instance_arn)
container_instance = ecs_client.describe_container_instances(cluster: @cluster, container_instances: [container_instance_arn]).container_instances[0]
- ec2_client.describe_tags(filters: [{ name: 'resource-id', values: [container_instance.ec2_instance_id] }]).each do |page|
- tag = page.tags.find { |t| t.key == 'Name' }
- if tag
- Hako.logger.info "Container instance is #{container_instance_arn} (#{tag.value} #{container_instance.ec2_instance_id})"
- else
- Hako.logger.info "Container instance is #{container_instance_arn} (#{container_instance.ec2_instance_id})"
- end
- end
+ Hako.logger.info "Container instance is #{container_instance_arn} (#{container_instance.ec2_instance_id})"
end
# @param [String] task_definition_arn
# @param [Fixnum] front_port
# @return [Aws::ECS::Types::Service, Symbol]
@@ -613,26 +607,14 @@
:noop
end
end
end
- SERVICE_KEYS = %i[desired_count task_definition].freeze
-
# @param [Aws::ECS::Types::Service] service
# @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
+ EcsServiceComparator.new(params).different?(service)
end
# @param [Aws::ECS::Types::Service] service
# @return [nil]
def wait_for_ready(service)