diff --git a/lib/docker_client.rb b/lib/docker_client.rb index 5677c047..f6ab6b89 100644 --- a/lib/docker_client.rb +++ b/lib/docker_client.rb @@ -26,7 +26,12 @@ class DockerClient local_workspace_path = local_workspace_path(container) if local_workspace_path && Pathname.new(local_workspace_path).exist? - Pathname.new(local_workspace_path).children.each{ |p| p.rmtree} + Pathname.new(local_workspace_path).children.each do |p| + p.rmtree + rescue Errno::ENOENT => error + Raven.capture_exception(error) + Rails.logger.error('clean_container_workspace: Got Errno::ENOENT: ' + error.to_s) + end #FileUtils.rmdir(Pathname.new(local_workspace_path)) end end @@ -197,12 +202,17 @@ class DockerClient container.stop.kill container.port_bindings.values.each { |port| PortPool.release(port) } clean_container_workspace(container) + + # Checks only if container assignment is not nil and not whether the container itself is still present. if container container.delete(force: true, v: true) end rescue Docker::Error::NotFoundError => error Rails.logger.error('destroy_container: Rescued from Docker::Error::NotFoundError: ' + error.to_s) Rails.logger.error('No further actions are done concerning that.') + rescue Docker::Error::ConflictError => error + Rails.logger.error('destroy_container: Rescued from Docker::Error::ConflictError: ' + error.to_s) + Rails.logger.error('No further actions are done concerning that.') end #currently only used to check if containers have been started correctly, or other internal checks @@ -400,6 +410,7 @@ class DockerClient begin clean_container_workspace(container) rescue Docker::Error::NotFoundError => error + # FIXME: Create new container? Rails.logger.info('return_container: Rescued from Docker::Error::NotFoundError: ' + error.to_s) Rails.logger.info('Nothing is done here additionally. The container will be exchanged upon its next retrieval.') end diff --git a/lib/docker_container_pool.rb b/lib/docker_container_pool.rb index 64cd847c..79aeea40 100644 --- a/lib/docker_container_pool.rb +++ b/lib/docker_container_pool.rb @@ -52,13 +52,13 @@ class DockerContainerPool def self.create_container(execution_environment) Rails.logger.info('trying to create container for execution environment: ' + execution_environment.to_s) container = DockerClient.create_container(execution_environment) - container.status = 'available' + container.status = 'available' # FIXME: String vs Symbol usage? #Rails.logger.debug('created container ' + container.to_s + ' for execution environment ' + execution_environment.to_s) container end def self.return_container(container, execution_environment) - container.status = 'available' + container.status = 'available' # FIXME: String vs Symbol usage? if(@containers[execution_environment.id] && !@containers[execution_environment.id].include?(container)) @containers[execution_environment.id].push(container) else