Replacing a killed container only if required
This commit is contained in:
@ -316,8 +316,15 @@ class DockerClient
|
|||||||
DockerContainerPool.remove_from_all_containers(container, @execution_environment, bypass_semaphore: true)
|
DockerContainerPool.remove_from_all_containers(container, @execution_environment, bypass_semaphore: true)
|
||||||
# create new container and add it to @all_containers and @containers.
|
# create new container and add it to @all_containers and @containers.
|
||||||
# ToDo: How long does creating a new cotainer take? We're still locking the semaphore.
|
# ToDo: How long does creating a new cotainer take? We're still locking the semaphore.
|
||||||
|
|
||||||
|
missing_counter_count = execution_environment.pool_size - @all_containers[execution_environment.id].length
|
||||||
|
if missing_counter_count > 0
|
||||||
|
Rails.logger.error('kill_container: Creating a new container.')
|
||||||
new_container = self.class.create_container(@execution_environment)
|
new_container = self.class.create_container(@execution_environment)
|
||||||
DockerContainerPool.add_to_all_containers(new_container, @execution_environment, bypass_semaphore: true)
|
DockerContainerPool.add_to_all_containers(new_container, @execution_environment, bypass_semaphore: true)
|
||||||
|
else
|
||||||
|
Rails.logger.error('Container killed and removed for ' + execution_environment.to_s + ' but not creating a new one. Currently, ' + missing_counter_count.abs + ' more containers than the configured pool size are available.')
|
||||||
|
end
|
||||||
DockerContainerPool.release_semaphore
|
DockerContainerPool.release_semaphore
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ class DockerContainerPool
|
|||||||
remove_from_all_containers(container, execution_environment, bypass_semaphore: true)
|
remove_from_all_containers(container, execution_environment, bypass_semaphore: true)
|
||||||
missing_counter_count = execution_environment.pool_size - @all_containers[execution_environment.id].length
|
missing_counter_count = execution_environment.pool_size - @all_containers[execution_environment.id].length
|
||||||
if missing_counter_count > 0
|
if missing_counter_count > 0
|
||||||
Rails.logger.error('Creating a new container and returning that.')
|
Rails.logger.error('replace_broken_container: Creating a new container and returning that.')
|
||||||
new_container = create_container(execution_environment)
|
new_container = create_container(execution_environment)
|
||||||
DockerContainerPool.add_to_all_containers(new_container, execution_environment, bypass_semaphore: true)
|
DockerContainerPool.add_to_all_containers(new_container, execution_environment, bypass_semaphore: true)
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user