diff --git a/config/code_ocean.yml.example b/config/code_ocean.yml.example index 3c8cb672..740b1598 100644 --- a/config/code_ocean.yml.example +++ b/config/code_ocean.yml.example @@ -49,8 +49,8 @@ default: &default # The authorization token for connections to the runner management (Poseidon only) # 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) + # The maximum time in seconds a runner may idle at the runner management before + # it is removed. Each begin of an interaction with the runner resets this time unused_runner_expiration_time: 180 diff --git a/config/docker.yml.erb.ci b/config/docker.yml.erb.ci index 12415d0f..aaeceb14 100644 --- a/config/docker.yml.erb.ci +++ b/config/docker.yml.erb.ci @@ -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 diff --git a/config/docker.yml.erb.example b/config/docker.yml.erb.example index bb41db98..aaeceb14 100644 --- a/config/docker.yml.erb.example +++ b/config/docker.yml.erb.example @@ -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 diff --git a/lib/runner/strategy/docker_container_pool.rb b/lib/runner/strategy/docker_container_pool.rb index 26cdcb17..f426ee2c 100644 --- a/lib/runner/strategy/docker_container_pool.rb +++ b/lib/runner/strategy/docker_container_pool.rb @@ -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 - # Since the docker configuration file contains code that must be executed, we use ERB templating. - @config ||= CodeOcean::Config.new(:docker).read(erb: true) + @config ||= begin + # 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 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)