Skip to content

Commit

Permalink
Consume job_explanation from runner, fix error reporting error (#13482
Browse files Browse the repository at this point in the history
)
  • Loading branch information
AlanCoding authored Aug 30, 2023
1 parent cf1e448 commit cdb4f0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions awx/main/tasks/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,10 @@ def status_handler(self, status_data, runner_config):
# We opened a connection just for that save, close it here now
connections.close_all()
elif status_data['status'] == 'error':
result_traceback = status_data.get('result_traceback', None)
if result_traceback:
self.delay_update(result_traceback=result_traceback)
for field_name in ('result_traceback', 'job_explanation'):
field_value = status_data.get(field_name, None)
if field_value:
self.delay_update(**{field_name: field_value})

def artifacts_handler(self, artifact_dir):
self.artifacts_processed = True
Expand Down
6 changes: 3 additions & 3 deletions awx/main/tasks/receptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,16 +432,16 @@ def _run_internal(self, receptor_ctl):
# massive, only ask for last 1000 bytes
startpos = max(stdout_size - 1000, 0)
resultsock, resultfile = receptor_ctl.get_work_results(self.unit_id, startpos=startpos, return_socket=True, return_sockfile=True)
resultsock.setblocking(False) # this makes resultfile reads non blocking
lines = resultfile.readlines()
receptor_output = b"".join(lines).decode()
if receptor_output:
self.task.runner_callback.delay_update(result_traceback=receptor_output)
self.task.runner_callback.delay_update(result_traceback=f'Worker output:\n{receptor_output}')
elif detail:
self.task.runner_callback.delay_update(result_traceback=detail)
self.task.runner_callback.delay_update(result_traceback=f'Receptor detail:\n{detail}')
else:
logger.warning(f'No result details or output from {self.task.instance.log_format}, status:\n{state_name}')
except Exception:
logger.exception(f'Work results error from job id={self.task.instance.id} work_unit={self.task.instance.work_unit_id}')
raise RuntimeError(detail)

return res
Expand Down

0 comments on commit cdb4f0b

Please sign in to comment.