Disable DCP if other strategy class is chosen
This commit is contained in:
@ -13,14 +13,14 @@ div.mb-4
|
|||||||
= "CodeOcean Release:"
|
= "CodeOcean Release:"
|
||||||
pre = Sentry.configuration.release
|
pre = Sentry.configuration.release
|
||||||
|
|
||||||
- if DockerContainerPool.config[:active]
|
- if DockerContainerPool.active?
|
||||||
div.mb-4
|
div.mb-4
|
||||||
= "DockerContainerPool Release:"
|
= "DockerContainerPool Release:"
|
||||||
pre = DockerContainerPool.dump_info['release']
|
pre = DockerContainerPool.dump_info['release']
|
||||||
|
|
||||||
h2 Docker
|
h2 Docker
|
||||||
|
|
||||||
- if DockerContainerPool.config[:active]
|
- if DockerContainerPool.active?
|
||||||
h3 = t('.current')
|
h3 = t('.current')
|
||||||
.table-responsive
|
.table-responsive
|
||||||
table.table
|
table.table
|
||||||
|
@ -230,7 +230,7 @@ class DockerClient
|
|||||||
Rails.logger.info("destroying container #{container}")
|
Rails.logger.info("destroying container #{container}")
|
||||||
|
|
||||||
# Checks only if container assignment is not nil and not whether the container itself is still present.
|
# Checks only if container assignment is not nil and not whether the container itself is still present.
|
||||||
if container && !DockerContainerPool.config[:active]
|
if container && !DockerContainerPool.active?
|
||||||
container.kill
|
container.kill
|
||||||
container.port_bindings.each_value {|port| PortPool.release(port) }
|
container.port_bindings.each_value {|port| PortPool.release(port) }
|
||||||
begin
|
begin
|
||||||
@ -355,7 +355,7 @@ container_execution_time: nil}
|
|||||||
exit_thread_if_alive
|
exit_thread_if_alive
|
||||||
@socket.close
|
@socket.close
|
||||||
# if we use pooling and recylce the containers, put it back. otherwise, destroy it.
|
# if we use pooling and recylce the containers, put it back. otherwise, destroy it.
|
||||||
if DockerContainerPool.config[:active] && RECYCLE_CONTAINERS
|
if DockerContainerPool.active? && RECYCLE_CONTAINERS
|
||||||
self.class.return_container(container,
|
self.class.return_container(container,
|
||||||
@execution_environment)
|
@execution_environment)
|
||||||
else
|
else
|
||||||
@ -493,7 +493,7 @@ container_execution_time: nil}
|
|||||||
end
|
end
|
||||||
|
|
||||||
# if we use pooling and recylce the containers, put it back. otherwise, destroy it.
|
# if we use pooling and recylce the containers, put it back. otherwise, destroy it.
|
||||||
if DockerContainerPool.config[:active] && RECYCLE_CONTAINERS
|
if DockerContainerPool.active? && RECYCLE_CONTAINERS
|
||||||
self.class.return_container(container, @execution_environment)
|
self.class.return_container(container, @execution_environment)
|
||||||
else
|
else
|
||||||
self.class.destroy_container(container)
|
self.class.destroy_container(container)
|
||||||
|
@ -9,6 +9,11 @@ require 'concurrent/timer_task'
|
|||||||
# dump_info and quantities are still in use.
|
# dump_info and quantities are still in use.
|
||||||
|
|
||||||
class DockerContainerPool
|
class DockerContainerPool
|
||||||
|
def self.active?
|
||||||
|
# TODO: Refactor config and merge with code_ocean.yml
|
||||||
|
config[:active] && Runner.management_active? && Runner.strategy_class == Runner::Strategy::DockerContainerPool
|
||||||
|
end
|
||||||
|
|
||||||
def self.config
|
def self.config
|
||||||
# TODO: Why erb?
|
# TODO: Why erb?
|
||||||
@config ||= CodeOcean::Config.new(:docker).read(erb: true)[:pool]
|
@config ||= CodeOcean::Config.new(:docker).read(erb: true)[:pool]
|
||||||
@ -39,7 +44,7 @@ class DockerContainerPool
|
|||||||
|
|
||||||
def self.get_container(execution_environment)
|
def self.get_container(execution_environment)
|
||||||
# if pooling is active, do pooling, otherwise just create an container and return it
|
# if pooling is active, do pooling, otherwise just create an container and return it
|
||||||
if config[:active]
|
if active?
|
||||||
begin
|
begin
|
||||||
container_id = JSON.parse(Faraday.get("#{config[:location]}/docker_container_pool/get_container/#{execution_environment.id}").body)['id']
|
container_id = JSON.parse(Faraday.get("#{config[:location]}/docker_container_pool/get_container/#{execution_environment.id}").body)['id']
|
||||||
Docker::Container.get(container_id) if container_id.present?
|
Docker::Container.get(container_id) if container_id.present?
|
||||||
|
Reference in New Issue
Block a user