lib/hako/schedulers/ecs.rb in hako-2.3.0 vs lib/hako/schedulers/ecs.rb in hako-2.3.1

- old
+ new

@@ -52,13 +52,17 @@ @autoscaling_topic_for_oneshot = options.fetch('autoscaling_topic_for_oneshot', nil) if @autoscaling_topic_for_oneshot && !@autoscaling_group_for_oneshot validation_error!('autoscaling_group_for_oneshot must be set when autoscaling_topic_for_oneshot is set') end @oneshot_notification_prefix = options.fetch('oneshot_notification_prefix', nil) - @deployment_configuration = {} - %i[maximum_percent minimum_healthy_percent].each do |key| - @deployment_configuration[key] = options.dig('deployment_configuration', key.to_s) + if options.key?('deployment_configuration') + @deployment_configuration = {} + %i[maximum_percent minimum_healthy_percent].each do |key| + @deployment_configuration[key] = options.fetch('deployment_configuration')[key.to_s] + end + else + @deployment_configuration = nil end @placement_constraints = options.fetch('placement_constraints', []) @placement_strategy = options.fetch('placement_strategy', []) @scheduling_strategy = options.fetch('scheduling_strategy', nil) @execution_role_arn = options.fetch('execution_role_arn', nil) @@ -356,10 +360,11 @@ return 0 end if @dry_run return DEFAULT_FRONT_PORT end + service = describe_service if service find_front_port(service) else new_front_port @@ -410,10 +415,11 @@ end unless actual_definition # Initial deployment return true end + actual_volume_definitions = {} actual_definition.volumes.each do |v| actual_volume_definitions[v.name] = v end container_definitions = {} @@ -626,10 +632,11 @@ Hako.logger.error("#{failure.arn} #{failure.reason}") end if result.tasks.empty? raise NoTasksStarted.new('No tasks started') end + result.tasks[0] rescue Aws::ECS::Errors::InvalidParameterException => e if e.message == 'No Container Instances were found in your cluster.' && on_no_tasks_started(task_definition) retry else @@ -872,10 +879,11 @@ end s.events.each do |e| if e.id == latest_event_id break end + Hako.logger.info "#{e.created_at}: #{e.message}" task_id = extract_task_id(e.message) if task_id && e.message.include?(' has started ') started_task_ids << task_id end @@ -1112,10 +1120,11 @@ end definition.fetch(:mount_points).each do |mount_point| source_volume = mount_point.fetch(:source_volume) v = volumes_definition.find { |d| d[:name] == source_volume } raise "Could not find volume #{source_volume}" unless v + source = v.dig(:host, :source_path) || source_volume cmd << '--volume' << "#{source}:#{mount_point.fetch(:container_path)}#{mount_point[:read_only] ? ':ro' : ''}" end definition.fetch(:volumes_from).each do |volumes_from| cmd << '--volumes-from' << "#{volumes_from.fetch(:source_container)}#{volumes_from[:read_only] ? ':ro' : ''}" @@ -1169,10 +1178,10 @@ cmd << "\\\n " definition.fetch(:environment).each do |env| name = env.fetch(:name) value = env.fetch(:value) - # additional_env (given in command line) has priority over env (declared in YAML) + # additional_env (given in command line) has priority over env (declared in definition file) unless additional_env.key?(name) cmd << '--env' << "#{name}=#{value}" cmd << "\\\n " end end