diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index b01cf970..b2ad3d85 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -137,7 +137,6 @@ class SubmissionsController < ApplicationController @output = +'' socket.on :output do |data| - Rails.logger.info("#{Time.zone.now.getutc}: Container sending: #{data.inspect}") @output << data if @output.size + data.size <= max_output_buffer_size end diff --git a/lib/runner/connection.rb b/lib/runner/connection.rb index 4bf725af..05f1242f 100644 --- a/lib/runner/connection.rb +++ b/lib/runner/connection.rb @@ -34,8 +34,10 @@ class Runner::Connection instance_variable_set(:"@#{event}_callback", block) end - def send(data) - @socket.send(encode(data)) + def send(raw_data) + encoded_message = encode(raw_data) + Rails.logger.debug("#{Time.zone.now.getutc}: Sending to #{@socket.url}: #{encoded_message.inspect}") + @socket.send(encoded_message) end private @@ -49,6 +51,7 @@ class Runner::Connection end def on_message(raw_event) + Rails.logger.debug("#{Time.zone.now.getutc}: Receiving from #{@socket.url}: #{raw_event.data.inspect}") event = decode(raw_event) return unless BACKEND_OUTPUT_SCHEMA.valid?(event) @@ -64,10 +67,11 @@ class Runner::Connection def on_error(_event); end def on_close(_event) + Rails.logger.debug("#{Time.zone.now.getutc}: Closing connection to #{@socket.url} with status: #{@status}") case @status when :timeout raise Runner::Error::ExecutionTimeout.new('Execution exceeded its time limit') - when :terminated + when :terminated_by_codeocean, :terminated_by_management @exit_callback.call @exit_code else # :established # If the runner is killed by the DockerContainerPool after the maximum allowed time per user and @@ -77,7 +81,7 @@ class Runner::Connection end def handle_exit(event) - @status = :terminated + @status = :terminated_by_management @exit_code = event[:data] end diff --git a/lib/runner/strategy/docker_container_pool.rb b/lib/runner/strategy/docker_container_pool.rb index 84d5219e..2a8026a4 100644 --- a/lib/runner/strategy/docker_container_pool.rb +++ b/lib/runner/strategy/docker_container_pool.rb @@ -123,7 +123,7 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy # Assume correct termination for now and return exit code 0 # TODO: Can we use the actual exit code here? @exit_code = 0 - @status = :terminated + @status = :terminated_by_codeocean @socket.close when /#{format(@strategy.execution_environment.test_command, class_name: '.*', filename: '.*', module_name: '.*')}/ # TODO: Super dirty hack to redirect test output to stderr (remove attr_reader afterwards)