Ensure that logs are returned when containers blow up
This commit is contained in:
@@ -96,10 +96,21 @@ module Pipeline::Rpc::Worker
|
||||
def run_container
|
||||
log "Invoking container"
|
||||
begin
|
||||
@result = @analysis_run.analyze!
|
||||
data = @analysis_run.analyze!
|
||||
if data[:exit_status] != 0
|
||||
@error = {
|
||||
worker_error_code: 513,
|
||||
error: "Container returned exit status of #{data[:exit_status]}"
|
||||
}
|
||||
@error.merge!(data)
|
||||
else
|
||||
@result = data
|
||||
end
|
||||
rescue => e
|
||||
msg = "Error from container"
|
||||
log msg
|
||||
log e
|
||||
puts e.backtrace
|
||||
@error = {
|
||||
worker_error_code: 513,
|
||||
error: msg,
|
||||
|
||||
@@ -30,23 +30,27 @@ module Pipeline::Runtime
|
||||
|
||||
def analyze!
|
||||
puts "Starting container invocation"
|
||||
container_driver = Pipeline::Util::ContainerDriver.new(runc, img, configurator, solution_dir)
|
||||
@result = container_driver.invoke(working_directory, args)
|
||||
begin
|
||||
container_driver = Pipeline::Util::ContainerDriver.new(runc, img, configurator, solution_dir)
|
||||
@result = container_driver.invoke(working_directory, args)
|
||||
rescue => e
|
||||
end
|
||||
puts "Completed invocation"
|
||||
puts @logs.inspect
|
||||
{
|
||||
data = {
|
||||
exercise_slug: exercise_slug,
|
||||
solution_dir: solution_dir,
|
||||
rootfs_source: rootfs_source,
|
||||
result: result,
|
||||
invocation: @result.report,
|
||||
logs: @logs.inspect,
|
||||
exit_status: exit_status
|
||||
}
|
||||
rescue => e
|
||||
puts "Exception in analyze: #{e.message}"
|
||||
puts e.backtrace
|
||||
raise
|
||||
begin
|
||||
data[:result] = result if exit_status == 0
|
||||
rescue => e
|
||||
puts "Error reading result"
|
||||
data[:error] = e
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
def working_directory
|
||||
|
||||
@@ -21,8 +21,6 @@ module Pipeline::Util
|
||||
|
||||
def call
|
||||
invoke_process
|
||||
|
||||
|
||||
puts "status: #{status}" unless suppress_output
|
||||
puts "stdout: #{stdout}" unless suppress_output
|
||||
puts "stderr: #{stderr}" unless suppress_output
|
||||
|
||||
@@ -24,10 +24,14 @@ module Pipeline::Util
|
||||
puts "HERE: #{@logs}" + @logs.class.to_s
|
||||
begin
|
||||
run_cmd.call
|
||||
@logs << run_cmd
|
||||
rescue => e
|
||||
puts e.message
|
||||
puts "HERE"
|
||||
puts " --------- "
|
||||
raise
|
||||
ensure
|
||||
@logs << run_cmd
|
||||
kill_cmd.call
|
||||
@logs << kill_cmd
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user