Add debug log statements to runner connection
This commit is contained in:

committed by
Sebastian Serth

parent
cc412b73bc
commit
d1a5773e60
@ -137,7 +137,6 @@ class SubmissionsController < ApplicationController
|
|||||||
@output = +''
|
@output = +''
|
||||||
|
|
||||||
socket.on :output do |data|
|
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
|
@output << data if @output.size + data.size <= max_output_buffer_size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,8 +34,10 @@ class Runner::Connection
|
|||||||
instance_variable_set(:"@#{event}_callback", block)
|
instance_variable_set(:"@#{event}_callback", block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def send(data)
|
def send(raw_data)
|
||||||
@socket.send(encode(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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -49,6 +51,7 @@ class Runner::Connection
|
|||||||
end
|
end
|
||||||
|
|
||||||
def on_message(raw_event)
|
def on_message(raw_event)
|
||||||
|
Rails.logger.debug("#{Time.zone.now.getutc}: Receiving from #{@socket.url}: #{raw_event.data.inspect}")
|
||||||
event = decode(raw_event)
|
event = decode(raw_event)
|
||||||
return unless BACKEND_OUTPUT_SCHEMA.valid?(event)
|
return unless BACKEND_OUTPUT_SCHEMA.valid?(event)
|
||||||
|
|
||||||
@ -64,10 +67,11 @@ class Runner::Connection
|
|||||||
def on_error(_event); end
|
def on_error(_event); end
|
||||||
|
|
||||||
def on_close(_event)
|
def on_close(_event)
|
||||||
|
Rails.logger.debug("#{Time.zone.now.getutc}: Closing connection to #{@socket.url} with status: #{@status}")
|
||||||
case @status
|
case @status
|
||||||
when :timeout
|
when :timeout
|
||||||
raise Runner::Error::ExecutionTimeout.new('Execution exceeded its time limit')
|
raise Runner::Error::ExecutionTimeout.new('Execution exceeded its time limit')
|
||||||
when :terminated
|
when :terminated_by_codeocean, :terminated_by_management
|
||||||
@exit_callback.call @exit_code
|
@exit_callback.call @exit_code
|
||||||
else # :established
|
else # :established
|
||||||
# If the runner is killed by the DockerContainerPool after the maximum allowed time per user and
|
# If the runner is killed by the DockerContainerPool after the maximum allowed time per user and
|
||||||
@ -77,7 +81,7 @@ class Runner::Connection
|
|||||||
end
|
end
|
||||||
|
|
||||||
def handle_exit(event)
|
def handle_exit(event)
|
||||||
@status = :terminated
|
@status = :terminated_by_management
|
||||||
@exit_code = event[:data]
|
@exit_code = event[:data]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
|
|||||||
# Assume correct termination for now and return exit code 0
|
# Assume correct termination for now and return exit code 0
|
||||||
# TODO: Can we use the actual exit code here?
|
# TODO: Can we use the actual exit code here?
|
||||||
@exit_code = 0
|
@exit_code = 0
|
||||||
@status = :terminated
|
@status = :terminated_by_codeocean
|
||||||
@socket.close
|
@socket.close
|
||||||
when /#{format(@strategy.execution_environment.test_command, class_name: '.*', filename: '.*', module_name: '.*')}/
|
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)
|
# TODO: Super dirty hack to redirect test output to stderr (remove attr_reader afterwards)
|
||||||
|
Reference in New Issue
Block a user