lib/hako/schedulers/ecs.rb in hako-2.14.0 vs lib/hako/schedulers/ecs.rb in hako-2.15.0
- old
+ new
@@ -513,11 +513,12 @@
return true
end
if actual_definition.requires_compatibilities != @requires_compatibilities
return true
end
- actual_tags_set = Set.new(actual_tags.map { |t| {key: t.key, value: t.value } })
+
+ actual_tags_set = Set.new(actual_tags.map { |t| { key: t.key, value: t.value } })
tags_set = Set.new(@tags)
if actual_tags_set != tags_set
return true
end
@@ -574,41 +575,39 @@
# @param [Array<Hash>] definitions
# @return [Array<Boolean, Aws::ECS::Types::TaskDefinition]
def register_task_definition_for_oneshot(definitions)
10.times do |i|
- begin
- family = "#{@app_id}-oneshot"
- current_task_definition = describe_task_definition(family)
- if current_task_definition
- current_tags = ecs_client.list_tags_for_resource(resource_arn: current_task_definition.task_definition_arn).tags
- end
- if task_definition_changed?(definitions, current_task_definition, current_tags)
- new_task_definition = ecs_client.register_task_definition(
- family: family,
- task_role_arn: @task_role_arn,
- execution_role_arn: @execution_role_arn,
- network_mode: @network_mode,
- container_definitions: definitions,
- volumes: volumes_definition,
- requires_compatibilities: @requires_compatibilities,
- cpu: @cpu,
- memory: @memory,
- tags: @tags.empty? ? nil : @tags,
- ).task_definition
- return [true, new_task_definition]
- else
- return [false, current_task_definition]
- end
- rescue Aws::ECS::Errors::ClientException => e
- if e.message.include?('Too many concurrent attempts to create a new revision of the specified family')
- Hako.logger.error(e.message)
- interval = 2**i + rand(0.0..10.0)
- Hako.logger.error("Retrying register_task_definition_for_oneshot after #{interval} seconds")
- sleep(interval)
- else
- raise e
- end
+ family = "#{@app_id}-oneshot"
+ current_task_definition = describe_task_definition(family)
+ if current_task_definition
+ current_tags = ecs_client.list_tags_for_resource(resource_arn: current_task_definition.task_definition_arn).tags
+ end
+ if task_definition_changed?(definitions, current_task_definition, current_tags)
+ new_task_definition = ecs_client.register_task_definition(
+ family: family,
+ task_role_arn: @task_role_arn,
+ execution_role_arn: @execution_role_arn,
+ network_mode: @network_mode,
+ container_definitions: definitions,
+ volumes: volumes_definition,
+ requires_compatibilities: @requires_compatibilities,
+ cpu: @cpu,
+ memory: @memory,
+ tags: @tags.empty? ? nil : @tags,
+ ).task_definition
+ return [true, new_task_definition]
+ else
+ return [false, current_task_definition]
+ end
+ rescue Aws::ECS::Errors::ClientException => e
+ if e.message.include?('Too many concurrent attempts to create a new revision of the specified family')
+ Hako.logger.error(e.message)
+ interval = 2**i + rand(0.0..10.0)
+ Hako.logger.error("Retrying register_task_definition_for_oneshot after #{interval} seconds")
+ sleep(interval)
+ else
+ raise e
end
end
raise Error.new('Unable to register task definition for oneshot due to too many client errors')
end