lib/hako/schedulers/ecs.rb in hako-1.5.2 vs lib/hako/schedulers/ecs.rb in hako-1.6.0
- old
+ new
@@ -134,12 +134,13 @@
end
# @param [Hash<String, Container>] containers
# @param [Array<String>] commands
# @param [Hash<String, String>] env
- # @return [nil]
- def oneshot(containers, commands, env)
+ # @param [Boolean] no_wait
+ # @return [Integer] Returns exit code
+ def oneshot(containers, commands, env, no_wait: false)
definitions = create_definitions(containers)
definitions.each do |definition|
definition.delete(:essential)
end
@@ -159,11 +160,16 @@
Hako.logger.info "Task definition isn't changed: #{task_definition.task_definition_arn}"
end
@task = run_task(task_definition, commands, env)
Hako.logger.info "Started task: #{@task.task_arn}"
@scripts.each { |script| script.oneshot_started(self) }
- wait_for_oneshot_finish
+ if no_wait
+ puts @task.task_arn
+ 0
+ else
+ wait_for_oneshot_finish
+ end
end
end
# @return [nil]
def stop_oneshot
@@ -856,9 +862,10 @@
return false
end
autoscaling = Aws::AutoScaling::Client.new
interval = MIN_ASG_INTERVAL
+ Hako.logger.info("Unable to start tasks. Start trying scaling out '#{@autoscaling_group_for_oneshot}'")
loop do
begin
asg = autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: [@autoscaling_group_for_oneshot]).auto_scaling_groups[0]
rescue Aws::AutoScaling::Errors::Throttling => e
Hako.logger.error(e)