From 412bf7f282c3b91d92fc29edd764acd10ac09541 Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Thu, 14 Oct 2021 14:52:38 -0400 Subject: [PATCH 1/2] Move error handling into try/catch block --- awx/main/tasks.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index daf96484cf..f2f9529cb8 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -3113,9 +3113,14 @@ class AWXReceptorJob: resultsock.shutdown(socket.SHUT_RDWR) resultfile.close() elif res.status == 'error': - unit_status = receptor_ctl.simple_command(f'work status {self.unit_id}') - detail = unit_status['Detail'] - state_name = unit_status['StateName'] + try: + unit_status = receptor_ctl.simple_command(f'work status {self.unit_id}') + detail = unit_status.get('Detail', None) + state_name = unit_status.get('StateName', None) + except RuntimeError as e: + detail = '' + state_name = '' + logger.warn(e) if 'exceeded quota' in detail: logger.warn(detail) From dd622dcc30cdfc57f6d59207543fca7575bacaa1 Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Fri, 15 Oct 2021 08:08:24 -0400 Subject: [PATCH 2/2] Change log level from 'warning' to 'exception' --- awx/main/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index f2f9529cb8..fbc25f52c9 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -3120,7 +3120,7 @@ class AWXReceptorJob: except RuntimeError as e: detail = '' state_name = '' - logger.warn(e) + logger.exception(e) if 'exceeded quota' in detail: logger.warn(detail)