6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/services/runners/docker/run_task.rb', line 6
def perform(task:, slot:, runner_id:)
Rails.logger.debug("Performing Docker::RunTask for #{task} #{slot}")
pull_image(task: task, slot: slot)
Rails.logger.debug("Image pulled for #{task} #{slot}")
container = create_container(task: task, slot: slot, name: runner_id)
Rails.logger.debug("Container #{container.id} created for #{task} #{slot} with name #{runner_id}")
container.start
Rails.logger.debug("Container #{container.id} started")
runner_id
rescue Excon::Error, ::Docker::Error::TimeoutError => e then
message = "Docker connection error: #{e.message}"
message += "\n#{e.response.body}" if e.respond_to?(:response)
raise Node::NodeConnectionError, message
rescue ::Docker::Error::NotFoundError => e
raise "Docker image not found: #{e.message}"
end
|