Revert "Log terminated_by_client
to Sentry"
This reverts commits3ad94653
andc6461f6b
This commit is contained in:
@ -105,24 +105,19 @@ class SubmissionsController < ApplicationController
|
|||||||
# are registered first, the runner socket may still be nil.
|
# are registered first, the runner socket may still be nil.
|
||||||
client_socket, runner_socket = nil
|
client_socket, runner_socket = nil
|
||||||
|
|
||||||
@tubesock_debug_events = []
|
|
||||||
client_kill = false
|
|
||||||
hijack do |tubesock|
|
hijack do |tubesock|
|
||||||
client_socket = tubesock
|
client_socket = tubesock
|
||||||
|
|
||||||
client_socket.onopen do |event|
|
client_socket.onopen do |_event|
|
||||||
@tubesock_debug_events << {type: :open, data: event}
|
|
||||||
kill_client_socket(client_socket) and return true if @embed_options[:disable_run]
|
kill_client_socket(client_socket) and return true if @embed_options[:disable_run]
|
||||||
end
|
end
|
||||||
|
|
||||||
client_socket.onclose do |event|
|
client_socket.onclose do |_event|
|
||||||
@tubesock_debug_events << {type: :close, data: event}
|
|
||||||
runner_socket&.close(:terminated_by_client)
|
runner_socket&.close(:terminated_by_client)
|
||||||
@testrun[:status] ||= :terminated_by_client
|
@testrun[:status] ||= :terminated_by_client
|
||||||
end
|
end
|
||||||
|
|
||||||
client_socket.onmessage do |raw_event|
|
client_socket.onmessage do |raw_event|
|
||||||
@tubesock_debug_events << {type: :message, data: raw_event}
|
|
||||||
# Obviously, this is just flushing the current connection: Filtering.
|
# Obviously, this is just flushing the current connection: Filtering.
|
||||||
next if raw_event == "\n"
|
next if raw_event == "\n"
|
||||||
|
|
||||||
@ -138,7 +133,6 @@ class SubmissionsController < ApplicationController
|
|||||||
|
|
||||||
case event[:cmd]
|
case event[:cmd]
|
||||||
when :client_kill
|
when :client_kill
|
||||||
client_kill = true
|
|
||||||
@testrun[:status] = :terminated_by_client
|
@testrun[:status] = :terminated_by_client
|
||||||
close_client_connection(client_socket)
|
close_client_connection(client_socket)
|
||||||
Rails.logger.debug('Client exited container.')
|
Rails.logger.debug('Client exited container.')
|
||||||
@ -163,10 +157,6 @@ class SubmissionsController < ApplicationController
|
|||||||
Sentry.set_extras(data: raw_event)
|
Sentry.set_extras(data: raw_event)
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
client_socket.onerror do |event|
|
|
||||||
@tubesock_debug_events << {type: :error, data: event}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# If running is not allowed (and the socket is closed), we can stop here.
|
# If running is not allowed (and the socket is closed), we can stop here.
|
||||||
@ -176,7 +166,6 @@ class SubmissionsController < ApplicationController
|
|||||||
durations = @submission.run(@file) do |socket, starting_time|
|
durations = @submission.run(@file) do |socket, starting_time|
|
||||||
runner_socket = socket
|
runner_socket = socket
|
||||||
@testrun[:starting_time] = starting_time
|
@testrun[:starting_time] = starting_time
|
||||||
@tubesock_debug_events << {type: :send, data: {cmd: :status, status: :container_running}}
|
|
||||||
client_socket.send_data JSON.dump({cmd: :status, status: :container_running})
|
client_socket.send_data JSON.dump({cmd: :status, status: :container_running})
|
||||||
|
|
||||||
runner_socket.on :stdout do |data|
|
runner_socket.on :stdout do |data|
|
||||||
@ -248,13 +237,11 @@ class SubmissionsController < ApplicationController
|
|||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
extract_durations(e)
|
extract_durations(e)
|
||||||
ensure
|
ensure
|
||||||
close_client_connection(client_socket) unless client_kill
|
close_client_connection(client_socket)
|
||||||
save_testrun_output 'run'
|
save_testrun_output 'run'
|
||||||
Sentry.capture_message('Execution got terminated by client', extra: {websocket: @tubesock_debug_events, submission: @submission.id}) if @testrun[:status] == :terminated_by_client && !client_kill
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def score
|
def score
|
||||||
@tubesock_debug_events = []
|
|
||||||
client_socket = nil
|
client_socket = nil
|
||||||
disable_scoring = @embed_options[:disable_score] || !@submission.exercise.teacher_defined_assessment?
|
disable_scoring = @embed_options[:disable_score] || !@submission.exercise.teacher_defined_assessment?
|
||||||
|
|
||||||
@ -300,7 +287,6 @@ class SubmissionsController < ApplicationController
|
|||||||
def statistics; end
|
def statistics; end
|
||||||
|
|
||||||
def test
|
def test
|
||||||
@tubesock_debug_events = []
|
|
||||||
client_socket = nil
|
client_socket = nil
|
||||||
|
|
||||||
hijack do |tubesock|
|
hijack do |tubesock|
|
||||||
@ -354,7 +340,6 @@ class SubmissionsController < ApplicationController
|
|||||||
# We don't want to store this (arbitrary) exit command and redirect it ourselves
|
# We don't want to store this (arbitrary) exit command and redirect it ourselves
|
||||||
client_socket.send_data JSON.dump({cmd: :exit})
|
client_socket.send_data JSON.dump({cmd: :exit})
|
||||||
client_socket.send_data nil, :close
|
client_socket.send_data nil, :close
|
||||||
@tubesock_debug_events << {type: :send, data: {cmd: :exit}}
|
|
||||||
# We must not close the socket manually (with `client_socket.close`), as this would close it twice.
|
# We must not close the socket manually (with `client_socket.close`), as this would close it twice.
|
||||||
# When the socket is closed twice, nginx registers a `Connection reset by peer` error.
|
# When the socket is closed twice, nginx registers a `Connection reset by peer` error.
|
||||||
# Tubesock automatically closes the socket when the `hijack` block ends and otherwise ignores `Errno::ECONNRESET`.
|
# Tubesock automatically closes the socket when the `hijack` block ends and otherwise ignores `Errno::ECONNRESET`.
|
||||||
@ -416,7 +401,6 @@ class SubmissionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
@testrun[:messages].push message
|
@testrun[:messages].push message
|
||||||
@testrun[:status] = message[:status] if message[:status]
|
@testrun[:status] = message[:status] if message[:status]
|
||||||
@tubesock_debug_events << {type: :send, data: message}
|
|
||||||
client_socket.send_data JSON.dump(message)
|
client_socket.send_data JSON.dump(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user