Do not create container if pooling is on and all containers are gone
This commit is contained in:
@ -90,10 +90,14 @@ class DockerClient
|
|||||||
def execute_command(command, before_execution_block, output_consuming_block)
|
def execute_command(command, before_execution_block, output_consuming_block)
|
||||||
tries ||= 0
|
tries ||= 0
|
||||||
@container = DockerContainerPool.get_container(@execution_environment)
|
@container = DockerContainerPool.get_container(@execution_environment)
|
||||||
before_execution_block.try(:call)
|
if @container
|
||||||
send_command(command, @container, &output_consuming_block)
|
before_execution_block.try(:call)
|
||||||
|
send_command(command, @container, &output_consuming_block)
|
||||||
|
else
|
||||||
|
raise('Alle Slots belegt. Versuche es später nochmal.')
|
||||||
|
end
|
||||||
rescue Excon::Errors::SocketError => error
|
rescue Excon::Errors::SocketError => error
|
||||||
(tries += 1) <= RETRY_COUNT ? retry : raise(error)
|
#(tries += 1) <= RETRY_COUNT ? retry : raise(error)
|
||||||
end
|
end
|
||||||
|
|
||||||
[:run, :test].each do |cause|
|
[:run, :test].each do |cause|
|
||||||
@ -187,7 +191,7 @@ class DockerClient
|
|||||||
|
|
||||||
# we may need to stop the exec call here..!!!
|
# we may need to stop the exec call here..!!!
|
||||||
FileUtils.rm_rf(local_workspace_path(container)) if local_workspace_path(container)
|
FileUtils.rm_rf(local_workspace_path(container)) if local_workspace_path(container)
|
||||||
FileUtils.mkdir(local_workspace_path)
|
FileUtils.mkdir(local_workspace_path(container))
|
||||||
DockerContainerPool.return_container(container, @execution_environment)
|
DockerContainerPool.return_container(container, @execution_environment)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ class DockerContainerPool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.create_container(execution_environment)
|
def self.create_container(execution_environment)
|
||||||
DockerClient.create_container(execution_environment)
|
DockerClient.create_container(execution_environment)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.return_container(container, execution_environment)
|
def self.return_container(container, execution_environment)
|
||||||
@ -26,7 +26,7 @@ class DockerContainerPool
|
|||||||
|
|
||||||
def self.get_container(execution_environment)
|
def self.get_container(execution_environment)
|
||||||
if config[:active]
|
if config[:active]
|
||||||
@containers[execution_environment.id].try(:shift) || create_container(execution_environment)
|
@containers[execution_environment.id].try(:shift) || nil
|
||||||
else
|
else
|
||||||
create_container(execution_environment)
|
create_container(execution_environment)
|
||||||
end
|
end
|
||||||
@ -49,6 +49,7 @@ class DockerContainerPool
|
|||||||
def self.refill_for_execution_environment(execution_environment)
|
def self.refill_for_execution_environment(execution_environment)
|
||||||
refill_count = [execution_environment.pool_size - @containers[execution_environment.id].length, config[:refill][:batch_size]].min
|
refill_count = [execution_environment.pool_size - @containers[execution_environment.id].length, config[:refill][:batch_size]].min
|
||||||
@containers[execution_environment.id] += refill_count.times.map { create_container(execution_environment) }
|
@containers[execution_environment.id] += refill_count.times.map { create_container(execution_environment) }
|
||||||
|
#refill_count.times.map { create_container(execution_environment) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.start_refill_task
|
def self.start_refill_task
|
||||||
|
Reference in New Issue
Block a user