DCP: Move pool location to code_ocean.yml
This commit is contained in:
@ -50,7 +50,7 @@ default: &default
|
||||
# If TLS support is not enabled, this token is transmitted in clear text!
|
||||
token: SECRET
|
||||
# The maximum time in seconds a runner may idle at the runner management before
|
||||
# it is removed. Each interaction with the runner resets this time (Poseidon only)
|
||||
# it is removed. Each begin of an interaction with the runner resets this time
|
||||
unused_runner_expiration_time: 180
|
||||
|
||||
|
||||
|
@ -3,7 +3,6 @@ default: &default
|
||||
connection_timeout: 3
|
||||
pool:
|
||||
active: false
|
||||
location: http://localhost:7100
|
||||
ports: !ruby/range 4500..4600
|
||||
|
||||
development:
|
||||
@ -12,7 +11,6 @@ development:
|
||||
ws_host: ws://127.0.0.1:2376 #url to connect rails server to docker host
|
||||
workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %>
|
||||
pool:
|
||||
location: http://localhost:7100
|
||||
active: true
|
||||
refill:
|
||||
async: false
|
||||
@ -26,7 +24,6 @@ production:
|
||||
host: unix:///var/run/docker.sock
|
||||
pool:
|
||||
active: true
|
||||
location: http://localhost:3000
|
||||
refill:
|
||||
async: false
|
||||
batch_size: 8
|
||||
@ -40,7 +37,6 @@ staging:
|
||||
host: unix:///var/run/docker.sock
|
||||
pool:
|
||||
active: true
|
||||
location: http://localhost:3000
|
||||
refill:
|
||||
async: false
|
||||
batch_size: 8
|
||||
|
@ -3,7 +3,6 @@ default: &default
|
||||
connection_timeout: 3
|
||||
pool:
|
||||
active: false
|
||||
location: http://localhost:7100
|
||||
ports: !ruby/range 4500..4600
|
||||
|
||||
development:
|
||||
@ -13,7 +12,6 @@ development:
|
||||
workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %>
|
||||
pool:
|
||||
active: true
|
||||
location: http://localhost:7100
|
||||
refill:
|
||||
async: false
|
||||
batch_size: 8
|
||||
@ -26,7 +24,6 @@ production:
|
||||
host: unix:///var/run/docker.sock
|
||||
pool:
|
||||
active: true
|
||||
location: http://localhost:7100
|
||||
refill:
|
||||
async: false
|
||||
batch_size: 8
|
||||
@ -40,7 +37,6 @@ staging:
|
||||
host: unix:///var/run/docker.sock
|
||||
pool:
|
||||
active: true
|
||||
location: http://localhost:7100
|
||||
refill:
|
||||
async: false
|
||||
batch_size: 8
|
||||
|
@ -20,7 +20,7 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
|
||||
end
|
||||
|
||||
def self.request_from_management(environment)
|
||||
url = "#{config[:pool][:location]}/docker_container_pool/get_container/#{environment.id}"
|
||||
url = "#{config[:url]}/docker_container_pool/get_container/#{environment.id}"
|
||||
Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Requesting new runner at #{url}" }
|
||||
response = Faraday.get url
|
||||
container_id = JSON.parse(response.body)['id']
|
||||
@ -34,7 +34,7 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
|
||||
end
|
||||
|
||||
def destroy_at_management
|
||||
url = "#{self.class.config[:pool][:location]}/docker_container_pool/destroy_container/#{container.id}"
|
||||
url = "#{self.class.config[:url]}/docker_container_pool/destroy_container/#{container.id}"
|
||||
Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Destroying runner at #{url}" }
|
||||
Faraday.get(url)
|
||||
rescue Faraday::Error => e
|
||||
@ -90,7 +90,7 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
|
||||
end
|
||||
|
||||
def self.available_images
|
||||
url = "#{config[:pool][:location]}/docker_container_pool/available_images"
|
||||
url = "#{config[:url]}/docker_container_pool/available_images"
|
||||
response = Faraday.get(url)
|
||||
json = JSON.parse(response.body)
|
||||
return json if response.success?
|
||||
@ -103,12 +103,17 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
|
||||
end
|
||||
|
||||
def self.config
|
||||
@config ||= begin
|
||||
# Since the docker configuration file contains code that must be executed, we use ERB templating.
|
||||
@config ||= CodeOcean::Config.new(:docker).read(erb: true)
|
||||
docker_config = CodeOcean::Config.new(:docker).read(erb: true)
|
||||
codeocean_config = CodeOcean::Config.new(:code_ocean).read[:runner_management] || {}
|
||||
# All keys in `docker_config` take precedence over those in `codeocean_config`
|
||||
docker_config.merge codeocean_config
|
||||
end
|
||||
end
|
||||
|
||||
def self.release
|
||||
url = "#{config[:pool][:location]}/docker_container_pool/dump_info"
|
||||
url = "#{config[:url]}/docker_container_pool/dump_info"
|
||||
response = Faraday.get(url)
|
||||
JSON.parse(response.body)['release']
|
||||
rescue Faraday::Error => e
|
||||
@ -118,7 +123,7 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
|
||||
end
|
||||
|
||||
def self.pool_size
|
||||
url = "#{config[:pool][:location]}/docker_container_pool/quantities"
|
||||
url = "#{config[:url]}/docker_container_pool/quantities"
|
||||
response = Faraday.get(url)
|
||||
pool_size = JSON.parse(response.body)
|
||||
pool_size.transform_keys(&:to_i)
|
||||
|
Reference in New Issue
Block a user