@@ -70,7 +70,7 @@ def inner_plan(job_invocation, host, template_invocation, proxy_selector, option
7070 . merge ( additional_options )
7171
7272 plan_delegated_action ( proxy , provider . proxy_action_class , action_options , proxy_action_class : ::Actions ::RemoteExecution ::ProxyAction )
73- plan_self :with_event_logging => true
73+ plan_self
7474 end
7575
7676 def finalize ( *args )
@@ -127,51 +127,28 @@ def continuous_output_providers
127127 end
128128
129129 def fill_continuous_output ( continuous_output )
130- if input [ :with_event_logging ]
131- continuous_output_from_template_invocation_events ( continuous_output )
132- return
133- end
134-
135- delegated_output . fetch ( 'result' , [ ] ) . each do |raw_output |
136- continuous_output . add_raw_output ( raw_output )
137- end
138-
139- final_timestamp = ( continuous_output . last_timestamp || task . ended_at ) . to_f + 1
140-
141- if task . state == 'stopped' && task . result == 'cancelled'
142- continuous_output . add_output ( _ ( 'Job cancelled by user' ) , 'debug' , final_timestamp )
143- else
144- fill_planning_errors_to_continuous_output ( continuous_output ) unless exit_status
145- end
146- if exit_status
147- continuous_output . add_output ( _ ( 'Exit status: %s' ) % exit_status , 'stdout' , final_timestamp )
148- elsif run_step &.error
149- continuous_output . add_output ( _ ( 'Job finished with error' ) + ": #{ run_step . error . exception_class } - #{ run_step . error . message } " , 'debug' , final_timestamp )
150- end
151- rescue => e
152- continuous_output . add_exception ( _ ( 'Error loading data from proxy' ) , e )
153- end
154-
155- def continuous_output_from_template_invocation_events ( continuous_output )
156130 begin
157131 # Trigger reload
158132 delegated_output unless task . state == 'stopped'
159133 rescue => e
160134 # This is enough, the error will get shown using add_exception at the end of the method
161135 end
162136
137+ # Show the outputs which are already stored in the database
163138 task . template_invocation . template_invocation_events . order ( :timestamp ) . find_each do |output |
164139 if output . event_type == 'exit'
165140 continuous_output . add_output ( _ ( 'Exit status: %s' ) % output . event , 'stdout' , output . timestamp )
166141 else
167142 continuous_output . add_raw_output ( output . as_raw_continuous_output )
168143 end
169144 end
145+
146+ # Attach the exception at the end
170147 continuous_output . add_exception ( _ ( 'Error loading data from proxy' ) , e ) if e
171148 end
172149
173150 def exit_status
174- input [ :with_event_logging ] ? task . template_invocation . template_invocation_events . find_by ( event_type : 'exit' ) &.event : delegated_output [ :exit_status ]
151+ task . template_invocation . template_invocation_events . find_by ( event_type : 'exit' ) &.event
175152 end
176153
177154 def host_id
0 commit comments