Skip to content

Commit

Permalink
Fixes #37411 - Drop non event based output handling
Browse files Browse the repository at this point in the history
  • Loading branch information
adamruzicka committed Nov 6, 2024
1 parent 2ef6965 commit ae91f67
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions app/lib/actions/remote_execution/run_host_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def inner_plan(job_invocation, host, template_invocation, proxy_selector, option
.merge(additional_options)

plan_delegated_action(proxy, provider.proxy_action_class, action_options, proxy_action_class: ::Actions::RemoteExecution::ProxyAction)
plan_self :with_event_logging => true
plan_self
end

def finalize(*args)
Expand Down Expand Up @@ -127,51 +127,28 @@ def continuous_output_providers
end

def fill_continuous_output(continuous_output)
if input[:with_event_logging]
continuous_output_from_template_invocation_events(continuous_output)
return
end

delegated_output.fetch('result', []).each do |raw_output|
continuous_output.add_raw_output(raw_output)
end

final_timestamp = (continuous_output.last_timestamp || task.ended_at).to_f + 1

if task.state == 'stopped' && task.result == 'cancelled'
continuous_output.add_output(_('Job cancelled by user'), 'debug', final_timestamp)
else
fill_planning_errors_to_continuous_output(continuous_output) unless exit_status
end
if exit_status
continuous_output.add_output(_('Exit status: %s') % exit_status, 'stdout', final_timestamp)
elsif run_step&.error
continuous_output.add_output(_('Job finished with error') + ": #{run_step.error.exception_class} - #{run_step.error.message}", 'debug', final_timestamp)
end
rescue => e
continuous_output.add_exception(_('Error loading data from proxy'), e)
end

def continuous_output_from_template_invocation_events(continuous_output)
begin
# Trigger reload
delegated_output unless task.state == 'stopped'
rescue => e
# This is enough, the error will get shown using add_exception at the end of the method
end

# Show the outputs which are already stored in the database
task.template_invocation.template_invocation_events.order(:timestamp).find_each do |output|
if output.event_type == 'exit'
continuous_output.add_output(_('Exit status: %s') % output.event, 'stdout', output.timestamp)
else
continuous_output.add_raw_output(output.as_raw_continuous_output)
end
end

# Attach the exception at the end
continuous_output.add_exception(_('Error loading data from proxy'), e) if e
end

def exit_status
input[:with_event_logging] ? task.template_invocation.template_invocation_events.find_by(event_type: 'exit')&.event : delegated_output[:exit_status]
task.template_invocation.template_invocation_events.find_by(event_type: 'exit')&.event
end

def host_id
Expand Down

0 comments on commit ae91f67

Please sign in to comment.