Merge commit '17f0f6fa9fa57f3fd4b124bb8371dd715ad34c15' into lti_param_model

This commit is contained in:
Tom Staubitz
2017-01-12 15:12:54 +01:00
3 changed files with 7 additions and 5 deletions

View File

@ -123,7 +123,7 @@ GEM
erubis (2.7.0)
eventmachine (1.0.9.1)
eventmachine (1.0.9.1-java)
excon (0.45.4)
excon (0.54.0)
execjs (2.6.0)
factory_girl (4.5.0)
activesupport (>= 3.0.0)

View File

@ -108,7 +108,7 @@ class DockerClient
container.status = :created
container
rescue Docker::Error::NotFoundError => error
Rails.logger.info('create_container: Got Docker::Error::NotFoundError: ' + error.to_s)
Rails.logger.error('create_container: Got Docker::Error::NotFoundError: ' + error.to_s)
destroy_container(container)
#(tries += 1) <= RETRY_COUNT ? retry : raise(error)
end
@ -325,7 +325,7 @@ class DockerClient
end
def self.image_tags
Docker::Image.all.map { |image| image.info['RepoTags'] }.flatten.reject { |tag| tag.include?('<none>') }
Docker::Image.all.map { |image| image.info['RepoTags'] }.flatten.reject { |tag| tag.present? && tag.include?('<none>') }
end
def initialize(options = {})
@ -390,8 +390,8 @@ class DockerClient
Timeout.timeout(@execution_environment.permitted_execution_time.to_i) do
#TODO: check phusion doku again if we need -i -t options here
output = container.exec(['bash', '-c', command])
Rails.logger.info "output from container.exec"
Rails.logger.info output
Rails.logger.debug "output from container.exec"
Rails.logger.debug output
result = {status: output[2] == 0 ? :ok : :failed, stdout: output[0].join.force_encoding('utf-8'), stderr: output[1].join.force_encoding('utf-8')}
end
# if we use pooling and recylce the containers, put it back. otherwise, destroy it.

View File

@ -7,7 +7,9 @@ class DockerContainerPool
@containers = ThreadSafe::Hash[ExecutionEnvironment.all.map { |execution_environment| [execution_environment.id, ThreadSafe::Array.new] }]
#as containers are not containing containers in use
@all_containers = ThreadSafe::Hash[ExecutionEnvironment.all.map { |execution_environment| [execution_environment.id, ThreadSafe::Array.new] }]
def self.clean_up
Rails.logger.info('Container Pool is now performing a cleanup. ')
@refill_task.try(:shutdown)
@all_containers.values.each do |containers|
DockerClient.destroy_container(containers.shift) until containers.empty?