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