mirror of
https://github.com/ansible/awx.git
synced 2026-04-14 06:29:25 -02:30
Show tracebacks from dependency failures (#5154)
This commit is contained in:
committed by
Shane McDonald
parent
390e1f9a0a
commit
f1273d5810
@@ -47,11 +47,16 @@ class HasStatus(object):
|
|||||||
return self.wait_until_status(self.started_statuses, interval=interval, timeout=timeout)
|
return self.wait_until_status(self.started_statuses, interval=interval, timeout=timeout)
|
||||||
|
|
||||||
def failure_output_details(self):
|
def failure_output_details(self):
|
||||||
|
msg = ''
|
||||||
if getattr(self, 'result_stdout', ''):
|
if getattr(self, 'result_stdout', ''):
|
||||||
output = bytes_to_str(self.result_stdout)
|
output = bytes_to_str(self.result_stdout)
|
||||||
if output:
|
if output:
|
||||||
return '\nstdout:\n{}'.format(output)
|
msg = '\nstdout:\n{}'.format(output)
|
||||||
return ''
|
if getattr(self, 'job_explanation', ''):
|
||||||
|
msg += '\njob_explanation: {}'.format(bytes_to_str(self.job_explanation))
|
||||||
|
if getattr(self, 'result_traceback', ''):
|
||||||
|
msg += '\nresult_traceback:\n{}'.format(bytes_to_str(self.result_traceback))
|
||||||
|
return msg
|
||||||
|
|
||||||
def assert_status(self, status_list, msg=None):
|
def assert_status(self, status_list, msg=None):
|
||||||
if isinstance(status_list, str):
|
if isinstance(status_list, str):
|
||||||
@@ -65,8 +70,6 @@ class HasStatus(object):
|
|||||||
else:
|
else:
|
||||||
msg += '\n'
|
msg += '\n'
|
||||||
msg += '{0}-{1} has status of {2}, which is not in {3}.'.format(self.type.title(), self.id, self.status, status_list)
|
msg += '{0}-{1} has status of {2}, which is not in {3}.'.format(self.type.title(), self.id, self.status, status_list)
|
||||||
if getattr(self, 'job_explanation', ''):
|
|
||||||
msg += '\njob_explanation: {}'.format(bytes_to_str(self.job_explanation))
|
|
||||||
if getattr(self, 'execution_environment', ''):
|
if getattr(self, 'execution_environment', ''):
|
||||||
msg += '\nexecution_environment: {}'.format(bytes_to_str(self.execution_environment))
|
msg += '\nexecution_environment: {}'.format(bytes_to_str(self.execution_environment))
|
||||||
if getattr(self, 'related', False):
|
if getattr(self, 'related', False):
|
||||||
@@ -75,19 +78,17 @@ class HasStatus(object):
|
|||||||
msg += f'\nee_credential: {ee.credential}'
|
msg += f'\nee_credential: {ee.credential}'
|
||||||
msg += f'\nee_pull_option: {ee.pull}'
|
msg += f'\nee_pull_option: {ee.pull}'
|
||||||
msg += f'\nee_summary_fields: {ee.summary_fields}'
|
msg += f'\nee_summary_fields: {ee.summary_fields}'
|
||||||
if getattr(self, 'result_traceback', ''):
|
|
||||||
msg += '\nresult_traceback:\n{}'.format(bytes_to_str(self.result_traceback))
|
|
||||||
|
|
||||||
msg += self.failure_output_details()
|
msg += self.failure_output_details()
|
||||||
|
|
||||||
if getattr(self, 'job_explanation', '').startswith('Previous Task Failed'):
|
if getattr(self, 'job_explanation', '').startswith('Previous Task Failed'):
|
||||||
try:
|
try:
|
||||||
data = json.loads(self.job_explanation.replace('Previous Task Failed: ', ''))
|
data = json.loads(self.job_explanation.replace('Previous Task Failed: ', ''))
|
||||||
dep_output = self.connection.get(
|
dependency = self.walk('/api/v2/{0}s/{1}/'.format(data['job_type'], data['job_id']))
|
||||||
'{0}/api/v2/{1}s/{2}/stdout/'.format(self.endpoint.split('/api')[0], data['job_type'], data['job_id']),
|
if hasattr(dependency, 'failure_output_details'):
|
||||||
query_parameters=dict(format='txt_download'),
|
msg += '\nDependency output:\n{}'.format(dependency.failure_output_details())
|
||||||
).content
|
else:
|
||||||
msg += '\nDependency output:\n{}'.format(bytes_to_str(dep_output))
|
msg += '\nDependency info:\n{}'.format(dependency)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg += '\nFailed to obtain dependency stdout: {}'.format(e)
|
msg += '\nFailed to obtain dependency stdout: {}'.format(e)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user