From f72292cce2f7d70019f3346b2670f84af665ca76 Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Thu, 14 Oct 2021 14:52:38 -0400 Subject: [PATCH] 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 8cf1e39969..d51aac24cb 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -3122,9 +3122,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)