Skip to content

Commit

Permalink
Improve error handling / display when Ansible Runner errors
Browse files Browse the repository at this point in the history
  • Loading branch information
shanemcd committed Apr 26, 2021
1 parent 1e7b7d1 commit 15ad0c3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions awx/main/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,8 @@ def status_handler(self, status_data, runner_config):
if k in job_env:
job_env[k] = v
self.instance = self.update_model(self.instance.pk, job_args=json.dumps(runner_config.command), job_cwd=runner_config.cwd, job_env=job_env)
elif status_data['status'] == 'error':
self.instance = self.update_model(self.instance.pk, result_traceback=status_data['result_traceback'])

def check_handler(self, config):
"""
Expand Down Expand Up @@ -3002,13 +3004,20 @@ def _run_internal(self, receptor_ctl):
# TODO: There should be a more efficient way of getting this information
receptor_work_list = receptor_ctl.simple_command("work list")
detail = receptor_work_list[self.unit_id]['Detail']
state_name = receptor_work_list[self.unit_id]['StateName']

if 'exceeded quota' in detail:
logger.warn(detail)
log_name = self.task.instance.log_format
logger.warn(f"Could not launch pod for {log_name}. Exceeded quota.")
self.task.update_model(self.task.instance.pk, status='pending')
return

# If ansible-runner ran, but the job itself failed, the traceback information
# is saved via the status_handler passed in to the processor.
if state_name == 'Succeeded':
return res

raise RuntimeError(detail)

return res
Expand Down

0 comments on commit 15ad0c3

Please sign in to comment.