Skip to content

Commit

Permalink
English string validation to error code validation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmzoneill committed Feb 21, 2024
1 parent 402c29d commit a516325
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions awx/main/tasks/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import logging
import os
import psycopg
from io import StringIO
from contextlib import redirect_stdout
import shutil
Expand Down Expand Up @@ -630,10 +631,17 @@ def cluster_node_heartbeat(dispatch_time=None, worker_tasks=None):
logger.error("Host {} last checked in at {}, marked as lost.".format(other_inst.hostname, other_inst.last_seen))

except DatabaseError as e:
if 'did not affect any rows' in str(e):
logger.debug('Another instance has marked {} as lost'.format(other_inst.hostname))
if hasattr(e, 'sqlstate'):
sqlstate = e.sqlstate
sqlstate_str = psycopg.errors.lookup(sqlstate)
logger.debug('SQL Error state: {} - {}'.format(sqlstate, sqlstate_str))

if sqlstate == psycopg.errors.NoData:
logger.debug('Another instance has marked {} as lost'.format(other_inst.hostname))
else:
logger.exception("Error marking {} as lost.".format(other_inst.hostname))
else:
logger.exception('Error marking {} as lost'.format(other_inst.hostname))
logger.exception('No SQL state available. Error marking {} as lost'.format(other_inst.hostname))

# Run local reaper
if worker_tasks is not None:
Expand Down

0 comments on commit a516325

Please sign in to comment.