From ab5438d5ede59d3c6a2481644a6147446e707f29 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Thu, 5 Jan 2017 14:49:55 +0100 Subject: [PATCH 1/3] bumped excon to fix error in docker-api gem --- Gemfile.lock | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3493d81f..bd8caf11 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -97,6 +97,7 @@ GEM execjs coffee-script-source (1.10.0) concurrent-ruby (1.0.2) + concurrent-ruby (1.0.2-java) concurrent-ruby-ext (1.0.2) concurrent-ruby (~> 1.0.2) d3-rails (3.5.11) @@ -113,7 +114,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) @@ -419,3 +420,6 @@ DEPENDENCIES uglifier (>= 1.3.0) web-console (~> 2.0) will_paginate (~> 3.0) + +BUNDLED WITH + 1.13.6 From 254e8c65d1a37e498f96b8188d28de324490877b Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 11 Jan 2017 16:04:55 +0100 Subject: [PATCH 2/3] adjusted log levels for docker exit and kill messages --- lib/docker_client.rb | 6 +++--- lib/docker_container_pool.rb | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/docker_client.rb b/lib/docker_client.rb index 4672360f..a548cc82 100644 --- a/lib/docker_client.rb +++ b/lib/docker_client.rb @@ -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 @@ -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. diff --git a/lib/docker_container_pool.rb b/lib/docker_container_pool.rb index 7f1f16fd..a2dc1a2e 100644 --- a/lib/docker_container_pool.rb +++ b/lib/docker_container_pool.rb @@ -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? From 17f0f6fa9fa57f3fd4b124bb8371dd715ad34c15 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 11 Jan 2017 17:13:34 +0100 Subject: [PATCH 3/3] prevent calls on nil --- lib/docker_client.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/docker_client.rb b/lib/docker_client.rb index a548cc82..a8bdf915 100644 --- a/lib/docker_client.rb +++ b/lib/docker_client.rb @@ -325,7 +325,7 @@ class DockerClient end def self.image_tags - Docker::Image.all.map { |image| image.info['RepoTags'] }.flatten.reject { |tag| tag.include?('') } + Docker::Image.all.map { |image| image.info['RepoTags'] }.flatten.reject { |tag| tag.present? && tag.include?('') } end def initialize(options = {})